From f11738ad6797f4207e8b015d2d7eb97143782512 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Tue, 29 Jul 2014 09:53:46 +0200 Subject: [PATCH] Show plugin attributes in WP overview --- .../angular/config/configuration-service.js | 17 ++++++++++++++++- .../details-tab-overview-controller.js | 11 +++-------- app/controllers/work_packages_controller.rb | 10 ++++++++++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/angular/config/configuration-service.js b/app/assets/javascripts/angular/config/configuration-service.js index a4e585b3cb..69f5f2fc0b 100644 --- a/app/assets/javascripts/angular/config/configuration-service.js +++ b/app/assets/javascripts/angular/config/configuration-service.js @@ -28,9 +28,16 @@ angular.module('openproject.config') +.constant('DEFAULT_WORK_PACKAGE_PROPERTIES', [ + 'status', 'assignee', 'responsible', + 'date', 'percentageDone', 'priority', + 'estimatedTime', 'versionName' +]) + .service('ConfigurationService', [ '$log', - function($log) { + 'DEFAULT_WORK_PACKAGE_PROPERTIES', + function($log, DEFAULT_WORK_PACKAGE_PROPERTIES) { return { settingsPresent: function() { @@ -80,6 +87,14 @@ angular.module('openproject.config') }, timeFormat: function() { return gon.settings.display.time_format; + }, + workPackageAttributeSettingsPresent: function() { + return this.settingsPresent() && gon.settings.hasOwnProperty('work_package_attributes'); + }, + workPackageAttributes: function() { + var attributes = (this.workPackageAttributeSettingsPresent()) ? gon.settings.work_package_attributes : []; + + return DEFAULT_WORK_PACKAGE_PROPERTIES.concat(attributes); } }; }]); diff --git a/app/assets/javascripts/angular/work_packages/controllers/details-tab-overview-controller.js b/app/assets/javascripts/angular/work_packages/controllers/details-tab-overview-controller.js index 043e993544..06704ce20b 100644 --- a/app/assets/javascripts/angular/work_packages/controllers/details-tab-overview-controller.js +++ b/app/assets/javascripts/angular/work_packages/controllers/details-tab-overview-controller.js @@ -28,23 +28,18 @@ angular.module('openproject.workPackages.controllers') -.constant('DEFAULT_WORK_PACKAGE_PROPERTIES', [ - 'status', 'assignee', 'responsible', - 'date', 'percentageDone', 'priority', - 'estimatedTime', 'versionName' -]) .constant('USER_TYPE', 'user') .controller('DetailsTabOverviewController', [ '$scope', 'I18n', - 'DEFAULT_WORK_PACKAGE_PROPERTIES', + 'ConfigurationService', 'USER_TYPE', 'CustomFieldHelper', 'WorkPackagesHelper', 'UserService', '$q', - function($scope, I18n, DEFAULT_WORK_PACKAGE_PROPERTIES, USER_TYPE, CustomFieldHelper, WorkPackagesHelper, UserService, $q) { + function($scope, I18n, ConfigurationService, USER_TYPE, CustomFieldHelper, WorkPackagesHelper, UserService, $q) { // work package properties @@ -52,7 +47,7 @@ angular.module('openproject.workPackages.controllers') $scope.emptyWorkPackageProperties = []; $scope.userPath = PathHelper.staticUserPath; - var workPackageProperties = DEFAULT_WORK_PACKAGE_PROPERTIES; + var workPackageProperties = ConfigurationService.workPackageAttributes(); function getPropertyValue(property, format) { if (format === USER_TYPE) { diff --git a/app/controllers/work_packages_controller.rb b/app/controllers/work_packages_controller.rb index 62a54496c2..233983caa4 100644 --- a/app/controllers/work_packages_controller.rb +++ b/app/controllers/work_packages_controller.rb @@ -206,6 +206,7 @@ class WorkPackagesController < ApplicationController respond_to do |format| format.html do gon.settings = client_preferences + gon.settings[:work_package_attributes] = hook_overview_attributes render :index, :locals => { :query => @query, :project => @project }, @@ -454,4 +455,13 @@ class WorkPackagesController < ApplicationController def parse_preview_data parse_preview_data_helper :work_package, [:notes, :description] end + + def hook_overview_attributes + attributes = [] + call_hook(:work_packages_overview_attributes, + work_package: work_package, + project: project, + attributes: attributes) + attributes + end end