Commit ed6c89ca authored by mduppanapudi-nisum-com's avatar mduppanapudi-nisum-com Committed by rbonthala-nisum-com

bug fix in manage Employee (#110)

parent 9ec32ced
...@@ -331,6 +331,11 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -331,6 +331,11 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
} }
$scope.validateFields = function(){ $scope.validateFields = function(){
var today = new Date();
if($scope.templateTitle == "Add"){
$scope.empStatus ="Active";
}
var searchId = $scope.empId; var searchId = $scope.empId;
var empName = $scope.empName; var empName = $scope.empName;
var gender = $scope.gender; var gender = $scope.gender;
...@@ -389,63 +394,95 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -389,63 +394,95 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
}else if(hasB1 == undefined){ }else if(hasB1 == undefined){
$scope.alertMsg = "Please select a Visa"; $scope.alertMsg = "Please select a Visa";
document.getElementById('hasB1').focus(); document.getElementById('hasB1').focus();
}
else if($scope.templateTitle != "Add" && $scope.exitDate == undefined && $scope.empStatus != "Active"){
$scope.alertMsg = "Please select the exit date";
document.getElementById('hasB1').focus();
}
else if($scope.templateTitle != "Add" && $scope.exitDate >= today){
$scope.alertMsg = "Please select the exit date less than or equal to current date";
document.getElementById('hasB1').focus();
}else{ }else{
$scope.alertMsg = ""; $scope.alertMsg = "";
console.log($scope.empName,"VENU");
var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "gender": $scope.gender,"emailId": $scope.empEmail, var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "gender": $scope.gender,"emailId": $scope.empEmail,
"role": $scope.empRole, "empLocation": $scope.empLocation,"designation": $scope.designation,"functionalGroup": $scope.functionalGroup, "role": $scope.empRole, "empLocation": $scope.empLocation,"designation": $scope.designation,"functionalGroup": $scope.functionalGroup,
"empStatus": $scope.empStatus,"employmentType": $scope.employmentType,"domain": $scope.domain,"dateOfJoining":$scope.dateOfJoining, "empStatus": $scope.empStatus,"employmentType": $scope.employmentType,"domain": $scope.domain,"dateOfJoining":$scope.dateOfJoining,
"dateOfBirth":$scope.dateOfBirth,"hasPassort":$scope.hasPassort,"hasB1":$scope.hasB1,"passportExpiryDate":$scope.passportExpiryDate, "dateOfBirth":$scope.dateOfBirth,"hasPassort":$scope.hasPassort,"hasB1":$scope.hasB1,"passportExpiryDate":$scope.passportExpiryDate,
"b1ExpiryDate":$scope.b1ExpiryDate "b1ExpiryDate":$scope.b1ExpiryDate, "endDate":$scope.exitDate
}; };
if($scope.templateTitle == "Add"){
addOrUpdateRole(record, $scope.templateTitle);
$timeout(function(){updateGrid($scope.templateTitle, record)},500);
}
else{
if(isDataUpdated() == true){
addOrUpdateRole(record, $scope.templateTitle);
$timeout(function(){updateGrid($scope.templateTitle, record)},500);
}
else{
$mdDialog.show($mdDialog.alert({
skipHide: true,
title:'Attention',
textContent: 'There is no data change to Update',
ok: 'ok'
}))
}
}
addOrUpdateRole(record, $scope.templateTitle);
$timeout(function(){updateGrid($scope.templateTitle, record)},500);
} }
}; };
$scope.cancel = function() { isDataUpdated = function(){
var showConfirmDialog = false;
if(dataToPass.action=="Update"){ if(dataToPass.action=="Update"){
console.log(dataToPass); console.log(dataToPass);
$scope.previousData={ $scope.previousData={
EmpId:dataToPass.employeeId, EmpId:dataToPass.employeeId,
EmpName:dataToPass.employeeName, EmpName:dataToPass.employeeName,
Gender:dataToPass.gender, Gender:dataToPass.gender,
Email:dataToPass.emailId, Email:dataToPass.emailId,
EmploymentStatus:dataToPass.empStatus, EmploymentStatus:dataToPass.empStatus,
Role:dataToPass.role, Role:dataToPass.role,
Designation:dataToPass.designation, Designation:dataToPass.designation,
WorkLocation:dataToPass.empLocation, WorkLocation:dataToPass.empLocation,
EmploymentType:dataToPass.employmentType, EmploymentType:dataToPass.employmentType,
FunctionalGroup:dataToPass.functionalGroup, FunctionalGroup:dataToPass.functionalGroup,
HasPassport:dataToPass.hasPassort, HasPassport:dataToPass.hasPassort,
HasB1Visa:dataToPass.hasB1, HasB1Visa:dataToPass.hasB1,
Dateofjoining: new Date(dataToPass.dateOfJoining), Dateofjoining: new Date(dataToPass.dateOfJoining),
//DateofBirth:dataToPass.dateOfBirth ? new Date(dataToPass.dateOfBirth) : '' //DateofBirth:dataToPass.dateOfBirth ? new Date(dataToPass.dateOfBirth) : ''
DateofBirth: new Date(dataToPass.dateOfBirth) DateofBirth: new Date(dataToPass.dateOfBirth)
} }
$scope.currentData={ $scope.currentData={
EmpId: $scope.empId, EmpId: $scope.empId,
EmpName:$scope.empName, EmpName:$scope.empName,
Gender:$scope.gender, Gender:$scope.gender,
Email:$scope.empEmail, Email:$scope.empEmail,
EmploymentStatus:$scope.empStatus, EmploymentStatus:$scope.empStatus,
Role:$scope.empRole, Role:$scope.empRole,
Designation:$scope.designation, Designation:$scope.designation,
WorkLocation:$scope.empLocation, WorkLocation:$scope.empLocation,
EmploymentType:$scope.employmentType, EmploymentType:$scope.employmentType,
FunctionalGroup:$scope.functionalGroup, FunctionalGroup:$scope.functionalGroup,
HasPassport:$scope.hasPassort, HasPassport:$scope.hasPassort,
HasB1Visa:$scope.hasB1, HasB1Visa:$scope.hasB1,
Dateofjoining:$scope.dateOfJoining, Dateofjoining:$scope.dateOfJoining,
DateofBirth:$scope.dateOfBirth DateofBirth:$scope.dateOfBirth
} }
var predata=JSON.stringify($scope.previousData); var predata=JSON.stringify($scope.previousData);
var curdata=JSON.stringify($scope.currentData); var curdata=JSON.stringify($scope.currentData);
if(predata === curdata){ if(predata == curdata){
return false;
}
return true;
}
}
$scope.cancel = function() {
var showConfirmDialog = false;
if(dataToPass.action=="Update"){
if(isDataUpdated() != true){
$mdDialog.hide('Cancelled'); $mdDialog.hide('Cancelled');
} }
else{ else{
......
...@@ -64,17 +64,24 @@ ...@@ -64,17 +64,24 @@
</td> </td>
</tr> </tr>
<tr> <tr ng-show="templateTitle != 'Add'">
<td colspan="4"><b>Employment Status:</b><span class="mandatory"></span></td> <td colspan="4"><b>Employment Status {{templateTitle}}:</b><span class="mandatory"></span></td>
<td colspan="8"><md-select ng-model="empStatus" <td colspan="8"><md-select ng-model="empStatus"
md-selected-text="getSelectedEmpStatus()" id="empStatus"> md-selected-text="getSelectedEmpStatus()" id="empStatus">
<md-optgroup label="Employment Status"> <md-option <md-optgroup label="Employment Status"> <md-option
ng-value="status" ng-repeat="status in empStatuses">{{status}}</md-option> ng-value="status" ng-repeat="status in empStatuses">{{status}}</md-option>
</md-optgroup> </md-select></td> </md-optgroup> </md-select></td>
</tr> </tr>
<tr ng-show="empStatus == 'In Active'">
<td colspan="4"><b>Employment Status:</b><span class="mandatory"></span></td>
<td colspan="8"><md-datepicker ng-model="exitDate"
md-placeholder="Exit Date" md-min-date="minDate"
md-max-date="maxDate" onkeydown="return false"></md-datepicker>
</td>
</tr>
<tr> <tr>
<td colspan="4"> <td colspan="12">
<div role="alert"> <div role="alert">
<span class="error" style="color: red;">{{alertMsg}}</span> <span class="error" style="color: red;">{{alertMsg}}</span>
</div> </div>
......
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