Commit 1e85ec4f authored by dgoud-nisum-com's avatar dgoud-nisum-com Committed by rbonthala-nisum-com

Mt 77 edit account (#45)

* edit and MT-69

* edit and MT-69

* MT-77 Edit Account Completed
parent 35ed81fb
......@@ -290,7 +290,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
menuItems.push({"menu" : "My Org","icon" : "fa fa-address-card-o fa-2x","path" : "templates/myOrg.html"});
menuItems.push({"menu" : "My Profile","icon" : "fa fa-address-book-o fa-2x","path" : "templates/profile.html"});
}else if(role == "Delivery Manager" || role == "Director"){
menuItems.push({"menu" : "Manage Accounts","icon" : "fa fa-user-plus fa-2x","path" : "templates/accounts.html"});
menuItems.push({"menu" : "Manage Accounts","icon" : "fa fa fa-user fa-2x","path" : "templates/accounts.html"});
menuItems.push({"menu" : "Manage Employees","icon" : "fa fa-user-plus fa-2x","path" : "templates/roles.html"});
menuItems.push({"menu" : "Manage Team","icon" : "fa fa-sitemap fa-2x","path" : "templates/projectDetails.html"});
menuItems.push({"menu" : "Manage Domains","icon" : "fa fa-handshake-o","path" : "templates/domains.html"});
......
......@@ -6,9 +6,10 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
"industryType":"",
"status":"",
"deliveryManagers":[],
"action":""
"action":"",
"clientAddress":""
};
var getCellTemplate = '<p class="col-lg-12"><i class="fa fa-pencil-square-o fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" data-placement="center" title="View" onmouseenter="$(this).tooltip(\'show\')" ng-click="grid.appScope.getRowData(row,\'Update\')"></i>'+
var getCellTemplate = '<p class="col-lg-12"><i class="fa fa-pencil-square-o fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" data-placement="center" title="Edit" onmouseenter="$(this).tooltip(\'show\')" ng-click="grid.appScope.getRowData(row,\'Update\')"></i>'+
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class="fa fa-minus-circle fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" data-placement="left" title="Delete" onmouseenter="$(this).tooltip(\'show\')" ng-click="grid.appScope.getRowData(row,\'Delete\')"></i></p>';
$scope.gridOptions = {
paginationPageSizes : [ 10, 20, 30, 40, 50, 100],
......@@ -17,7 +18,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
pageSize:10,
enableFiltering: true,
columnDefs : [
{field : 'accountId',displayName: 'Account ID', enableColumnMenu: true, enableSorting: true,enableFiltering: true, width:120,cellClass: 'grid-align'},
{field : 'accountId',displayName: 'Account ID', enableColumnMenu: true, enableSorting: true,enableFiltering: false, width:120,cellClass: 'grid-align'},
{field : 'accountName',displayName: 'Account Name', enableColumnMenu: false, enableSorting: false,enableFiltering: true,cellClass: 'grid-align'},
{field : 'industryType',displayName: 'Industry Type', enableColumnMenu: false, enableSorting: true,enableFiltering: true,cellClass: 'grid-align'},
{field : 'status',displayName: 'Status', enableColumnMenu: false, enableSorting: true,enableFiltering: true,cellClass: 'grid-align'},
......@@ -27,13 +28,15 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
};
$scope.gridOptions.data = $scope.records;
$scope.getRowData = function(row, action){
$scope.parentData.id = row.entity.id;
$scope.parentData.accountId = row.entity.accountId;
$scope.parentData.accountName = row.entity.accountName;
$scope.parentData.industryType = row.entity.industryType;
$scope.parentData.deliveryManagers = row.entity.deliveryManagers;
$scope.parentData.status = row.entity.status;
$scope.parentData.clientAddress = row.entity.clientAddress;
if(action == "Update")
$scope.updateAccount(action, $scope.parentData);
$scope.addAccount(action, $scope.parentData);
else if(action == "Delete")
$scope.deleteAccount(row,action);
}
......@@ -45,7 +48,6 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
method : "GET",
url : appConfig.appUri + "account/accounts"
}).then(function mySuccess(response) {
console.log(response.data);
$scope.gridOptions.data=response.data;
}, function myError(response) {
showAlert("Something went wrong while fetching data!!!");
......@@ -69,23 +71,6 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
else showAlert('Account assigning/updation failed!!!');
});
}
// $scope.updateAccount = function(action, userData){
// $('#home').addClass('md-scroll-mask');
// userData.action = action;
// $mdDialog.show ({
// clickOutsideToClose: true,
// scope: $scope,
// preserveScope: true,
// templateUrl: 'templates/newAccount.html',
// controller: addController,
// locals:{dataToPass: userData,gridOptionsData: $scope.gridOptions.data, employees: $scope.employees},
// }).then(function(result) {
// if(result == "Add") showAlert('Account assigned successfully');
// else if(result == "Update") showAlert('Account updated successfully');
// else if(result == "Cancelled") console.log(result);
// else showAlert('Account assigning/updation failed!!!');
// });
// }
function showAlert(message) {
$mdDialog.show($mdDialog.alert().parent(
angular.element(document.querySelector('#popupContainer')))
......@@ -143,6 +128,21 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
$mdSelect.hide();
}
})
if(dataToPass.action == "Add"){
$scope.accountId = "";
$scope.accountName = "";
$scope.industryType = "";
$scope.clientAddress = "";
$scope.deliveryManagers = [];
$scope.alertMsg = "";
}else if(dataToPass.action == "Update"){
$scope.accountId = dataToPass.accountId;
$scope.accountName = dataToPass.accountName;
$scope.industryType = dataToPass.industryType;
$scope.clientAddress = dataToPass.clientAddress;
$scope.managersSelectedList = dataToPass.deliveryManagers;
}
$scope.getDeliveryManagers = function(){
$http({
method : "GET",
......@@ -154,24 +154,9 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
$scope.gridOptions.data = [];
});
};
$scope.duplicateAccNameValidation = function(){
$http({
method : "GET",
url : appConfig.appUri + "/account/accounts/"+$scope.accountName
}).then(function mySuccess(response) {
if(response.data =='Account already exist'){
$scope.alertMsg=response.data;
$scope.addButtonvisible=true;
$('#addButton').addClass('addButtonDisable');
}else{
//$scope.alertMsg=response.data;
$scope.addButtonvisible=false;
$('#addButton').removeClass('addButtonDisable');
}
}, function myError(response) {
showAlert("Something went wrong while fetching data!!!");
});
$scope.closeSelectBox = function () {
$mdSelect.hide();
}
$scope.cancel = function(){
$mdDialog.hide("Cancelled");
......@@ -210,7 +195,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
ev.stopPropagation();
});
$scope.validateFields = function(){
$scope.validateFields = function(action){
var managersSelectedList = $scope.managersSelectedList;
var accountName = $scope.accountName;
var industryType = $scope.industryType;
......@@ -222,6 +207,7 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
}
return employeeIdsArray;
}
if(action == "Add"){
if(managersSelectedList == undefined){
$scope.alertMsg = "Please select a accountManager";
document.getElementById('selectManager').focus();
......@@ -238,17 +224,37 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
else{
$scope.alertMsg = "";
var record = {"accountName":$scope.accountName,"industryType":$scope.industryType,"clientAddress":$scope.clientAddress,"deliveryManagers":$scope.accountManagers()};
console.log(record);
addingAccount(record,$scope.templateTitle);
$timeout(function(){updateGrid($scope.templateTitle, record)},500);
addOrUpdateAccount(record,$scope.templateTitle,"N");
$timeout(function(){updateGrid($scope.templateTitle, record)},200);
}
}else if(action == "Update"){
if(managersSelectedList == undefined){
$scope.alertMsg = "Please select a accountManager";
document.getElementById('selectManager').focus();
}else if(accountName == undefined){
$scope.alertMsg = "Please enter the account Name";
document.getElementById('accountName').focus();
}else if(industryType == undefined){
$scope.alertMsg = "Please enter the industry type";
document.getElementById('industryType').focus();
}else if(clientAddress == undefined){
$scope.alertMsg = "Please enter the client address";
document.getElementById('clientAddress').focus();
}else{
$scope.alertMsg = "";
var record = {"accountId":$scope.accountId, "accountName":$scope.accountName,"industryType":$scope.industryType,"clientAddress":$scope.clientAddress,"deliveryManagers":$scope.accountManagers()};
record.id = $scope.parentData.id;
addOrUpdateAccount(record,$scope.templateTitle,"U");
$timeout(function(){updateGrid($scope.templateTitle, record)},200);
}
}
};
addingAccount = function(record,action){
addOrUpdateAccount = function(record,action,flag){
var urlRequest = "";
if(action == "Add"){
urlRequest = appConfig.appUri+ "/account/accounts";
//}else if(action == "Update"){
//urlRequest = appConfig.appUri+ "project/updateProject";
if(action == "Add" || action == "Update"){
urlRequest = appConfig.appUri+"account/accounts?action="+flag ;
}
var req = {
method : 'POST',
......@@ -260,6 +266,11 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
}
$http(req).then(function mySuccess(response) {
$scope.result = "Success";
if(response.data =='Account already exist'){
$scope.alertMsg=response.data;
}else{
$scope.alertMsg="";
}
}, function myError(response){
$scope.result = "Error";
});
......@@ -270,11 +281,9 @@ myApp.controller("assignAccountsController",function($scope, myFactory, $mdDialo
if(action == "Add" || action == "Delete"){
$scope.refreshPage();
}
//else if(action == "Update"){
// var existingRecord = getRowEntity($scope.projectId);
// var index = gridOptionsData.indexOf(existingRecord);
// gridOptionsData[index] = record;
// }
else if(action == "Update"){
$scope.refreshPage();
}
$mdDialog.hide(action);
}else{
$mdDialog.hide("Error");
......
......@@ -205,10 +205,6 @@ md-dialog{
padding-left: 0px !important;
}
/* Styles added for accounts module*/
.addButtonDisable{
background-color: darkgrey !important;
}
.ui-grid-canvas .ui-grid-cell-contents {
white-space: normal;
}
......@@ -61,16 +61,17 @@
<p> {{item.employeeName}} <span ng-click="removeSelectedLead(item)" class="glyphicon glyphicon-remove"></span> </p>
</div>
</div>
<md-input-container style="display: block; float: left; width: 100%;">
<md-select class="lead-search" ng-model="managersSelectedList" id="selectManager" data-md-container-class="selectdemoSelectHeader" multiple="" md-selected-text="getSelectedLead()">
<md-select-header class="demo-select-header">
<input ng-model="searchTerm" type="search" id="search" style = "width:100%" placeholder="Search for a manager" ng-keydown="updateSearch($event)" ng-model-options="{debounce: {'default': 500, 'blur': 0}}" class="demo-header-searchbox md-text" />
<div style="display: block; float: left; width: 100%;">
<md-select ng-model="managersSelectedList" data-md-container-class="selectHeader" id="selectManager" multiple="" md-selected-text="getSelectedLead()">
<md-select-header class="selectHeaderChild header-spacing" layout="column">
<input ng-model="searchTerm" type="search" id="search" ng-keydown="updateSearch($event)" ng-model-options="{debounce: {'default': 500, 'blur': 0}}" placeholder="Please Search for a manager" class="searchBoxHeader demo-header-searchbox md-text search-spacingleft" />
<span class="glyphicon glyphicon-remove close-mdselect" ng-click="closeSelectBox()"></span>
</md-select-header>
<md-optgroup label="managers">
<md-optgroup label="managers" class="optionScroll">
<md-option ng-value="manager" ng-repeat="manager in managerDetails | filter:searchFilter">{{manager.employeeName}}</md-option>
</md-optgroup>
</md-select>
</md-input-container>
</div>
</td>
</tr>
</table>
......
......@@ -70,9 +70,14 @@
</p>
</div>
</div>
<md-select ng-model="employeeModel " md-selected-text="getEmployeeSelected() " id="selectEmp" name="employeeModel">
<md-optgroup label="Employee ">
<md-option ng-value="employee " ng-repeat="employee in employeeList ">{{employee.employeeName}}</md-option>
<md-select ng-model="employeeModel " data-md-container-class="selectHeader" md-selected-text="getEmployeeSelected() " id="selectEmp" name="employeeModel">
<md-select-header class="selectHeaderChild header-spacing" layout="column">
<input ng-model="searchTerm" type="search" id="search" ng-keydown="updateSearch($event)" ng-model-options="{debounce: {'default': 500, 'blur': 0}}"
placeholder="Please search for a employee" class="searchBoxHeader demo-header-searchbox md-text search-spacingleft" />
<span class="glyphicon glyphicon-remove close-mdselect" ng-click="closeSelectBox()"></span>
</md-select-header>
<md-optgroup label="Employee " class="optionScroll">
<md-option ng-value="employee " ng-repeat="employee in employeeList | filter:searchFilter">{{employee.employeeName}}</md-option>
</md-optgroup>
</md-select>
<output>Employee Name : {{employeeModel.employeeName}}</output>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment