Only allow to configure columns as summable, that can be summed

no more "sum that subject and the versions!"
pull/3493/head
Jan Sandbrink 9 years ago
parent 02e7b9f5a8
commit cf57b3c43e
  1. 14
      app/helpers/settings_helper.rb
  2. 9
      app/views/settings/_work_packages.html.erb
  3. 20
      spec/helpers/settings_helper_spec.rb

@ -149,14 +149,18 @@ module SettingsHelper
def build_settings_matrix_body(settings, choices)
choices.map { |choice|
text, value = (choice.is_a?(Array)) ? choice : [choice, choice]
value = choice[:value]
caption = choice[:caption] || value.to_s
exceptions = Array(choice[:except]).compact
content_tag(:tr, class: 'form--matrix-row') do
content_tag(:td, text, class: 'form--matrix-cell') +
content_tag(:td, caption, class: 'form--matrix-cell') +
settings.map { |setting|
content_tag(:td, class: 'form--matrix-checkbox-cell') do
styled_check_box_tag("settings[#{setting}][]", value,
Setting.send(setting).include?(value),
id: "#{setting}_#{value}")
unless exceptions.include?(setting)
styled_check_box_tag("settings[#{setting}][]", value,
Setting.send(setting).include?(value),
id: "#{setting}_#{value}")
end
end
}.join.html_safe
end

@ -36,8 +36,15 @@ See doc/COPYRIGHT.rdoc for more details.
<div class="form--field"><%= setting_text_field :work_packages_export_limit, :size => 6 %></div>
</section>
<fieldset class="form--fieldset"><legend class="form--fieldset-legend"><%= l(:setting_column_options) %></legend>
<%
column_choices = Query.new.available_columns.map { |column|
choice = { caption: column.caption, value: column.name.to_s }
choice[:except] = :work_package_list_summable_columns unless column.summable?
choice
}
%>
<%= settings_matrix([:work_package_list_default_columns, :work_package_list_summable_columns],
Query.new.available_columns.collect {|c| [c.caption, c.name.to_s]}, :label_choices => :setting_work_package_properties) %>
column_choices, :label_choices => :setting_work_package_properties) %>
</fieldset>
<%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-yes' %>
<% end %>

@ -87,9 +87,25 @@ describe SettingsHelper, type: :helper do
end
subject(:output) {
helper.settings_matrix [:field_a, :field_b], [
['Popsickle', '1'], ['Jello', '2'], ['Ice Cream', '3'], 'Quarkspeise'
settings = [:field_a, :field_b]
choices = [
{
caption: 'Popsickle',
value: '1'
},
{
caption: 'Jello',
value: '2'
},
{
caption: 'Ice Cream',
value: '3'
},
{
value: 'Quarkspeise'
}
]
helper.settings_matrix settings, choices
}
it_behaves_like 'not wrapped in container'

Loading…
Cancel
Save