Commit 0ede9d1b authored by ssathu-nisum-com's avatar ssathu-nisum-com Committed by tdutta-nisum-com

MT-88:see_multiple_Managers_assigned_to_each_project_in_DataGrid (#31)

parent c68fbe25
package com.nisum.mytime.controller; package com.nisum.mytime.controller;
import java.util.HashMap;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -63,8 +64,8 @@ public class ProjectController { ...@@ -63,8 +64,8 @@ public class ProjectController {
} }
@RequestMapping(value = "/getProjects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getProjects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Project>> getProjects() throws MyTimeException { public ResponseEntity<List<HashMap<Object, Object>>> getProjects() throws MyTimeException {
List<Project> projects = projectService.getProjects(); List<HashMap<Object, Object>> projects = projectService.getProjects();
return new ResponseEntity<>(projects, HttpStatus.OK); return new ResponseEntity<>(projects, HttpStatus.OK);
} }
......
package com.nisum.mytime.service; package com.nisum.mytime.service;
import java.util.HashMap;
import java.util.List; import java.util.List;
import org.bson.types.ObjectId; import org.bson.types.ObjectId;
...@@ -17,7 +18,7 @@ public interface ProjectService { ...@@ -17,7 +18,7 @@ public interface ProjectService {
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate, List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException; String toDate) throws MyTimeException;
List<Project> getProjects() throws MyTimeException; List<HashMap<Object, Object>> getProjects() throws MyTimeException;
Project addProject(Project project) throws MyTimeException; Project addProject(Project project) throws MyTimeException;
......
...@@ -79,20 +79,36 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -79,20 +79,36 @@ public class ProjectServiceImpl implements ProjectService {
} }
@Override @Override
public List<Project> getProjects() throws MyTimeException { public List<HashMap<Object, Object>> getProjects() throws MyTimeException {
/* /*
* MT-79:returns all project info. This will get implemented once managers are * MT-79:returns all project info. This will get implemented once managers are
* maintained as List and not attributes * maintained as List and not attributes
* return projectRepo.findAll(); * return projectRepo.findAll();
*/ */
List<HashMap<Object, Object>> projectList = new ArrayList<>();
List<HashMap<String, String>> EmployeeList = null;
List<Project> projects=projectRepo.findAll(); List<Project> projects=projectRepo.findAll();
for(Project p:projects) for (Project p : projects) {
{ HashMap<Object, Object> projectMap = new HashMap<>();
if(p.getManagerIds()== null && p.getManagerId()!= null) projectMap.put("id", p.getId());
p.setManagerIds(Arrays.asList(p.getManagerId())); projectMap.put("projectId", p.getProjectId());
projectMap.put("projectName", p.getProjectName());
projectMap.put("account", p.getAccount());
projectMap.put("domain", p.getDomain());
projectMap.put("status", p.getStatus());
projectMap.put("employeeIds", p.getEmployeeIds());
if (p.getManagerIds() == null && p.getManagerId() != null) {
EmployeeList = getEmployeeData(Arrays.asList(p.getManagerId()));
} else if (p.getManagerIds() != null) {
List<String> managerIds = p.getManagerIds();
EmployeeList = getEmployeeData(managerIds);
}
projectMap.put("managerIds", EmployeeList);
projectList.add(projectMap);
} }
return projects; return projectList;
} }
@Override @Override
...@@ -719,4 +735,18 @@ public class ProjectServiceImpl implements ProjectService { ...@@ -719,4 +735,18 @@ public class ProjectServiceImpl implements ProjectService {
return projectTeamMatesRepo.findByAccountAndActiveAndBillableStatus( return projectTeamMatesRepo.findByAccountAndActiveAndBillableStatus(
account, status, billableStatus); account, status, billableStatus);
} }
public List<HashMap<String, String>> getEmployeeData(List<String> ids) {
List<HashMap<String, String>> EmployeeList = new ArrayList<>();
Query query = new Query(Criteria.where("employeeId").in(ids));
List<EmployeeRoles> employeeRoles = mongoTemplate.find(query, EmployeeRoles.class);
for (EmployeeRoles employeesRole : employeeRoles) {
HashMap<String, String> managerMap = new HashMap<>();
managerMap.put("id", employeesRole.getEmployeeId());
managerMap.put("name", employeesRole.getEmployeeName());
EmployeeList.add(managerMap);
}
return EmployeeList;
}
} }
...@@ -5,10 +5,9 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -5,10 +5,9 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
"projectId": "", "projectId": "",
"projectName": "", "projectName": "",
"account": "", "account": "",
"managerId": "",
"managerName": "",
"status": "", "status": "",
"action": "" "action": "",
"managerIds":[]
}; };
$scope.managers = []; $scope.managers = [];
...@@ -20,8 +19,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -20,8 +19,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
//code added //code added
var getCellTemplate = '<p class="col-lg-12"><i class="fa fa-book 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,\'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>' +
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>' + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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>'; '&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 = { $scope.gridOptions = {
...@@ -36,7 +35,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -36,7 +35,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
{ field: 'projectName', displayName: 'Project ', enableColumnMenu: false, enableSorting: true, enableFiltering: true }, { field: 'projectName', displayName: 'Project ', enableColumnMenu: false, enableSorting: true, enableFiltering: true },
{ field: 'account', displayName: 'Account ', enableColumnMenu: false, enableSorting: true, enableFiltering: true }, { field: 'account', displayName: 'Account ', enableColumnMenu: false, enableSorting: true, enableFiltering: true },
//{field : 'managerId',displayName: 'Manager ID ', enableColumnMenu: false, enableSorting: false}, //{field : 'managerId',displayName: 'Manager ID ', enableColumnMenu: false, enableSorting: false},
{ field: 'managerIds', displayName: 'Manager Name ', cellTemplate: '<div ng-repeat= "item in row.entity[col.field]">{{item}}<span ng-hide="$last">,</span></div>', enableColumnMenu: false, enableSorting: true, enableFiltering: true }, { field: 'managerIds', displayName: 'Manager Name ', cellTemplate: '<div ng-repeat= "item in row.entity[col.field]">{{item.name}}<span ng-hide="$last">,</span></div>', enableColumnMenu: false, enableSorting: true, enableFiltering: true },
{ field: 'status', displayName: 'Status ', enableColumnMenu: false, enableSorting: true, enableFiltering: false }, { field: 'status', displayName: 'Status ', enableColumnMenu: false, enableSorting: true, enableFiltering: false },
{ name: 'Actions', displayName: 'Actions', cellTemplate: getCellTemplate, enableColumnMenu: false, enableSorting: false, enableFiltering: false, width: 130 } { name: 'Actions', displayName: 'Actions', cellTemplate: getCellTemplate, enableColumnMenu: false, enableSorting: false, enableFiltering: false, width: 130 }
] ]
...@@ -47,8 +46,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -47,8 +46,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
$scope.parentData.projectId = row.entity.projectId; $scope.parentData.projectId = row.entity.projectId;
$scope.parentData.projectName = row.entity.projectName; $scope.parentData.projectName = row.entity.projectName;
$scope.parentData.account = row.entity.account; $scope.parentData.account = row.entity.account;
$scope.parentData.managerId = row.entity.managerId; $scope.parentData.managerIds=row.entity.managerIds;
$scope.parentData.managerName = row.entity.managerName;
$scope.parentData.domain = row.entity.domain; $scope.parentData.domain = row.entity.domain;
$scope.parentData.status = row.entity.status; $scope.parentData.status = row.entity.status;
if (action == "Update") if (action == "Update")
...@@ -388,8 +386,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -388,8 +386,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
$scope.projectId = dataToPass.projectId; $scope.projectId = dataToPass.projectId;
$scope.projectName = dataToPass.projectName; $scope.projectName = dataToPass.projectName;
$scope.account = dataToPass.account; $scope.account = dataToPass.account;
$scope.managerId = dataToPass.managerId; $scope.managerIds=dataToPass.managerIds;
$scope.managerName = dataToPass.managerName;
$scope.projectStatus = dataToPass.status; $scope.projectStatus = dataToPass.status;
$scope.domain = dataToPass.domain; $scope.domain = dataToPass.domain;
$scope.managerModel = { $scope.managerModel = {
......
...@@ -4,8 +4,7 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid ...@@ -4,8 +4,7 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid
$scope.parentData = { $scope.parentData = {
"projectId": "", "projectId": "",
"projectName": "", "projectName": "",
"managerId":"", "managerIds":[],
"managerName": "",
"status": "", "status": "",
"action":"" "action":""
}; };
...@@ -33,8 +32,7 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid ...@@ -33,8 +32,7 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid
$scope.getRowData = function(row, action){ $scope.getRowData = function(row, action){
$scope.parentData.projectId = row.entity.projectId; $scope.parentData.projectId = row.entity.projectId;
$scope.parentData.projectName = row.entity.projectName; $scope.parentData.projectName = row.entity.projectName;
$scope.parentData.managerId = row.entity.managerId; $scope.parentData.managerIds=row.entity.managerIds;
$scope.parentData.managerName = row.entity.managerName;
$scope.parentData.status = row.entity.status; $scope.parentData.status = row.entity.status;
if(action == "Update") if(action == "Update")
$scope.addProject(action, $scope.parentData); $scope.addProject(action, $scope.parentData);
...@@ -271,9 +269,8 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid ...@@ -271,9 +269,8 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid
}else if(dataToPass.action == "View"){ }else if(dataToPass.action == "View"){
$scope.projectId = dataToPass.projectId; $scope.projectId = dataToPass.projectId;
$scope.projectName = dataToPass.projectName; $scope.projectName = dataToPass.projectName;
$scope.managerId = dataToPass.managerId;
$scope.managerName = dataToPass.managerName;
$scope.projectStatus = dataToPass.status; $scope.projectStatus = dataToPass.status;
$scope.managerIds=dataToPass.managerIds;
// $scope.managerModel = dataToPass.managerModel; // $scope.managerModel = dataToPass.managerModel;
$scope.gridOptions = { $scope.gridOptions = {
paginationPageSizes : [ 10, 20, 30, 40, 50, 100], paginationPageSizes : [ 10, 20, 30, 40, 50, 100],
......
...@@ -21,14 +21,14 @@ ...@@ -21,14 +21,14 @@
<div class="form-group "> <div class="form-group ">
<div class="row col-lg-12 " style="margin-left: 0px; "> <div class="row col-lg-12 " style="margin-left: 0px; ">
<div class="row col-lg-12 col-xs-12 "> <div class="row col-lg-12 col-xs-12 ">
<div class="col-xs-6 text-center "> <div class="col-xs-6 text-left ">
<p> <p>
<b>Project Name:</b> {{projectName}} <b>Project Name:</b> {{projectName}}
</p> </p>
</div> </div>
<div class="col-xs-6 text-center "> <div class="col-xs-6 text-right ">
<p> <p>
<b>Manager Name:</b>&nbsp;&nbsp;&nbsp; {{managerName}} <b>Manager Name:</b><p><span ng-repeat="x in managerIds"> {{x.name}}<br></span></p>
</p> </p>
</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