From 599917e553a7fdef5afb7ed9a88d37b56ac9e32f Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Tue, 22 Mar 2011 17:00:42 +0100 Subject: [PATCH] #2891: displaying select menu for backlogs display options: none, left, right --- app/helpers/version_settings_helper.rb | 23 +++++++++++++++ app/views/versions/_form.rhtml | 21 +++++++++++++ config/locales/de.yml | 5 ++++ config/locales/en-GB.yml | 9 ++++-- config/locales/en.yml | 6 ++++ features/project_admin.feature | 31 ++++++++++++++++++++ init.rb | 1 + lib/backlogs_version_controller_patch.rb | 13 ++++++++ spec/helpers/version_settings_helper_spec.rb | 13 ++++++++ 9 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 app/helpers/version_settings_helper.rb create mode 100644 app/views/versions/_form.rhtml create mode 100644 features/project_admin.feature create mode 100644 lib/backlogs_version_controller_patch.rb create mode 100644 spec/helpers/version_settings_helper_spec.rb diff --git a/app/helpers/version_settings_helper.rb b/app/helpers/version_settings_helper.rb new file mode 100644 index 0000000000..e4934b6a9c --- /dev/null +++ b/app/helpers/version_settings_helper.rb @@ -0,0 +1,23 @@ +module VersionSettingsHelper + unloadable + + def position_display_options + options = [::VersionSetting::DISPLAY_NONE, + ::VersionSetting::DISPLAY_LEFT, + ::VersionSetting::DISPLAY_RIGHT] + options.collect {|s| [humanize_display_option(s), s]} + end + + private + + def humanize_display_option(option) + case option + when ::VersionSetting::DISPLAY_NONE + t("version_settings_display_option_none") + when ::VersionSetting::DISPLAY_LEFT + t("version_settings_display_option_left") + when ::VersionSetting::DISPLAY_RIGHT + t("version_settings_display_option_right") + end + end +end \ No newline at end of file diff --git a/app/views/versions/_form.rhtml b/app/views/versions/_form.rhtml new file mode 100644 index 0000000000..fc4b587e4b --- /dev/null +++ b/app/views/versions/_form.rhtml @@ -0,0 +1,21 @@ +<%= error_messages_for 'version' %> + +<% @version.build_version_setting if @version.version_setting.nil? %> + +
+

<%= f.text_field :name, :size => 60, :required => true %>

+

<%= f.text_field :description, :size => 60 %>

+

<%= f.select :status, Version::VERSION_STATUSES.collect {|s| [l("version_status_#{s}"), s]} %>

+

<%= f.text_field :wiki_page_title, :label => :label_wiki_page, :size => 60, :disabled => @project.wiki.nil? %>

+

<%= f.text_field :effective_date, :size => 10 %><%= calendar_for('version_effective_date') %>

+

<%= f.select :sharing, @version.allowed_sharings.collect {|v| [format_version_sharing(v), v]} %>

+ +<% f.fields_for :version_setting do |sf| %> +

<%= sf.select :display, position_display_options %>

+<% end %> + +<% @version.custom_field_values.each do |value| %> +

<%= custom_field_tag_with_label :version, value %>

+<% end %> + +
diff --git a/config/locales/de.yml b/config/locales/de.yml index 17ad241264..44a4230872 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -86,3 +86,8 @@ de: error_outro: Bitte beheben Sie die obigen Fehler bevor Sie erneut abschicken. backlogs: show_statistics: 'Scrum Statistiken anzeigen' + version_settings_display_option_none: kein + version_settings_display_option_left: links + version_settings_display_option_right: rechts + version_settings_display_label: Spalte im Backlog + diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index c2d8f682ba..1d23f95f76 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -1,5 +1,5 @@ ---- -en-GB: +--- +en-GB: rb_label_copy_tasks_open: "[[Open]]" label_webcal: Webcal Feed event_sprint_summary: "{{project}}: {{summary}}" @@ -84,3 +84,8 @@ en-GB: backlogs_product_backlog: Product backlog remaining_hours: remaining hours error_outro: Please correct the above errors before submitting again. + version_settings_display_option_none: none + version_settings_display_option_left: left + version_settings_display_option_right: right + version_settings_display_label: Column in backlog + diff --git a/config/locales/en.yml b/config/locales/en.yml index 270f5559a0..12dc219088 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -104,3 +104,9 @@ en: backlogs: show_statistics: 'Show Scrum statistics' + + version_settings_display_option_none: none + version_settings_display_option_left: left + version_settings_display_option_right: right + version_settings_display_label: Column in backlog + diff --git a/features/project_admin.feature b/features/project_admin.feature new file mode 100644 index 0000000000..13bd5f366f --- /dev/null +++ b/features/project_admin.feature @@ -0,0 +1,31 @@ +Feature: Project Admin + As a Project Admin + I want to configure the backlogs plugin + So that my team and I can work effectively + + + Background: + Given there is 1 project with: + | name | ecookbook | + And I am working in project "ecookbook" + And the project uses the following modules: + | backlogs | + And the backlogs module is initialized + And there is 1 user with: + | login | padme | + And there is a role "project admin" + And the role "project admin" may have the following rights: + | manage_versions | + And the user "padme" is a "project admin" + And the project has the following sprints: + | name | sprint_start_date | effective_date | + | Sprint 001 | 2010-01-01 | 2010-01-31 | + | Sprint 002 | 2010-02-01 | 2010-02-28 | + | Sprint 003 | 2010-03-01 | 2010-03-31 | + | Sprint 004 | 2010-03-01 | 2010-03-31 | + And I am logged in as "padme" + + Scenario: One can select whether versions are displayed left or right (left is default) in the backlogs page + When I go to the edit page of the version called "Sprint 001" + Then there should be a "version_version_setting_attributes_display" field within "#content form" + And the "version_version_setting_attributes_display" field within "#content form" should contain "2" \ No newline at end of file diff --git a/init.rb b/init.rb index 641a2027ee..95ebffaf10 100644 --- a/init.rb +++ b/init.rb @@ -18,6 +18,7 @@ Dispatcher.to_prepare do require_dependency 'backlogs_project_patch' require_dependency 'backlogs_user_patch' require_dependency 'backlogs_my_controller_patch' + require_dependency 'backlogs_version_controller_patch' end require_dependency 'backlogs_hooks' diff --git a/lib/backlogs_version_controller_patch.rb b/lib/backlogs_version_controller_patch.rb new file mode 100644 index 0000000000..5561fc73cd --- /dev/null +++ b/lib/backlogs_version_controller_patch.rb @@ -0,0 +1,13 @@ +module Backlogs + module VersionsControllerPatch + def self.included(base) + base.class_eval do + unloadable + include VersionSettingsHelper + helper :version_settings + end + end + end +end + +VersionsController.send(:include, Backlogs::VersionsControllerPatch) \ No newline at end of file diff --git a/spec/helpers/version_settings_helper_spec.rb b/spec/helpers/version_settings_helper_spec.rb new file mode 100644 index 0000000000..ec91f77488 --- /dev/null +++ b/spec/helpers/version_settings_helper_spec.rb @@ -0,0 +1,13 @@ +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe VersionSettingsHelper do + describe :position_display_options do + before(:each) do + @expected_options = [[I18n.t("version_settings_display_option_none"), 1], + [I18n.t("version_settings_display_option_left"), 2], + [I18n.t("version_settings_display_option_right"), 3]] + end + + it { helper.position_display_options.should eql @expected_options } + end +end \ No newline at end of file