Add plug-in actions

pull/1782/head
Hagen Schink 10 years ago
parent f698fa6f2d
commit a87ed9aa5a
  1. 25
      app/assets/javascripts/angular/work_packages/directives/work-package-details-toolbar-directive.js
  2. 14
      public/templates/work_packages/work_package_details_toolbar.html

@ -37,6 +37,7 @@ angular.module('openproject.workPackages.directives')
'I18n',
'flags',
'PathHelper',
'HookService',
'WorkPackagesTableService',
'WorkPackageService',
'WorkPackageAuthorization',
@ -46,10 +47,32 @@ angular.module('openproject.workPackages.directives')
I18n,
flags,
PathHelper,
HookService,
WorkPackagesTableService,
WorkPackageService,
WorkPackageAuthorization) {
function getPermittedPluginActions(authorization) {
var pluginActions = HookService.call('workPackageDetailsMoreMenu').reduce(function(previousValue, currentValue) {
return angular.extend(previousValue, currentValue);
}, { });
var permittedPluginActions = authorization.permittedActions(Object.keys(pluginActions));
var augmentedPluginActions = { };
angular.forEach(permittedPluginActions, function(value, key) {
var css = [].concat(pluginActions[key]);
if (css.length == 0) {
css = ["icon-" + key];
}
this[key] = { link: value, css: css };
}, augmentedPluginActions);
return augmentedPluginActions;
}
return {
restrict: 'E',
replace: true,
@ -62,7 +85,9 @@ angular.module('openproject.workPackages.directives')
scope.I18n = I18n;
scope.permittedActions = authorization.permittedActions(PERMITTED_MORE_MENU_ACTIONS);
scope.permittedPluginActions = getPermittedPluginActions(authorization);
scope.actionsAvailable = Object.keys(scope.permittedActions).length > 0;
scope.pluginActionsAvailable = Object.keys(scope.permittedPluginActions).length > 0;
scope.editWorkPackage = function() {
// TODO: Temporarily going to the old edit dialog until we get in-place editing done

@ -1,7 +1,7 @@
<div class="work-packages--details-toolbar">
<button class="button" ng-click="editWorkPackage()"><i class="icon-left icon-edit"></i>{{ I18n.t('js.button_edit') }}</button>
<button class="button dropdown-relative"
ng-disabled="!actionsAvailable"
ng-disabled="!(actionsAvailable || pluginActionsAvailable)"
with-dropdown
dropdown-id="moreDropdown">
{{ I18n.t('js.button_more') }}
@ -21,4 +21,16 @@
</a>
</li>
</ul>
<hr ng-if="actionsAvailable && pluginActionsAvailable"/>
<ul class="dropdown-menu" ng-if="pluginActionsAvailable">
<li ng-repeat="(action, properties) in permittedPluginActions"
ng-click="triggerMoreMenuAction(action, properties.link)"
class="{{action}}">
<a href
ng-class="['icon-context'].concat(properties.css)"
ng-click="deleteWorkPackages()"
ng-bind="I18n.t('js.button_' + action)">
</a>
</li>
</ul>
</div>

Loading…
Cancel
Save