Commit 33b8a8f7 authored by Prayas Jain's avatar Prayas Jain

Added endpoint for open pool and edit functionality in onbehalf feature

parent 7559e41a
......@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping
......@@ -131,6 +132,17 @@ public class ResourceController {
"List of Resources for a project", null, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
@RequestMapping(value = "/resources/openPool/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getResourcesForOpenPool(HttpServletRequest request)
throws MyTeamException {
List<ResourceVO> resourcesList = resourceService.getResourcesForOpenPool(MyTeamUtils.BENCH_PROJECT_ID, MyTeamUtils.ACTIVE).stream()
.sorted((o1, o2) -> o1.getEmployeeName().trim().compareTo(o2.getEmployeeName().trim()))
.collect(Collectors.toList());
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
"List of Resources for a project", resourcesList, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
@RequestMapping(value = "/resources/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getMyProjectAllocations(
......
......@@ -71,6 +71,8 @@ public interface IResourceService {
Resource getCurrentAllocation(String employeeId);
List<ResourceVO> getResourcesForOpenPool(String projectId, String statusFlag);
// List<Resource> getAllResourcesForProject(String projectId, String status);
......
......@@ -166,6 +166,7 @@ public class ResourceService implements IResourceService {
nextAllocation.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resourceReq.getBillingEndDate()));
this.updateExistedResource(nextAllocation);
}
resource.setOnBehalfOf(resourceReq.getOnBehalfOf());
resource.setBillableStatus(resourceReq.getBillableStatus());
resource.setBillingStartDate(resourceReq.getBillingStartDate());
resource.setBillingEndDate(resourceReq.getBillingEndDate());
......@@ -680,6 +681,38 @@ public class ResourceService implements IResourceService {
}
return resourcesList;
}
@Override
public List<ResourceVO> getResourcesForOpenPool(String projectId, String statusFlag) {
List<ResourceVO> resourcesList = new ArrayList<>();
for (Resource resource : resourceRepo.findByProjectId(projectId)) {
Date billingEndDate = resource.getBillingEndDate();
Date todayDate = new Date();
if (billingEndDate != null) {
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
if(employee.getEmpStatus().equalsIgnoreCase(MyTeamUtils.ACTIVE) && billingEndDate.compareTo(todayDate)>0) {
ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO.setResourceRole(resource.getResourceRole());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate());
resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setEmployeeId(resource.getEmployeeId());
resourceVO.setStatus(resource.getStatus());
resourceVO.setOnBehalfOf(resource.getOnBehalfOf()!=null?employeeService.getEmployeeById(resource.getOnBehalfOf()).getEmployeeName():"");
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
resourcesList.add(resourceVO);
}
}
}
return resourcesList;
}
@Override
......
......@@ -76,14 +76,10 @@ myApp.controller("openPoolController", function($scope, $http, myFactory, $mdDia
}
$http({
method : "GET",
url : appConfig.appUri + 'resources/project/Nisum0000?status=Active'
url : appConfig.appUri + 'resources/openPool/active'
}).then(function mySuccess(response) {
$mdDialog.hide();
today.setHours(0, 0, 0, 0);
var openPoolRecords = response.data.records.filter(function (employee) {
return employee.billingEndDate >= today;
});
$scope.gridOptions.data = openPoolRecords;
$scope.gridOptions.data = response.data.records;
if(response.data.records.length > 10){
$scope.gridOptions.enablePaginationControls = true;
}
......
......@@ -630,7 +630,19 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
//'&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;" ng-click="grid.appScope.getRowData(row,\'Delete\')"></i></p>';
var getCellActiveTemplate = '<div ng-show="COL_FIELD==true"><p class="col-lg-12">Y</P></div><div ng-show="COL_FIELD==false"><p class="col-lg-12">N</p></div>';
var onBehalfOfCellTemplate = '<div class="ui-grid-cell-contents" ng-if="!row.entity.editrow">{{COL_FIELD}}</div><div ng-if="row.entity.editrow" class="grid-Dropdown">'+
'<md-select style="margin-right:10px;" ng-model="MODEL_COL_FIELD" data-md-container-class="selectHeader" id="selectEmp" name="employeeModel" placeholder="Add Resource">'+
'<md-select-header class="selectHeaderChild header-spacing" layout="column">'+
'<input ng-model="grid.appScope.searchTerm" type="search" id="search" ng-keydown="grid.appScope.updateSearch($event)" ng-model-options="{debounce: {\'default\': 500, \'blur\': 0}}"'+
'placeholder="Search for employee" class="searchBoxHeader demo-header-searchbox md-text search-spacingleft"/>'+
'<span class="glyphicon glyphicon-remove close-mdselect" ng-click="grid.appScope.closeSelectBox()"></span>'+
'</md-select-header>'+
'<md-optgroup label="Employee" class="optionScroll">'+
'<md-option value= "" ng-click="grid.appScope.getEmp(null)">None</md-option>'+
'<md-option ng-value="employee.employeeName" ng-repeat="employee in grid.appScope.employeeList | filter:grid.appScope.searchFilter" ng-click="grid.appScope.getEmp(employee)">{{employee.employeeName}}</md-option>'+
'</md-optgroup>'+
'</md-select></div>';
$scope.gridOptions = {
paginationPageSizes: [10, 20, 30, 40, 50, 100],
......@@ -647,11 +659,11 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
direction: uiGridConstants.ASC,
priority: 0,
} },
{ name: 'onBehalfOf', displayName: 'On Behalf Of', enableColumnMenu: true, enableSorting: true, enableFiltering:true,width:120 },
// { field: 'emailId', displayName: 'Email Id ', enableColumnMenu: false, enableSorting: false },
// { field: 'experience', displayName: 'Exp', enableColumnMenu: true, enableSorting: true, width: 80 },
{ field: 'onBehalfOf', displayName: 'On Behalf Of', enableColumnMenu: true, enableSorting: true, enableFiltering:true,width:160,
cellTemplate:onBehalfOfCellTemplate
},
{
name: 'resourceRole', displayName:'Role', enableColumnMenu: false,width:"*", enableSorting: false,enableFiltering:false,
name: 'resourceRole', displayName:'Role', enableColumnMenu: false,width:"120", enableSorting: false,enableFiltering:false,
cellTemplate:'<div class="ui-grid-cell-contents" ng-if="!row.entity.editrow">{{COL_FIELD}}</div><div ng-if="row.entity.editrow" class="grid-Dropdown"><md-select ng-model="MODEL_COL_FIELD" id="empRole">'
+'<md-optgroup label="employee role"><md-option ng-value="empRole" ng-repeat="empRole in col.colDef.editDropdownOptionsArray">{{empRole}}</md-option>'
+'</md-optgroup></md-select></div>',
......@@ -695,7 +707,7 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
$scope.gridOptions.data[i].resourceRole = "Individual Contributor";
}
}
if(response.data.records.length > 10){
if(response.data.records.length >= 9){
$scope.gridOptions.enablePaginationControls = true;
}
else{
......@@ -725,6 +737,9 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
}
}
$scope.getEmp = function (empObj) {
console.log(empObj)
}
$scope.parentData = {
"employeeId":"",
......@@ -753,12 +768,14 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
"endDate":"",
"newBillingStartDate":"",
"empAllocationStatus" : "",
"empBillableStatuses":[]
"empBillableStatuses":[],
"onBehalfOf":""
};
$scope.edit = function (rowd) {
$scope.searchTerm = "";
$scope.minBillingStartDate = new Date($scope.projectStartDate);
$scope.maxBillingStartDate = new Date($scope.projectEndDate);
$scope.maxBillingEndDate = new Date($scope.projectEndDate);
......@@ -791,6 +808,7 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
$scope.parentData.projectName = row.projectName;
$scope.parentData.designation = row.designation;
$scope.parentData.billableStatus = row.billableStatus;
$scope.parentData.onBehalfOf = row.onBehalfOf;
$scope.parentData.employeeModel = {
'employeeName': row.employeeName,
'employeeId': row.employeeId,
......@@ -807,13 +825,22 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
var allRows = row.grid.rows;
for(var i=0; i<allRows.length; i++) {
var newIndex = $scope.gridOptions.data.indexOf(allRows[i].entity)
if(newIndex == $scope.previousRowIndex){
if(newIndex == $scope.previousRowIndex && $scope.previousRow.status == "Engaged" && allRows[i].entity.status == "Engaged"){
allRows[i].entity.onBehalfOf = $scope.previousRow.onBehalfOf;
allRows[i].entity.resourceRole = $scope.previousRow.resourceRole;
allRows[i].entity.billableStatus = $scope.previousRow.billableStatus;
allRows[i].entity.billingStartDate = $scope.previousRow.billingStartDate;
allRows[i].entity.billingEndDate = $scope.previousRow.billingEndDate;
$scope.previousRow = angular.copy(row.entity);
}
else if(newIndex == $scope.previousRowIndex && $scope.previousRow.status == "Proposed" && allRows[i].entity.status == "Proposed"){
allRows[i].entity.onBehalfOf = $scope.previousRow.onBehalfOf;
allRows[i].entity.resourceRole = $scope.previousRow.resourceRole;
allRows[i].entity.billableStatus = $scope.previousRow.billableStatus;
allRows[i].entity.billingStartDate = $scope.previousRow.billingStartDate;
allRows[i].entity.billingEndDate = $scope.previousRow.billingEndDate;
$scope.previousRow = angular.copy(row.entity);
}
}
}
......@@ -867,8 +894,10 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
}else {
row.resourceRole == 'Individual Contributor' ? row.resourceRole = 'Employee' : row.resourceRole;
$scope.alertMsg ='';
var onBehalfOfEmp = $scope.getOnBehalfOfEmpId(row.onBehalfOf);
var onBehalfOfEmpId = onBehalfOfEmp[0].employeeId;
var loginEmpId = myFactory.getEmpId();
var record = {"id":row.id,"employeeId":row.employeeId,"projectId":row.projectId,"billableStatus":row.billableStatus,"billingEndDate":row.billingEndDate,"resourceRole":row.resourceRole,"billingStartDate":row.billingStartDate,"status":"Engaged"};
var record = {"id":row.id,"employeeId":row.employeeId,"projectId":row.projectId,"onBehalfOf":onBehalfOfEmpId,"billableStatus":row.billableStatus,"billingEndDate":row.billingEndDate,"resourceRole":row.resourceRole,"billingStartDate":row.billingStartDate,"status":"Engaged"};
var urlRequest = appConfig.appUri+ "resources?loginEmpId="+loginEmpId;
var req = {
method : 'PUT',
......@@ -935,14 +964,17 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
$scope.cancelEdit = function (row) {
$scope.searchTerm = "";
var index = $scope.gridOptions.data.indexOf(row);
$scope.gridOptions.data[index].editrow = false;
row.onBehalfOf = $scope.parentData.onBehalfOf;
row.billingStartDate = $scope.parentData.newBillingStartDate;
row.billingEndDate = $scope.parentData.endDate;
row.resourceRole = $scope.parentData.role;
row.billableStatus = $scope.parentData.billableStatus;
};
$scope.saveRow = function (row,action) {
$scope.searchTerm = "";
var index = $scope.gridOptions.data.indexOf(row);
$scope.gridOptions.data[index].editrow = false;
$scope.projectId = row.projectId;
......@@ -961,11 +993,12 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
$scope.employeeRole = row.resourceRole;
$scope.empBillableStatus = row.billableStatus;
$scope.empAllocationStatus = row.status;
$scope.aliasResourceName = row.onBehalfOf;
$scope.onBehalfOfEmpName = row.onBehalfOf;
$scope.id = row.id;
if(action == 'Update'){
$scope.validateFields(action,row);
if($scope.alertMsg != ""){
row.onBehalfOf = $scope.parentData.onBehalfOf;
row.billingStartDate = $scope.parentData.newBillingStartDate;
row.billingEndDate = $scope.parentData.endDate;
row.resourceRole = $scope.parentData.role;
......@@ -1507,21 +1540,35 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
}
}
$scope.getOnBehalfOfEmpId = function(onBehalfOfEmpName){
return $scope.employeeList.filter(function (employee) {
return employee.employeeName == onBehalfOfEmpName;
});
}
$scope.validateFields = function (action,row) {
var project = $scope.projectId;
var projectName = $scope.projectName;
var account = $scope.account;
var managerId=$scope.managerId;
var managerName=$scope.managerName;
var employeeModel = $scope.employeeModel;
var aliasFor = action == "Add" ? aliasFor = $scope.aliasModel.employeeId : aliasFor = $scope.aliasResourceName;
var projectModel = $scope.projectModel;
var newBillingStartDate = $scope.newBillingStartDate;
var empAllocationStatus = $scope.empAllocationStatus;
if(action == 'Update'){
$scope.employeeRole == 'Lead' ? $scope.employeeRole ='Lead' : $scope.employeeRole = 'Employee';
}
//var onBehalfEmpId = action=="Add" ? onBehalfEmpId = $scope.aliasModel.employeeId : onBehalfEmpId = $scope.onBehalfOfEmpName;
if(action == "Update" && ($scope.onBehalfOfEmpName != undefined && $scope.onBehalfOfEmpName != "")) {
$scope.onBehalfEmpId = $scope.getOnBehalfOfEmpId($scope.onBehalfOfEmpName)[0].employeeId;
}
else if(action == "Update" && ($scope.onBehalfOfEmpName == "" || $scope.onBehalfOfEmpName == undefined)){
$scope.onBehalfEmpId = null;
}
else if(action == "Add"){
$scope.onBehalfEmpId = $scope.aliasModel.employeeId;
}
if(action === "Add" || action =="Update"){
if(employeeModel == undefined || employeeModel.employeeName == undefined){
$scope.alertMsg = "Please select a employee";
......@@ -1577,7 +1624,7 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
else {
$scope.id = $scope.id ? $scope.id : $scope.objectId;
$scope.alertMsg = "";
var record = {"id":$scope.id,"employeeId":employeeModel.employeeId,"onBehalfOf":aliasFor,"projectId":project,"billableStatus":$scope.empBillableStatus,"billingEndDate":$scope.endDate,"resourceRole":$scope.employeeRole,"billingStartDate":newBillingStartDate,"status":empAllocationStatus};
var record = {"id":$scope.id,"employeeId":employeeModel.employeeId,"onBehalfOf":$scope.onBehalfEmpId,"projectId":project,"billableStatus":$scope.empBillableStatus,"billingEndDate":$scope.endDate,"resourceRole":$scope.employeeRole,"billingStartDate":newBillingStartDate,"status":empAllocationStatus};
if(action == "Add"){
addRecord(record,action);
$scope.myForm.$setPristine();
......@@ -1726,7 +1773,7 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
roleselected = data.role;
}
$scope.previousData = {
OnBehalfOf : data.onBehalfOf,
Role: roleselected,
//Shift: data.shift,
Billabilitystatus: data.billableStatus,
......@@ -1735,6 +1782,7 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
Enddate: data.endDate
},
$scope.currentData = {
OnBehalfOf : $scope.onBehalfOfEmpName,
Role: $scope.employeeRole,
// Shift: $scope.employeeShift,
Billabilitystatus: $scope.empBillableStatus,
......@@ -1973,6 +2021,7 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
}else{
$scope.alertMsg=response.data.message;
if($scope.alertMsg && $scope.alertMsg != ""){
row.onBehalfOf = $scope.parentData.onBehalfOf;
row.billingStartDate = $scope.parentData.newBillingStartDate;
row.billingEndDate = $scope.parentData.endDate;
row.resourceRole = $scope.parentData.role;
......@@ -1983,6 +2032,7 @@ myApp.controller("projectController", function ($scope,uiGridConstants, myFactor
}, function myError(response){
$scope.result = "Error";
row.onBehalfOf = $scope.parentData.onBehalfOf;
row.billingStartDate = $scope.parentData.newBillingStartDate;
row.billingEndDate = $scope.parentData.endDate;
row.resourceRole = $scope.parentData.role;
......
......@@ -657,9 +657,6 @@ cursor: pointer;
.manage-employee-efforts {
height: calc(100vh - 260px) !important;
}
.manage-open-pool {
height: calc(100vh - 230px) !important;
}
.md-datepicker-input-mask {
height : 0px;
}
......@@ -690,6 +687,7 @@ cursor: pointer;
.substatus-dropdown md-datepicker {
padding:0;
}
.substatus-dropdown >md-select {
margin:0;
}
......
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