]> source.dussan.org Git - redmine.git/commitdiff
Addq "please select" to activity select box if no activity is set as default (#937).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 29 Jun 2008 12:01:20 +0000 (12:01 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 29 Jun 2008 12:01:20 +0000 (12:01 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1602 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/issues_controller.rb
app/controllers/timelog_controller.rb
app/helpers/timelog_helper.rb
app/views/issues/_edit.rhtml
app/views/timelog/edit.rhtml

index 49b443238c4978b53f4673a1a1ff00297ab680b4..5bc65d2e4a99ca675aebabc5a2770abc1a437b14 100644 (file)
@@ -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)
     
index cf1c844df463ec408947a2f1b974e4dc14ff2249..9f539d459921d5b37edf6fc0541ee34e4610694f 100644 (file)
@@ -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
index 7fd70e744071ed627d8ccc66000b329348059cce..2c1ae5285fe9129988408bd7132efb83719b5d60 100644 (file)
 # 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
index 49f198a63629b2fb79b3e900739f91ddd7e17da0..914f7b9c4d26d046d15848f130d36083e37d7cdf 100644 (file)
@@ -21,7 +21,7 @@
         <p><%= time_entry.text_field :hours, :size => 6, :label => :label_spent_time %> <%= l(:field_hours) %></p>
         </div>
         <div class="splitcontentright">
-        <p><%= time_entry.select :activity_id, (@activities.collect {|p| [p.name, p.id]}) %></p>
+        <p><%= time_entry.select :activity_id, activity_collection_for_select_options %></p>
         </div>
         <p><%= time_entry.text_field :comments, :size => 60 %></p>
         <% end %>
index f9dae8a991ef60901a9a78a26d9cd11b14144957..7e8cc4591d1288787d8404a127b1c137086b4cf3 100644 (file)
@@ -9,7 +9,7 @@
 <p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>\r
 <p><%= f.text_field :hours, :size => 6, :required => true %></p>\r
 <p><%= f.text_field :comments, :size => 100 %></p>\r
-<p><%= f.select :activity_id, (@activities.collect {|p| [p.name, p.id]}), :required => true %></p>\r
+<p><%= f.select :activity_id, activity_collection_for_select_options, :required => true %></p>\r
 </div>\r
 \r
 <%= submit_tag l(:button_save) %>\r