diff --git a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/ganttprojectcontroller.js b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/ganttprojectcontroller.js index aa89ba9aad57a2529abb5572077c83f25d562a59..f1ab1f89e635afb78929adfb1e133b83396678ee 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/ganttprojectcontroller.js +++ b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/ganttprojectcontroller.js @@ -171,8 +171,11 @@ ganttProjectControllerMod.controller('GanttProjectController', ['$scope', 'dataS }; $scope.$watch('dataService.tasks', updateGanttData, true); - $scope.$watch('dataService.filteredTasks', updateGanttData, true); - $scope.$watch('dataService.tasktypes', updateGanttData, true); + $scope.$watch('dataService.resources', updateGanttData); + $scope.$watch('dataService.resourceClaims', updateGanttData, true); + $scope.$watch('dataService.resourceGroups', updateGanttData); + $scope.$watch('dataService.resourceGroupMemberships', updateGanttData); + $scope.$watch('dataService.filteredTaskDict', updateGanttData); $scope.$watch('dataService.momProjectsDict', updateGanttData, true); } ]); diff --git a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/ganttresourcecontroller.js b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/ganttresourcecontroller.js index 295bfe7488d6178ef823871ecd9e4f5df0ab1734..4a1be2f31efd1be25349560795984e32d5ae7eab 100644 --- a/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/ganttresourcecontroller.js +++ b/SAS/ResourceAssignment/ResourceAssignmentEditor/lib/static/app/controllers/ganttresourcecontroller.js @@ -94,31 +94,33 @@ ganttResourceControllerMod.controller('GanttResourceController', ['$scope', 'dat var createGanttRowTree = function(groupId, parentRow) { var resourceGroup = resourceGroupsDict[groupId]; - var groupRowId = 'group_' + groupId; - if(parentRow) { - groupRowId += '_parent' + parentRow.id; - } + if(resourceGroup) { + var groupRowId = 'group_' + groupId; + if(parentRow) { + groupRowId += '_parent' + parentRow.id; + } - var ganttRow = { - 'id': groupRowId, - 'parent': parentRow ? parentRow.id : null, - 'name': resourceGroup.name, - 'tasks': [] - }; + var ganttRow = { + 'id': groupRowId, + 'parent': parentRow ? parentRow.id : null, + 'name': resourceGroup.name, + 'tasks': [] + }; - ganttRowsDict[groupRowId] = ganttRow; + ganttRowsDict[groupRowId] = ganttRow; - //store ganttRow also in dict resourceGroup2GanttRows for fast lookup based on groupId - if(!resourceGroup2GanttRows.hasOwnProperty(groupId)) { - resourceGroup2GanttRows[groupId] = []; - } - resourceGroup2GanttRows[groupId].push(ganttRow); + //store ganttRow also in dict resourceGroup2GanttRows for fast lookup based on groupId + if(!resourceGroup2GanttRows.hasOwnProperty(groupId)) { + resourceGroup2GanttRows[groupId] = []; + } + resourceGroup2GanttRows[groupId].push(ganttRow); - //recurse over the childs - var numChilds = resourceGroupMemberships.groups[groupId].child_ids.length; - for(var i = 0; i < numChilds; i++) { - var childGroupId = resourceGroupMemberships.groups[groupId].child_ids[i]; - createGanttRowTree(childGroupId, ganttRow); + //recurse over the childs + var numChilds = resourceGroupMemberships.groups[groupId].child_ids.length; + for(var i = 0; i < numChilds; i++) { + var childGroupId = resourceGroupMemberships.groups[groupId].child_ids[i]; + createGanttRowTree(childGroupId, ganttRow); + } } }; @@ -153,22 +155,24 @@ ganttResourceControllerMod.controller('GanttResourceController', ['$scope', 'dat //since each resourceGroup itself can have multiple parents var parentGanttRows = resourceGroup2GanttRows[parentGroupId]; - for(var parentGanttRow of parentGanttRows) { - var resourceGanttRowId = 'resource_' + resource.id + '_' + parentGanttRow.id; - var ganttRow = { - id: resourceGanttRowId, - parent: parentGanttRow.id, - name: resource.name, - tasks: [] - }; - - ganttRowsDict[resourceGanttRowId] = ganttRow; - - //store ganttRow also in dict resource2GanttRows for fast lookup based on groupId - if(!resource2GanttRows.hasOwnProperty(resourceId)) { - resource2GanttRows[resourceId] = []; + if(parentGanttRows) { + for(var parentGanttRow of parentGanttRows) { + var resourceGanttRowId = 'resource_' + resource.id + '_' + parentGanttRow.id; + var ganttRow = { + id: resourceGanttRowId, + parent: parentGanttRow.id, + name: resource.name, + tasks: [] + }; + + ganttRowsDict[resourceGanttRowId] = ganttRow; + + //store ganttRow also in dict resource2GanttRows for fast lookup based on groupId + if(!resource2GanttRows.hasOwnProperty(resourceId)) { + resource2GanttRows[resourceId] = []; + } + resource2GanttRows[resourceId].push(ganttRow); } - resource2GanttRows[resourceId].push(ganttRow); } } } @@ -240,18 +244,20 @@ ganttResourceControllerMod.controller('GanttResourceController', ['$scope', 'dat for(var resourceId of resourceIds) { var claims = resource2Claims[resourceId]; - for(var claim of claims) { - var taskId = claim.task_id; - if(taskId in aggregatedClaims) { - if(claim.starttime < aggregatedClaims[taskId].starttime) { - aggregatedClaims[taskId].starttime = claim.starttime; - } - if(claim.endtime > aggregatedClaims[taskId].endtime) { - aggregatedClaims[taskId].endtime = claim.endtime; + if(claims) { + for(var claim of claims) { + var taskId = claim.task_id; + if(taskId in aggregatedClaims) { + if(claim.starttime < aggregatedClaims[taskId].starttime) { + aggregatedClaims[taskId].starttime = claim.starttime; + } + if(claim.endtime > aggregatedClaims[taskId].endtime) { + aggregatedClaims[taskId].endtime = claim.endtime; + } + } else { + aggregatedClaims[taskId] = { starttime: claim.starttime, + endtime: claim.endtime }; } - } else { - aggregatedClaims[taskId] = { starttime: claim.starttime, - endtime: claim.endtime }; } } }