Remove 'percentage done' if it is disabled

This should prevent the client to show the attribute if the admin disabled it
in the global configuration.
pull/2006/head
Hagen Schink 10 years ago
parent 20bb875423
commit dfa56b6c2b
  1. 12
      app/controllers/work_packages_controller.rb

@ -63,6 +63,8 @@ class WorkPackagesController < ApplicationController
# The order in here is actually important for the angular client.
# The first 6 are always to be displayed.
# Beware that 'percentageDone' may be removed if the related setting is
# disabled.
DEFAULT_WORK_PACKAGE_PROPERTIES = [:status, :assignee, :responsible,
:date, :percentageDone, :priority,
:category, :estimatedTime, :versionName, :spentTime]
@ -460,7 +462,15 @@ class WorkPackagesController < ApplicationController
parse_preview_data_helper :work_package, [:notes, :description]
end
def hook_overview_attributes(initial_attributes = DEFAULT_WORK_PACKAGE_PROPERTIES)
def enabled_default_work_package_properties
@enabled_default_work_package_properties ||= begin
properties = DEFAULT_WORK_PACKAGE_PROPERTIES
properties.delete(:percentageDone) if Setting.work_package_done_ratio == 'disabled'
properties
end
end
def hook_overview_attributes(initial_attributes = enabled_default_work_package_properties)
attributes = initial_attributes
call_hook(:work_packages_overview_attributes,
project: @project,

Loading…
Cancel
Save