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
75fff52c
Commit
75fff52c
authored
Aug 17, 2018
by
Manikanta SKPB Duppanapudi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored the manage employee and few bug fixes
parent
73b00024
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 @
75fff52c
...
...
@@ -11,7 +11,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
"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>
$scope
.
gridOptions
=
{
...
...
@@ -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'
}
]
};
$scope
.
gridOptions
.
data
=
$scope
.
records
;
$scope
.
gridOptionsOrgView
=
{
paginationPageSizes
:
[
10
,
20
,
30
,
40
,
50
,
100
],
...
...
@@ -108,6 +110,12 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
else
{
$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
;
},
function
myError
(
response
)
{
showAlert
(
"Something went wrong while fetching data!!!"
);
...
...
@@ -490,7 +498,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope
.
alertMsg
=
""
;
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
,
"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
,
"b1ExpiryDate"
:
$scope
.
b1ExpiryDate
,
"endDate"
:
$scope
.
exitDate
};
...
...
@@ -499,12 +507,15 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$timeout
(
function
(){
updateGrid
(
$scope
.
templateTitle
,
record
)},
500
);
}
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
,
"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
);
$timeout
(
function
(){
updateGrid
(
$scope
.
templateTitle
,
record
)},
500
);
}
...
...
@@ -522,96 +533,70 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope
.
errorMessage
=
true
;
};
isDataUpdated
=
function
(){
if
(
dataToPass
.
action
==
"Update"
){
console
.
log
(
dataToPass
);
$scope
.
previousData
=
{
EmpId
:
dataToPass
.
employeeId
,
EmpName
:
dataToPass
.
employeeName
,
Gender
:
dataToPass
.
gender
,
Email
:
dataToPass
.
emailId
,
EmploymentStatus
:
dataToPass
.
empStatus
,
Role
:
dataToPass
.
role
,
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
;
objectConstructionBasedOnParameters
=
function
(
obj
){
if
(
obj
.
hasB1
!=
"Yes"
){
delete
obj
[
'b1ExpiryDate'
];
}
if
(
obj
.
hasPassort
!=
"Yes"
){
delete
obj
[
'passportExpiryDate'
];
}
if
(
obj
.
empStatus
==
"Active"
){
delete
obj
[
'endDate'
];
}
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
()
{
var
showConfirmDialog
=
false
;
if
(
dataToPass
.
action
==
"Update"
){
if
(
isDataUpdated
()
!=
true
){
$mdDialog
.
hide
(
'Cancelled'
);
}
else
{
$mdDialog
.
show
(
$mdDialog
.
confirm
({
skipHide
:
true
,
textContent
:
'Are you sure you want to cancel this?'
,
ok
:
'ok'
,
cancel
:
'cancel'
})).
then
(
function
(){
$mdDialog
.
hide
(
'Cancelled'
);
})
}
}
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
,
"empStatus"
:
$scope
.
empStatus
,
"employmentType"
:
$scope
.
employmentType
,
"dateOfJoining"
:
$scope
.
dateOfJoining
,
"dateOfBirth"
:
$scope
.
dateOfBirth
,
"hasPassort"
:
$scope
.
hasPassort
,
"hasB1"
:
$scope
.
hasB1
,
"passportExpiryDate"
:
$scope
.
passportExpiryDate
,
"b1ExpiryDate"
:
$scope
.
b1ExpiryDate
,
"endDate"
:
$scope
.
exitDate
};
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
,
"empStatus"
:
dataToPass
.
empStatus
,
"employmentType"
:
dataToPass
.
employmentType
,
"dateOfJoining"
:
new
Date
(
dataToPass
.
dateOfJoining
),
"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
)
};
objectConstructionBasedOnParameters
(
recordFromDb
);
objectConstructionBasedOnParameters
(
record
);
if
(
dataToPass
.
action
==
"Add"
){
var
totalFields
=
$scope
.
myForm
.
$$controls
;
for
(
key
in
totalFields
)
{
console
.
log
(
"Model value of"
+
key
+
" ==>"
+
totalFields
[
key
].
$modelValue
)
if
(
totalFields
[
key
].
$modelValue
!==
''
&&
totalFields
[
key
].
$modelValue
!==
undefined
)
{
console
.
log
(
"Came here!"
);
showConfirmDialog
=
true
;
var
employeeForm
=
myFactory
.
addFormDataCheck
(
$scope
.
myForm
)
;
if
(
Object
.
keys
(
employeeForm
).
length
==
0
)
{
$mdDialog
.
hide
(
'Cancelled'
);
}
else
{
confirmationMsg
()
;
}
}
if
(
showConfirmDialog
){
$mdDialog
.
show
(
$mdDialog
.
confirm
({
skipHide
:
true
,
textContent
:
'Are you sure you want to cancel this?'
,
ok
:
'ok'
,
cancel
:
'cancel'
})).
then
(
function
(){
$mdDialog
.
hide
(
'Cancelled'
);
})
else
if
(
dataToPass
.
action
==
"Update"
){
if
(
myFactory
.
updateFormDataCheck
(
record
,
recordFromDb
)
!=
true
){
$mdDialog
.
hide
(
'Cancelled'
);
}
else
{
$mdDialog
.
hide
(
'Cancelled'
);
confirmationMsg
();
}
}
};
};
function
updateGrid
(
action
,
record
){
if
(
$scope
.
alertMsg
==
""
){
if
(
$scope
.
result
==
"Success"
){
...
...
src/main/webapp/WEB-INF/controllers/ProjectController.js
View file @
75fff52c
...
...
@@ -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>'
+
' <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>'
...
...
src/main/webapp/WEB-INF/js/app.js
View file @
75fff52c
...
...
@@ -209,8 +209,16 @@ myApp.factory('myFactory', function() {
}
function
updateFormDataCheck
(
form
,
record
){
var
updatedForm
=
addFormDataCheck
(
form
);
var
sortedUpdatedForm
=
sortObjectBasedOnKeys
(
updatedForm
);
var
updatedForm
;
var
sortedUpdatedForm
;
if
(
Array
.
isArray
(
form
.
$$controls
)){
updatedForm
=
addFormDataCheck
(
form
);
sortedUpdatedForm
=
sortObjectBasedOnKeys
(
updatedForm
);
}
else
{
sortedUpdatedForm
=
sortObjectBasedOnKeys
(
form
);
}
var
sortedRecord
=
sortObjectBasedOnKeys
(
record
);
if
(
JSON
.
stringify
(
sortedUpdatedForm
)
==
JSON
.
stringify
(
sortedRecord
)){
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