kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
125 lines
4.1 KiB
125 lines
4.1 KiB
10 years ago
|
//-- copyright
|
||
|
// OpenProject is a project management system.
|
||
10 years ago
|
// Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
10 years ago
|
//
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License version 3.
|
||
|
//
|
||
|
// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
// Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
// Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
//
|
||
|
// This program is free software; you can redistribute it and/or
|
||
|
// modify it under the terms of the GNU General Public License
|
||
|
// as published by the Free Software Foundation; either version 2
|
||
|
// of the License, or (at your option) any later version.
|
||
|
//
|
||
|
// This program is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU General Public License
|
||
|
// along with this program; if not, write to the Free Software
|
||
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
//
|
||
|
// See doc/COPYRIGHT.rdoc for more details.
|
||
|
//++
|
||
|
|
||
9 years ago
|
|
||
|
|
||
|
|
||
|
import {openprojectModule} from "../../angular-modules";
|
||
|
function wpDetailsToolbar(
|
||
|
PERMITTED_MORE_MENU_ACTIONS,
|
||
|
$state,
|
||
|
$window,
|
||
|
I18n,
|
||
|
HookService,
|
||
|
WorkPackageService,
|
||
|
WorkPackageAuthorization) {
|
||
10 years ago
|
|
||
10 years ago
|
function getPermittedActions(authorization, permittedMoreMenuActions) {
|
||
9 years ago
|
var permittedActions = authorization.permittedActionsWithLinks(permittedMoreMenuActions);
|
||
10 years ago
|
var augmentedActions = { };
|
||
|
|
||
9 years ago
|
angular.forEach(permittedActions, function(permission) {
|
||
|
var css = ["icon-" + permission.key];
|
||
10 years ago
|
|
||
9 years ago
|
this[permission.key] = { link: permission.link, css: css };
|
||
10 years ago
|
}, augmentedActions);
|
||
|
|
||
|
return augmentedActions;
|
||
|
}
|
||
|
|
||
10 years ago
|
function getPermittedPluginActions(authorization) {
|
||
9 years ago
|
var pluginActions = [];
|
||
|
angular.forEach(HookService.call('workPackageDetailsMoreMenu'), function(action) {
|
||
|
pluginActions = pluginActions.concat(action);
|
||
|
});
|
||
10 years ago
|
|
||
9 years ago
|
var permittedPluginActions = authorization.permittedActionsWithLinks(pluginActions);
|
||
10 years ago
|
var augmentedPluginActions = { };
|
||
|
|
||
9 years ago
|
angular.forEach(permittedPluginActions, function(action) {
|
||
|
var css = [].concat(action.css);
|
||
10 years ago
|
|
||
9 years ago
|
if (css.length === 0) {
|
||
|
css = ["icon-" + action.key];
|
||
10 years ago
|
}
|
||
|
|
||
9 years ago
|
this[action.key] = { link: action.link, css: css };
|
||
10 years ago
|
}, augmentedPluginActions);
|
||
|
|
||
|
return augmentedPluginActions;
|
||
|
}
|
||
|
|
||
10 years ago
|
return {
|
||
|
restrict: 'E',
|
||
9 years ago
|
templateUrl: '/components/wp-details/wp-details-toolbar.directive.html',
|
||
|
require: '^wpEditForm',
|
||
10 years ago
|
scope: {
|
||
10 years ago
|
workPackage: '='
|
||
10 years ago
|
},
|
||
9 years ago
|
|
||
9 years ago
|
link: function(scope, attr, element, wpEditForm) {
|
||
10 years ago
|
var authorization = new WorkPackageAuthorization(scope.workPackage);
|
||
10 years ago
|
|
||
9 years ago
|
scope.displayWatchButton = scope.workPackage.links.hasOwnProperty('unwatch') ||
|
||
|
scope.workPackage.links.hasOwnProperty('watch');
|
||
|
|
||
10 years ago
|
scope.I18n = I18n;
|
||
10 years ago
|
scope.permittedActions = angular.extend(getPermittedActions(authorization, PERMITTED_MORE_MENU_ACTIONS),
|
||
9 years ago
|
getPermittedPluginActions(authorization));
|
||
10 years ago
|
scope.actionsAvailable = Object.keys(scope.permittedActions).length > 0;
|
||
10 years ago
|
|
||
|
scope.triggerMoreMenuAction = function(action, link) {
|
||
|
switch (action) {
|
||
|
case 'delete':
|
||
|
deleteSelectedWorkPackage();
|
||
|
break;
|
||
10 years ago
|
default:
|
||
|
$window.location.href = link;
|
||
10 years ago
|
break;
|
||
|
}
|
||
|
};
|
||
|
|
||
9 years ago
|
scope.canEdit = () => wpEditForm.isEditable;
|
||
|
scope.editButtonVisible = () => wpEditForm.isEditable && !wpEditForm.inEditMode;
|
||
|
scope.editWorkPackage = () => wpEditForm.toggleEditMode(true);
|
||
|
|
||
10 years ago
|
function deleteSelectedWorkPackage() {
|
||
9 years ago
|
var workPackageDeletionId = scope.workPackage.props.id;
|
||
|
var promise = WorkPackageService.performBulkDelete([workPackageDeletionId], true);
|
||
10 years ago
|
|
||
9 years ago
|
promise.success(function() {
|
||
9 years ago
|
WorkPackageService.cache().remove('preselectedWorkPackageId');
|
||
10 years ago
|
$state.go('work-packages.list');
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
};
|
||
9 years ago
|
}
|
||
|
|
||
|
openprojectModule.directive('wpDetailsToolbar', wpDetailsToolbar);
|