helper :sort
include SortHelper
include IssuesHelper
+ helper :timelog
def index
sort_init "#{Issue.table_name}.id", "desc"
@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|
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)
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
# 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
<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 %>
<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