|
|
|
@ -48,6 +48,7 @@ angular.module('openproject.workPackages.controllers') |
|
|
|
|
precedes: "precedes", |
|
|
|
|
follows: "follows" |
|
|
|
|
}) |
|
|
|
|
.constant('PERMITTED_MORE_MENU_ACTIONS', ['log_time', 'duplicate', 'move', 'delete']) |
|
|
|
|
|
|
|
|
|
.controller('WorkPackageDetailsController', [ |
|
|
|
|
'$scope', |
|
|
|
@ -58,6 +59,7 @@ angular.module('openproject.workPackages.controllers') |
|
|
|
|
'VISIBLE_LATEST', |
|
|
|
|
'RELATION_TYPES', |
|
|
|
|
'RELATION_IDENTIFIERS', |
|
|
|
|
'PERMITTED_MORE_MENU_ACTIONS', |
|
|
|
|
'$q', |
|
|
|
|
'WorkPackagesHelper', |
|
|
|
|
'PathHelper', |
|
|
|
@ -67,7 +69,10 @@ angular.module('openproject.workPackages.controllers') |
|
|
|
|
'ChildrenRelationsHandler', |
|
|
|
|
'ParentRelationsHandler', |
|
|
|
|
'WorkPackageService', |
|
|
|
|
function($scope, $state, latestTab, workPackage, I18n, VISIBLE_LATEST, RELATION_TYPES, RELATION_IDENTIFIERS, $q, WorkPackagesHelper, PathHelper, UsersHelper, ConfigurationService, CommonRelationsHandler, ChildrenRelationsHandler, ParentRelationsHandler, WorkPackageService) { |
|
|
|
|
'WorkPackageContextMenuHelper', |
|
|
|
|
'WorkPackagesTableService', |
|
|
|
|
'$window', |
|
|
|
|
function($scope, $state, latestTab, workPackage, I18n, VISIBLE_LATEST, RELATION_TYPES, RELATION_IDENTIFIERS, PERMITTED_MORE_MENU_ACTIONS, $q, WorkPackagesHelper, PathHelper, UsersHelper, ConfigurationService, CommonRelationsHandler, ChildrenRelationsHandler, ParentRelationsHandler, WorkPackageService, WorkPackageContextMenuHelper, WorkPackagesTableService, $window) { |
|
|
|
|
$scope.$on('$stateChangeSuccess', function(event, toState){ |
|
|
|
|
latestTab.registerState(toState.name); |
|
|
|
|
}); |
|
|
|
@ -155,6 +160,19 @@ angular.module('openproject.workPackages.controllers') |
|
|
|
|
$scope.author = workPackage.embedded.author; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$scope.$watch('rows', function(newVal, oldVal) { |
|
|
|
|
if (!$scope.workPackage) { return; } |
|
|
|
|
|
|
|
|
|
// More Menu
|
|
|
|
|
var workPackageRows = WorkPackagesTableService.getRowsByWorkPackageIds([$scope.workPackage.props.id]); |
|
|
|
|
|
|
|
|
|
if (workPackageRows && workPackageRows.length == 1) { |
|
|
|
|
var rowObject = workPackageRows[0].object; |
|
|
|
|
|
|
|
|
|
$scope.permittedActions = WorkPackageContextMenuHelper.getPermittedActions([rowObject], PERMITTED_MORE_MENU_ACTIONS); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$scope.toggleWatch = function() { |
|
|
|
|
$scope.toggleWatchLink |
|
|
|
|
.fetch({ ajax: $scope.toggleWatchLink.props }) |
|
|
|
@ -186,12 +204,35 @@ angular.module('openproject.workPackages.controllers') |
|
|
|
|
window.location = "/work_packages/" + $scope.workPackage.props.id; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
$scope.deleteSelectedWorkPackage = function() { |
|
|
|
|
$scope.triggerMoreMenuAction = function(action, link) { |
|
|
|
|
var actionLink; |
|
|
|
|
|
|
|
|
|
switch (action) { |
|
|
|
|
case 'delete': |
|
|
|
|
deleteSelectedWorkPackage(); |
|
|
|
|
break; |
|
|
|
|
case 'log_time': |
|
|
|
|
actionLink = PathHelper.timeEntryNewPath($scope.workPackage.props.id); |
|
|
|
|
break; |
|
|
|
|
case 'duplicate': |
|
|
|
|
actionLink = PathHelper.workPackageDuplicatePath($scope.workPackage.props.projectId, $scope.workPackage.props.id); |
|
|
|
|
break; |
|
|
|
|
case 'move': |
|
|
|
|
actionLink = PathHelper.workPackageMovePath($scope.workPackage.props.id) |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (actionLink) { |
|
|
|
|
$window.location.href = actionLink; |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function deleteSelectedWorkPackage() { |
|
|
|
|
var promis = WorkPackageService.performBulkDelete([$scope.workPackage.props.id], true); |
|
|
|
|
|
|
|
|
|
promis.success(function(data, status) { |
|
|
|
|
$state.go('work-packages.list'); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
]); |
|
|
|
|