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
This commit is contained in:
Jean-Philippe Lang 2008-06-29 12:01:20 +00:00
parent 94cf4f258f
commit 1424b0f215
5 changed files with 11 additions and 5 deletions

View File

@ -43,6 +43,7 @@ class IssuesController < ApplicationController
helper :sort helper :sort
include SortHelper include SortHelper
include IssuesHelper include IssuesHelper
helper :timelog
def index def index
sort_init "#{Issue.table_name}.id", "desc" sort_init "#{Issue.table_name}.id", "desc"
@ -99,7 +100,6 @@ class IssuesController < ApplicationController
@journals.reverse! if User.current.wants_comments_in_reverse_order? @journals.reverse! if User.current.wants_comments_in_reverse_order?
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
@edit_allowed = User.current.allowed_to?(:edit_issues, @project) @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
@activities = Enumeration::get_values('ACTI')
@priorities = Enumeration::get_values('IPRI') @priorities = Enumeration::get_values('IPRI')
@time_entry = TimeEntry.new @time_entry = TimeEntry.new
respond_to do |format| respond_to do |format|
@ -157,7 +157,6 @@ class IssuesController < ApplicationController
def edit def edit
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
@activities = Enumeration::get_values('ACTI')
@priorities = Enumeration::get_values('IPRI') @priorities = Enumeration::get_values('IPRI')
@edit_allowed = User.current.allowed_to?(:edit_issues, @project) @edit_allowed = User.current.allowed_to?(:edit_issues, @project)

View File

@ -183,7 +183,6 @@ class TimelogController < ApplicationController
redirect_to(params[:back_url].blank? ? {:action => 'details', :project_id => @time_entry.project} : params[:back_url]) redirect_to(params[:back_url].blank? ? {:action => 'details', :project_id => @time_entry.project} : params[:back_url])
return return
end end
@activities = Enumeration::get_values('ACTI')
end end
def destroy def destroy

View File

@ -16,6 +16,14 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module TimelogHelper 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) def select_hours(data, criteria, value)
data.select {|row| row[criteria] == value} data.select {|row| row[criteria] == value}
end end

View File

@ -21,7 +21,7 @@
<p><%= time_entry.text_field :hours, :size => 6, :label => :label_spent_time %> <%= l(:field_hours) %></p> <p><%= time_entry.text_field :hours, :size => 6, :label => :label_spent_time %> <%= l(:field_hours) %></p>
</div> </div>
<div class="splitcontentright"> <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> </div>
<p><%= time_entry.text_field :comments, :size => 60 %></p> <p><%= time_entry.text_field :comments, :size => 60 %></p>
<% end %> <% end %>

View File

@ -9,7 +9,7 @@
<p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p> <p><%= f.text_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
<p><%= f.text_field :hours, :size => 6, :required => true %></p> <p><%= f.text_field :hours, :size => 6, :required => true %></p>
<p><%= f.text_field :comments, :size => 100 %></p> <p><%= f.text_field :comments, :size => 100 %></p>
<p><%= f.select :activity_id, (@activities.collect {|p| [p.name, p.id]}), :required => true %></p> <p><%= f.select :activity_id, activity_collection_for_select_options, :required => true %></p>
</div> </div>
<%= submit_tag l(:button_save) %> <%= submit_tag l(:button_save) %>