Commit 64b7b7d9 authored by Prayas Jain's avatar Prayas Jain

Added edit and save icon in open pool screen

parent 47f8b553
myApp.controller("openPoolController", function($scope, $http, myFactory, $mdDialog, appConfig, exportUiGridService) { myApp.controller("openPoolController", function($scope, $http, myFactory, $mdDialog, appConfig, exportUiGridService) {
$scope.records = []; $scope.records = [];
var today = new Date(); var today = new Date();
var getCellTemplate = '<p class="col-lg-12"><i ng-show="!row.entity.editrow" class="fa fa-pencil-square-o fa-2x" data-placement="center" title="Edit" onmouseenter="$(this).tooltip(\'show\')" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.onEdit(row)"></i>'+
'<i ng-show="row.entity.editrow" class="fa fa-save fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" data-placement="center" title="Save" onmouseenter="$(this).tooltip(\'show\')" ng-click="grid.appScope.saveRow(row.entity,\'Update\')"></i>'
+'&nbsp;&nbsp;&nbsp;<i ng-show="row.entity.editrow" id="cancelEdit" class="fa fa-times fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" data-placement="center" title="Cancel" onmouseenter="$(this).tooltip(\'show\')" ng-click="grid.appScope.cancelEdit(row.entity)"></i></p>';
$scope.gridOptions = { $scope.gridOptions = {
paginationPageSizes : [ 10, 20, 30, 40, 50, 100], paginationPageSizes : [ 10, 20, 30, 40, 50, 100],
paginationPageSize : 10, paginationPageSize : 10,
...@@ -12,8 +16,15 @@ myApp.controller("openPoolController", function($scope, $http, myFactory, $mdDia ...@@ -12,8 +16,15 @@ myApp.controller("openPoolController", function($scope, $http, myFactory, $mdDia
{field : 'employeeName',displayName: 'Employee Name', enableColumnMenu: false, enableSorting: false, enableFiltering: true,width:'*'}, {field : 'employeeName',displayName: 'Employee Name', enableColumnMenu: false, enableSorting: false, enableFiltering: true,width:'*'},
{field : 'resourceRole',displayName: 'Role', enableColumnMenu: false, enableSorting: false,enableFiltering: true,width:'*'}, {field : 'resourceRole',displayName: 'Role', enableColumnMenu: false, enableSorting: false,enableFiltering: true,width:'*'},
{field : 'designation',displayName: 'Designation', enableColumnMenu: false,enableFiltering: false,width:'*'}, {field : 'designation',displayName: 'Designation', enableColumnMenu: false,enableFiltering: false,width:'*'},
{field : 'billableStatus',displayName: 'Billability', enableColumnMenu: false,enableSorting: false,enableFiltering: true , cellFilter: 'date:"dd-MMM-yyyy"',width:'*'}, {field : 'billableStatus',displayName: 'Billability', enableColumnMenu: false,enableSorting: false,enableFiltering: true ,width:'*', cellTemplate: '<div class="ui-grid-cell-contents" ng-if="!row.entity.editrow">{{COL_FIELD}}</div><div ng-if="row.entity.editrow" class="grid-Dropdown"><md-select ng-model="MODEL_COL_FIELD" name="empBillableStatus" append-to-body="true">'
{field : 'billingStartDate',displayName: 'Start Date', enableColumnMenu: false, enableSorting: false, enableFiltering: true,width:'*',cellFilter: 'date:"dd-MMM-yyyy"'} + '<md-optgroup label="billable statuses "><md-option ng-value="billableStatus " ng-repeat="billableStatus in col.colDef.editDropdownOptionsArray">{{billableStatus}}</md-option>'
+'</md-optgroup></md-select></div>',editDropdownOptionsArray: [
'Trainee' ,
'Non-Billable'
]
},
{field : 'billingStartDate',displayName: 'Start Date', enableColumnMenu: false, enableSorting: false, enableFiltering: true,width:'*',cellFilter: 'date:"dd-MMM-yyyy"'},
{ name: 'Actions', displayName: 'Actions', cellTemplate: getCellTemplate, enableColumnMenu: false, enableSorting: false, enableFiltering: false, width:'*' }
], ],
enableGridMenu: true, enableGridMenu: true,
enableSelectAll: true, enableSelectAll: true,
...@@ -97,4 +108,87 @@ myApp.controller("openPoolController", function($scope, $http, myFactory, $mdDia ...@@ -97,4 +108,87 @@ myApp.controller("openPoolController", function($scope, $http, myFactory, $mdDia
function ProgressController($scope, dataToPass) { function ProgressController($scope, dataToPass) {
$scope.progressText = dataToPass; $scope.progressText = dataToPass;
} }
$scope.parentData = {
"id":"",
"employeeId": "",
"employeeName": "",
"role": "",
"designation":"",
"billableStatus":"",
"billingStartDate":""
};
$scope.onEdit = function (rowd) {
var row = rowd.entity;
var index = $scope.gridOptions.data.indexOf(row);
if($scope.previousRow){
$scope.rowCompare(rowd);
}
$scope.previousRow = angular.copy(row);
$scope.previousRowIndex = index;
$scope.gridOptions.enableCellEdit = true;
for(var i =0; i<$scope.gridOptions.data.length; i++){
if(i==index){
$scope.gridOptions.data[i].editrow = !$scope.gridOptions.data[i].editrow;
}
else{
$scope.gridOptions.data[i].editrow = false;
}
}
$scope.parentData.employeeId = row.employeeId;
$scope.parentData.employeeName = row.employeeName;
$scope.parentData.id = row.id;
$scope.parentData.role = row.resourceRole;
$scope.parentData.designation = row.designation;
$scope.parentData.billableStatus = row.billableStatus;
$scope.parentData.billingStartDate = new Date(row.billingStartDate);
};
$scope.rowCompare = function(row) {
var allRows = row.grid.rows;
for(var i=0; i<allRows.length; i++) {
var newIndex = $scope.gridOptions.data.indexOf(allRows[i].entity)
if(newIndex == $scope.previousRowIndex){
allRows[i].entity.billableStatus = $scope.previousRow.billableStatus;
allRows[i].entity.billingStartDate = $scope.previousRow.billingStartDate;
allRows[i].entity.billingEndDate = $scope.previousRow.billingEndDate;
$scope.previousRow = angular.copy(row.entity);
}
}
}
$scope.cancelEdit = function (row) {
var index = $scope.gridOptions.data.indexOf(row);
$scope.gridOptions.data[index].editrow = false;
row.billableStatus = $scope.parentData.billableStatus;
};
// $scope.saveRow = function (row,action) {
// var index = $scope.gridOptions.data.indexOf(row);
// $scope.gridOptions.data[index].editrow = false;
// $scope.employeeModel = {
// 'employeeName': row.employeeName,
// 'employeeId': row.employeeId,
// 'designation': row.designation
// };
// $scope.newBillingStartDate = row.billingStartDate;
// $scope.endDate = row.billingEndDate;
// $scope.employeeRole = row.resourceRole;
// $scope.empBillableStatus = row.billableStatus;
// $scope.empAllocationStatus = row.status;
// $scope.aliasResourceName = row.onBehalfOf;
// $scope.id = row.id;
// if(action == 'Update'){
// $scope.validateFields(action,row);
// if($scope.alertMsg != ""){
// row.billingStartDate = $scope.parentData.newBillingStartDate;
// row.billingEndDate = $scope.parentData.endDate;
// row.resourceRole = $scope.parentData.role;
// row.billableStatus = $scope.parentData.billableStatus;
// }
// $scope.previousRow = angular.copy(row);
// }
// }
}); });
\ No newline at end of file
...@@ -815,8 +815,6 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor ...@@ -815,8 +815,6 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
$scope.previousRow = angular.copy(row.entity); $scope.previousRow = angular.copy(row.entity);
} }
} }
} }
$scope.moveToBench = function (row) { $scope.moveToBench = function (row) {
......
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