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;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -63,8 +64,8 @@ public class ProjectController {
}
@RequestMapping(value = "/getProjects", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Project>> getProjects() throws MyTimeException {
List<Project> projects = projectService.getProjects();
public ResponseEntity<List<HashMap<Object, Object>>> getProjects() throws MyTimeException {
List<HashMap<Object, Object>> projects = projectService.getProjects();
return new ResponseEntity<>(projects, HttpStatus.OK);
}
......
package com.nisum.mytime.service;
import java.util.HashMap;
import java.util.List;
import org.bson.types.ObjectId;
......@@ -17,7 +18,7 @@ public interface ProjectService {
List<EmpLoginData> employeeLoginsBasedOnDate(long id, String fromDate,
String toDate) throws MyTimeException;
List<Project> getProjects() throws MyTimeException;
List<HashMap<Object, Object>> getProjects() throws MyTimeException;
Project addProject(Project project) throws MyTimeException;
......
......@@ -79,20 +79,36 @@ public class ProjectServiceImpl implements ProjectService {
}
@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
* maintained as List and not attributes
* return projectRepo.findAll();
*/
List<HashMap<Object, Object>> projectList = new ArrayList<>();
List<HashMap<String, String>> EmployeeList = null;
List<Project> projects=projectRepo.findAll();
for(Project p:projects)
{
if(p.getManagerIds()== null && p.getManagerId()!= null)
p.setManagerIds(Arrays.asList(p.getManagerId()));
for (Project p : projects) {
HashMap<Object, Object> projectMap = new HashMap<>();
projectMap.put("id", p.getId());
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
......@@ -719,4 +735,18 @@ public class ProjectServiceImpl implements ProjectService {
return projectTeamMatesRepo.findByAccountAndActiveAndBillableStatus(
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
"projectId": "",
"projectName": "",
"account": "",
"managerId": "",
"managerName": "",
"status": "",
"action": ""
"action": "",
"managerIds":[]
};
$scope.managers = [];
......@@ -20,8 +19,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
//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>' +
'&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>' +
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="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>';
$scope.gridOptions = {
......@@ -36,7 +35,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
{ field: 'projectName', displayName: 'Project ', 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: '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 },
{ 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
$scope.parentData.projectId = row.entity.projectId;
$scope.parentData.projectName = row.entity.projectName;
$scope.parentData.account = row.entity.account;
$scope.parentData.managerId = row.entity.managerId;
$scope.parentData.managerName = row.entity.managerName;
$scope.parentData.managerIds=row.entity.managerIds;
$scope.parentData.domain = row.entity.domain;
$scope.parentData.status = row.entity.status;
if (action == "Update")
......@@ -388,8 +386,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
$scope.projectId = dataToPass.projectId;
$scope.projectName = dataToPass.projectName;
$scope.account = dataToPass.account;
$scope.managerId = dataToPass.managerId;
$scope.managerName = dataToPass.managerName;
$scope.managerIds=dataToPass.managerIds;
$scope.projectStatus = dataToPass.status;
$scope.domain = dataToPass.domain;
$scope.managerModel = {
......
......@@ -4,8 +4,7 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid
$scope.parentData = {
"projectId": "",
"projectName": "",
"managerId":"",
"managerName": "",
"managerIds":[],
"status": "",
"action":""
};
......@@ -33,8 +32,7 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid
$scope.getRowData = function(row, action){
$scope.parentData.projectId = row.entity.projectId;
$scope.parentData.projectName = row.entity.projectName;
$scope.parentData.managerId = row.entity.managerId;
$scope.parentData.managerName = row.entity.managerName;
$scope.parentData.managerIds=row.entity.managerIds;
$scope.parentData.status = row.entity.status;
if(action == "Update")
$scope.addProject(action, $scope.parentData);
......@@ -271,9 +269,8 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid
}else if(dataToPass.action == "View"){
$scope.projectId = dataToPass.projectId;
$scope.projectName = dataToPass.projectName;
$scope.managerId = dataToPass.managerId;
$scope.managerName = dataToPass.managerName;
$scope.projectStatus = dataToPass.status;
$scope.managerIds=dataToPass.managerIds;
// $scope.managerModel = dataToPass.managerModel;
$scope.gridOptions = {
paginationPageSizes : [ 10, 20, 30, 40, 50, 100],
......
......@@ -21,14 +21,14 @@
<div class="form-group ">
<div class="row col-lg-12 " style="margin-left: 0px; ">
<div class="row col-lg-12 col-xs-12 ">
<div class="col-xs-6 text-center ">
<div class="col-xs-6 text-left ">
<p>
<b>Project Name:</b> {{projectName}}
</p>
</div>
<div class="col-xs-6 text-center ">
<div class="col-xs-6 text-right ">
<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>
</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