Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mytime
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Narendar Vakiti
mytime
Commits
5d6cd3ed
Unverified
Commit
5d6cd3ed
authored
Aug 17, 2018
by
mshaik-nisum-com
Committed by
GitHub
Aug 17, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #158 from nisum-inc/FEATURE/REFACTOR_AND_BUG_FIX
refactored the manage employee and few bug fixes
parents
73b00024
75fff52c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
88 deletions
+81
-88
AssignRolesController.js
src/main/webapp/WEB-INF/controllers/AssignRolesController.js
+70
-85
ProjectController.js
src/main/webapp/WEB-INF/controllers/ProjectController.js
+1
-1
app.js
src/main/webapp/WEB-INF/js/app.js
+10
-2
No files found.
src/main/webapp/WEB-INF/controllers/AssignRolesController.js
View file @
5d6cd3ed
...
@@ -11,7 +11,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
...
@@ -11,7 +11,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
"passportExpiryDate"
:
""
"passportExpiryDate"
:
""
};
};
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;" ng-click="grid.appScope.getRowData(row,
\'
Update
\'
)"></i>'
+
var
getCellTemplate
=
'<p
ng-show="row.entity.empStatus ==
\'
Active
\'
"
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;" ng-click="grid.appScope.getRowData(row,
\'
Update
\'
)"></i>'
+
' '
;
' '
;
// <i class="fa fa-minus-circle fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'Delete\')"></i></p>
// <i class="fa fa-minus-circle fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'Delete\')"></i></p>
$scope
.
gridOptions
=
{
$scope
.
gridOptions
=
{
...
@@ -30,6 +30,8 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
...
@@ -30,6 +30,8 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
{
name
:
'Actions'
,
displayName
:
'Actions'
,
cellTemplate
:
getCellTemplate
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
100
,
cellClass
:
'grid-align'
}
{
name
:
'Actions'
,
displayName
:
'Actions'
,
cellTemplate
:
getCellTemplate
,
enableColumnMenu
:
false
,
enableSorting
:
false
,
enableFiltering
:
false
,
width
:
100
,
cellClass
:
'grid-align'
}
]
]
};
};
$scope
.
gridOptions
.
data
=
$scope
.
records
;
$scope
.
gridOptions
.
data
=
$scope
.
records
;
$scope
.
gridOptionsOrgView
=
{
$scope
.
gridOptionsOrgView
=
{
paginationPageSizes
:
[
10
,
20
,
30
,
40
,
50
,
100
],
paginationPageSizes
:
[
10
,
20
,
30
,
40
,
50
,
100
],
...
@@ -108,6 +110,12 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
...
@@ -108,6 +110,12 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
else
{
else
{
$scope
.
gridOptions
.
enablePaginationControls
=
false
;
$scope
.
gridOptions
.
enablePaginationControls
=
false
;
}
}
if
(
$scope
.
status
==
"In Active"
){
$scope
.
gridOptions
.
columnDefs
[
6
].
visible
=
false
;
}
else
{
$scope
.
gridOptions
.
columnDefs
[
6
].
visible
=
true
;
}
$scope
.
gridOptions
.
data
=
response
.
data
;
$scope
.
gridOptions
.
data
=
response
.
data
;
},
function
myError
(
response
)
{
},
function
myError
(
response
)
{
showAlert
(
"Something went wrong while fetching data!!!"
);
showAlert
(
"Something went wrong while fetching data!!!"
);
...
@@ -490,7 +498,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
...
@@ -490,7 +498,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope
.
alertMsg
=
""
;
$scope
.
alertMsg
=
""
;
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
,
"d
omain"
:
$scope
.
domain
,
"d
ateOfJoining"
:
$scope
.
dateOfJoining
,
"empStatus"
:
$scope
.
empStatus
,
"employmentType"
:
$scope
.
employmentType
,
"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
,
"endDate"
:
$scope
.
exitDate
"b1ExpiryDate"
:
$scope
.
b1ExpiryDate
,
"endDate"
:
$scope
.
exitDate
};
};
...
@@ -499,12 +507,15 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
...
@@ -499,12 +507,15 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$timeout
(
function
(){
updateGrid
(
$scope
.
templateTitle
,
record
)},
500
);
$timeout
(
function
(){
updateGrid
(
$scope
.
templateTitle
,
record
)},
500
);
}
}
else
{
else
{
var
dbRecord
=
{
"employeeId"
:
dataToPass
.
employeeId
,
"employeeName"
:
dataToPass
.
employeeName
,
"gender"
:
dataToPass
.
gender
,
"emailId"
:
dataToPass
.
emailId
,
var
recordFromDb
=
{
"employeeId"
:
dataToPass
.
employeeId
,
"employeeName"
:
dataToPass
.
employeeName
,
"gender"
:
dataToPass
.
gender
,
"emailId"
:
dataToPass
.
emailId
,
"role"
:
dataToPass
.
role
,
"empLocation"
:
dataToPass
.
empLocation
,
"designation"
:
dataToPass
.
designation
,
"functionalGroup"
:
dataToPass
.
functionalGroup
,
"role"
:
dataToPass
.
role
,
"empLocation"
:
dataToPass
.
empLocation
,
"designation"
:
dataToPass
.
designation
,
"functionalGroup"
:
dataToPass
.
functionalGroup
,
"empStatus"
:
dataToPass
.
empStatus
,
"employmentType"
:
dataToPass
.
employmentType
,
"dateOfJoining"
:
new
Date
(
dataToPass
.
dateOfJoining
),
"empStatus"
:
dataToPass
.
empStatus
,
"employmentType"
:
dataToPass
.
employmentType
,
"dateOfJoining"
:
new
Date
(
dataToPass
.
dateOfJoining
),
"dateOfBirth"
:
new
Date
(
dataToPass
.
dateOfBirth
),
"hasPassort"
:
dataToPass
.
hasPassort
,
"hasB1"
:
dataToPass
.
hasB1
"dateOfBirth"
:
new
Date
(
dataToPass
.
dateOfBirth
),
"hasPassort"
:
dataToPass
.
hasPassort
,
"hasB1"
:
dataToPass
.
hasB1
,
"passportExpiryDate"
:
new
Date
(
dataToPass
.
passportExpiryDate
),
"b1ExpiryDate"
:
new
Date
(
dataToPass
.
b1ExpiryDate
),
"endDate"
:
new
Date
(
dataToPass
.
endDate
)
};
};
if
(
myFactory
.
updateFormDataCheck
(
$scope
.
myForm
,
dbRecord
)){
objectConstructionBasedOnParameters
(
recordFromDb
);
objectConstructionBasedOnParameters
(
record
);
if
(
myFactory
.
updateFormDataCheck
(
record
,
recordFromDb
)){
addOrUpdateRole
(
record
,
$scope
.
templateTitle
);
addOrUpdateRole
(
record
,
$scope
.
templateTitle
);
$timeout
(
function
(){
updateGrid
(
$scope
.
templateTitle
,
record
)},
500
);
$timeout
(
function
(){
updateGrid
(
$scope
.
templateTitle
,
record
)},
500
);
}
}
...
@@ -522,96 +533,70 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
...
@@ -522,96 +533,70 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope
.
errorMessage
=
true
;
$scope
.
errorMessage
=
true
;
};
};
isDataUpdated
=
function
(){
objectConstructionBasedOnParameters
=
function
(
obj
){
if
(
dataToPass
.
action
==
"Update"
){
if
(
obj
.
hasB1
!=
"Yes"
){
console
.
log
(
dataToPass
);
delete
obj
[
'b1ExpiryDate'
];
$scope
.
previousData
=
{
}
EmpId
:
dataToPass
.
employeeId
,
EmpName
:
dataToPass
.
employeeName
,
if
(
obj
.
hasPassort
!=
"Yes"
){
Gender
:
dataToPass
.
gender
,
delete
obj
[
'passportExpiryDate'
];
Email
:
dataToPass
.
emailId
,
}
EmploymentStatus
:
dataToPass
.
empStatus
,
if
(
obj
.
empStatus
==
"Active"
){
Role
:
dataToPass
.
role
,
delete
obj
[
'endDate'
];
Designation
:
dataToPass
.
designation
,
WorkLocation
:
dataToPass
.
empLocation
,
EmploymentType
:
dataToPass
.
employmentType
,
FunctionalGroup
:
dataToPass
.
functionalGroup
,
HasPassport
:
dataToPass
.
hasPassort
,
HasB1Visa
:
dataToPass
.
hasB1
,
Dateofjoining
:
(
dataToPass
.
dateOfJoining
==
null
)
?
null
:
new
Date
(
dataToPass
.
dateOfJoining
),
DateofBirth
:
(
dataToPass
.
dateOfBirth
==
null
)
?
null
:
new
Date
(
dataToPass
.
dateOfBirth
),
passportExpiryDate
:
(
dataToPass
.
passportExpiryDate
==
null
)?
null
:
new
Date
(
dataToPass
.
passportExpiryDate
)
,
b1ExpiryDate
:
(
dataToPass
.
b1ExpiryDate
==
null
)?
null
:
new
Date
(
dataToPass
.
b1ExpiryDate
)
}
$scope
.
currentData
=
{
EmpId
:
$scope
.
empId
,
EmpName
:
$scope
.
empName
,
Gender
:
$scope
.
gender
,
Email
:
$scope
.
empEmail
,
EmploymentStatus
:
$scope
.
empStatus
,
Role
:
$scope
.
empRole
,
Designation
:
$scope
.
designation
,
WorkLocation
:
$scope
.
empLocation
,
EmploymentType
:
$scope
.
employmentType
,
FunctionalGroup
:
$scope
.
functionalGroup
,
HasPassport
:
$scope
.
hasPassort
,
HasB1Visa
:
$scope
.
hasB1
,
Dateofjoining
:
$scope
.
dateOfJoining
,
DateofBirth
:
$scope
.
dateOfBirth
,
passportExpiryDate
:
$scope
.
passportExpiryDate
,
b1ExpiryDate
:
$scope
.
b1ExpiryDate
,
}
var
predata
=
JSON
.
stringify
(
$scope
.
previousData
);
var
curdata
=
JSON
.
stringify
(
$scope
.
currentData
);
if
(
predata
==
curdata
){
return
false
;
}
}
return
true
;
return
obj
;
}
}
}
var
confirmationMsg
=
function
(){
$mdDialog
.
show
(
$mdDialog
.
confirm
({
skipHide
:
true
,
textContent
:
'Are you sure you want to cancel this?'
,
ok
:
'ok'
,
cancel
:
'cancel'
})).
then
(
function
()
{
$mdDialog
.
hide
(
'Cancelled'
);
})
}
$scope
.
cancel
=
function
()
{
$scope
.
cancel
=
function
()
{
var
showConfirmDialog
=
false
;
var
record
=
{
if
(
dataToPass
.
action
==
"Update"
){
"employeeId"
:
$scope
.
empId
,
"employeeName"
:
$scope
.
empName
,
"gender"
:
$scope
.
gender
,
"emailId"
:
$scope
.
empEmail
,
if
(
isDataUpdated
()
!=
true
){
"role"
:
$scope
.
empRole
,
"empLocation"
:
$scope
.
empLocation
,
"designation"
:
$scope
.
designation
,
"functionalGroup"
:
$scope
.
functionalGroup
,
$mdDialog
.
hide
(
'Cancelled'
);
"empStatus"
:
$scope
.
empStatus
,
"employmentType"
:
$scope
.
employmentType
,
"dateOfJoining"
:
$scope
.
dateOfJoining
,
}
"dateOfBirth"
:
$scope
.
dateOfBirth
,
"hasPassort"
:
$scope
.
hasPassort
,
"hasB1"
:
$scope
.
hasB1
,
"passportExpiryDate"
:
$scope
.
passportExpiryDate
,
else
{
"b1ExpiryDate"
:
$scope
.
b1ExpiryDate
,
"endDate"
:
$scope
.
exitDate
$mdDialog
.
show
(
$mdDialog
.
confirm
({
};
skipHide
:
true
,
var
recordFromDb
=
{
textContent
:
'Are you sure you want to cancel this?'
,
"employeeId"
:
dataToPass
.
employeeId
,
"employeeName"
:
dataToPass
.
employeeName
,
"gender"
:
dataToPass
.
gender
,
"emailId"
:
dataToPass
.
emailId
,
ok
:
'ok'
,
"role"
:
dataToPass
.
role
,
"empLocation"
:
dataToPass
.
empLocation
,
"designation"
:
dataToPass
.
designation
,
"functionalGroup"
:
dataToPass
.
functionalGroup
,
cancel
:
'cancel'
"empStatus"
:
dataToPass
.
empStatus
,
"employmentType"
:
dataToPass
.
employmentType
,
"dateOfJoining"
:
new
Date
(
dataToPass
.
dateOfJoining
),
})).
then
(
function
(){
"dateOfBirth"
:
new
Date
(
dataToPass
.
dateOfBirth
),
"hasPassort"
:
dataToPass
.
hasPassort
,
"hasB1"
:
dataToPass
.
hasB1
,
"passportExpiryDate"
:
new
Date
(
dataToPass
.
passportExpiryDate
),
$mdDialog
.
hide
(
'Cancelled'
);
"b1ExpiryDate"
:
new
Date
(
dataToPass
.
b1ExpiryDate
),
"endDate"
:
new
Date
(
dataToPass
.
endDate
)
})
};
}
objectConstructionBasedOnParameters
(
recordFromDb
);
}
objectConstructionBasedOnParameters
(
record
);
if
(
dataToPass
.
action
==
"Add"
){
if
(
dataToPass
.
action
==
"Add"
){
var
totalFields
=
$scope
.
myForm
.
$$controls
;
var
employeeForm
=
myFactory
.
addFormDataCheck
(
$scope
.
myForm
)
;
for
(
key
in
totalFields
)
{
if
(
Object
.
keys
(
employeeForm
).
length
==
0
)
{
console
.
log
(
"Model value of"
+
key
+
" ==>"
+
totalFields
[
key
].
$modelValue
)
$mdDialog
.
hide
(
'Cancelled'
);
if
(
totalFields
[
key
].
$modelValue
!==
''
&&
totalFields
[
key
].
$modelValue
!==
undefined
)
{
}
console
.
log
(
"Came here!"
);
else
{
showConfirmDialog
=
true
;
confirmationMsg
()
;
}
}
}
}
if
(
showConfirmDialog
){
else
if
(
dataToPass
.
action
==
"Update"
){
$mdDialog
.
show
(
$mdDialog
.
confirm
({
if
(
myFactory
.
updateFormDataCheck
(
record
,
recordFromDb
)
!=
true
){
skipHide
:
true
,
$mdDialog
.
hide
(
'Cancelled'
);
textContent
:
'Are you sure you want to cancel this?'
,
ok
:
'ok'
,
cancel
:
'cancel'
})).
then
(
function
(){
$mdDialog
.
hide
(
'Cancelled'
);
})
}
}
else
{
else
{
$mdDialog
.
hide
(
'Cancelled'
);
confirmationMsg
();
}
}
}
}
};
};
function
updateGrid
(
action
,
record
){
function
updateGrid
(
action
,
record
){
if
(
$scope
.
alertMsg
==
""
){
if
(
$scope
.
alertMsg
==
""
){
if
(
$scope
.
result
==
"Success"
){
if
(
$scope
.
result
==
"Success"
){
...
...
src/main/webapp/WEB-INF/controllers/ProjectController.js
View file @
5d6cd3ed
...
@@ -34,7 +34,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
...
@@ -34,7 +34,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
var
getCellTemplate
=
'<p class="col-lg-12"><i class="fa fa-users fa-2x" aria-hidden="true" style="font-size:1.4em;margin-top:3px;cursor:pointer;" data-placement="center" title="View" onmouseenter="$(this).tooltip(
\'
show
\'
)" ng-click="grid.appScope.getRowData(row,
\'
View
\'
)" ></i>'
+
var
getCellTemplate
=
'<p class="col-lg-12"><i class="fa fa-users fa-2x" aria-hidden="true" style="font-size:1.4em;margin-top:3px;cursor:pointer;" data-placement="center" title="View" onmouseenter="$(this).tooltip(
\'
show
\'
)" ng-click="grid.appScope.getRowData(row,
\'
View
\'
)" ></i>'
+
' <i ng-show="row.entity.projectName !=
\'
Bench
\'
" 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></p>'
;
' <i ng-show="row.entity.projectName
==
\'
Bench
\'
"> </i><i ng-show="row.entity.projectName
!=
\'
Bench
\'
" 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></p>'
;
// ' <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>'
// ' <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>'
...
...
src/main/webapp/WEB-INF/js/app.js
View file @
5d6cd3ed
...
@@ -209,8 +209,16 @@ myApp.factory('myFactory', function() {
...
@@ -209,8 +209,16 @@ myApp.factory('myFactory', function() {
}
}
function
updateFormDataCheck
(
form
,
record
){
function
updateFormDataCheck
(
form
,
record
){
var
updatedForm
=
addFormDataCheck
(
form
);
var
updatedForm
;
var
sortedUpdatedForm
=
sortObjectBasedOnKeys
(
updatedForm
);
var
sortedUpdatedForm
;
if
(
Array
.
isArray
(
form
.
$$controls
)){
updatedForm
=
addFormDataCheck
(
form
);
sortedUpdatedForm
=
sortObjectBasedOnKeys
(
updatedForm
);
}
else
{
sortedUpdatedForm
=
sortObjectBasedOnKeys
(
form
);
}
var
sortedRecord
=
sortObjectBasedOnKeys
(
record
);
var
sortedRecord
=
sortObjectBasedOnKeys
(
record
);
if
(
JSON
.
stringify
(
sortedUpdatedForm
)
==
JSON
.
stringify
(
sortedRecord
)){
if
(
JSON
.
stringify
(
sortedUpdatedForm
)
==
JSON
.
stringify
(
sortedRecord
)){
return
false
;
return
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment