Show plugin attributes in WP overview

pull/1683/head
Hagen Schink 10 years ago
parent 50519eccdc
commit f11738ad67
  1. 17
      app/assets/javascripts/angular/config/configuration-service.js
  2. 11
      app/assets/javascripts/angular/work_packages/controllers/details-tab-overview-controller.js
  3. 10
      app/controllers/work_packages_controller.rb

@ -28,9 +28,16 @@
angular.module('openproject.config') angular.module('openproject.config')
.constant('DEFAULT_WORK_PACKAGE_PROPERTIES', [
'status', 'assignee', 'responsible',
'date', 'percentageDone', 'priority',
'estimatedTime', 'versionName'
])
.service('ConfigurationService', [ .service('ConfigurationService', [
'$log', '$log',
function($log) { 'DEFAULT_WORK_PACKAGE_PROPERTIES',
function($log, DEFAULT_WORK_PACKAGE_PROPERTIES) {
return { return {
settingsPresent: function() { settingsPresent: function() {
@ -80,6 +87,14 @@ angular.module('openproject.config')
}, },
timeFormat: function() { timeFormat: function() {
return gon.settings.display.time_format; 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);
} }
}; };
}]); }]);

@ -28,23 +28,18 @@
angular.module('openproject.workPackages.controllers') angular.module('openproject.workPackages.controllers')
.constant('DEFAULT_WORK_PACKAGE_PROPERTIES', [
'status', 'assignee', 'responsible',
'date', 'percentageDone', 'priority',
'estimatedTime', 'versionName'
])
.constant('USER_TYPE', 'user') .constant('USER_TYPE', 'user')
.controller('DetailsTabOverviewController', [ .controller('DetailsTabOverviewController', [
'$scope', '$scope',
'I18n', 'I18n',
'DEFAULT_WORK_PACKAGE_PROPERTIES', 'ConfigurationService',
'USER_TYPE', 'USER_TYPE',
'CustomFieldHelper', 'CustomFieldHelper',
'WorkPackagesHelper', 'WorkPackagesHelper',
'UserService', 'UserService',
'$q', '$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 // work package properties
@ -52,7 +47,7 @@ angular.module('openproject.workPackages.controllers')
$scope.emptyWorkPackageProperties = []; $scope.emptyWorkPackageProperties = [];
$scope.userPath = PathHelper.staticUserPath; $scope.userPath = PathHelper.staticUserPath;
var workPackageProperties = DEFAULT_WORK_PACKAGE_PROPERTIES; var workPackageProperties = ConfigurationService.workPackageAttributes();
function getPropertyValue(property, format) { function getPropertyValue(property, format) {
if (format === USER_TYPE) { if (format === USER_TYPE) {

@ -206,6 +206,7 @@ class WorkPackagesController < ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
gon.settings = client_preferences gon.settings = client_preferences
gon.settings[:work_package_attributes] = hook_overview_attributes
render :index, :locals => { :query => @query, render :index, :locals => { :query => @query,
:project => @project }, :project => @project },
@ -454,4 +455,13 @@ class WorkPackagesController < ApplicationController
def parse_preview_data def parse_preview_data
parse_preview_data_helper :work_package, [:notes, :description] parse_preview_data_helper :work_package, [:notes, :description]
end end
def hook_overview_attributes
attributes = []
call_hook(:work_packages_overview_attributes,
work_package: work_package,
project: project,
attributes: attributes)
attributes
end
end end

Loading…
Cancel
Save