From 1424b0f215082fff57d840dc715f5875bea45ef0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 29 Jun 2008 12:01:20 +0000 Subject: [PATCH] Addq "please select" to activity select box if no activity is set as default (#937). git-svn-id: http://redmine.rubyforge.org/svn/trunk@1602 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 3 +-- app/controllers/timelog_controller.rb | 1 - app/helpers/timelog_helper.rb | 8 ++++++++ app/views/issues/_edit.rhtml | 2 +- app/views/timelog/edit.rhtml | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 49b44323..5bc65d2e 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -43,6 +43,7 @@ class IssuesController < ApplicationController helper :sort include SortHelper include IssuesHelper + helper :timelog def index sort_init "#{Issue.table_name}.id", "desc" @@ -99,7 +100,6 @@ class IssuesController < ApplicationController @journals.reverse! if User.current.wants_comments_in_reverse_order? @allowed_statuses = @issue.new_statuses_allowed_to(User.current) @edit_allowed = User.current.allowed_to?(:edit_issues, @project) - @activities = Enumeration::get_values('ACTI') @priorities = Enumeration::get_values('IPRI') @time_entry = TimeEntry.new respond_to do |format| @@ -157,7 +157,6 @@ class IssuesController < ApplicationController def edit @allowed_statuses = @issue.new_statuses_allowed_to(User.current) - @activities = Enumeration::get_values('ACTI') @priorities = Enumeration::get_values('IPRI') @edit_allowed = User.current.allowed_to?(:edit_issues, @project) diff --git a/app/controllers/timelog_controller.rb b/app/controllers/timelog_controller.rb index cf1c844d..9f539d45 100644 --- a/app/controllers/timelog_controller.rb +++ b/app/controllers/timelog_controller.rb @@ -183,7 +183,6 @@ class TimelogController < ApplicationController redirect_to(params[:back_url].blank? ? {:action => 'details', :project_id => @time_entry.project} : params[:back_url]) return end - @activities = Enumeration::get_values('ACTI') end def destroy diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index 7fd70e74..2c1ae528 100644 --- a/app/helpers/timelog_helper.rb +++ b/app/helpers/timelog_helper.rb @@ -16,6 +16,14 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. module TimelogHelper + def activity_collection_for_select_options + activities = Enumeration::get_values('ACTI') + collection = [] + collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default) + activities.each { |a| collection << [a.name, a.id] } + collection + end + def select_hours(data, criteria, value) data.select {|row| row[criteria] == value} end diff --git a/app/views/issues/_edit.rhtml b/app/views/issues/_edit.rhtml index 49f198a6..914f7b9c 100644 --- a/app/views/issues/_edit.rhtml +++ b/app/views/issues/_edit.rhtml @@ -21,7 +21,7 @@

<%= time_entry.text_field :hours, :size => 6, :label => :label_spent_time %> <%= l(:field_hours) %>

-

<%= time_entry.select :activity_id, (@activities.collect {|p| [p.name, p.id]}) %>

+

<%= time_entry.select :activity_id, activity_collection_for_select_options %>

<%= time_entry.text_field :comments, :size => 60 %>

<% end %> diff --git a/app/views/timelog/edit.rhtml b/app/views/timelog/edit.rhtml index f9dae8a9..7e8cc459 100644 --- a/app/views/timelog/edit.rhtml +++ b/app/views/timelog/edit.rhtml @@ -9,7 +9,7 @@

<%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %>

<%= f.text_field :hours, :size => 6, :required => true %>

<%= f.text_field :comments, :size => 100 %>

-

<%= f.select :activity_id, (@activities.collect {|p| [p.name, p.id]}), :required => true %>

+

<%= f.select :activity_id, activity_collection_for_select_options, :required => true %>

<%= submit_tag l(:button_save) %> -- 2.11.0