##// END OF EJS Templates
Adds custom fields on time entries (#772)....
Jean-Philippe Lang -
r1672:898fac293b3d
parent child
Show More
@@ -0,0 +1,23
1 # redMine - project management software
2 # Copyright (C) 2008 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 class TimeEntryCustomField < CustomField
19 def type_name
20 :label_spent_time
21 end
22 end
23
@@ -39,6 +39,8 class CustomFieldsController < ApplicationController
39 @custom_field = UserCustomField.new(params[:custom_field])
39 @custom_field = UserCustomField.new(params[:custom_field])
40 when "ProjectCustomField"
40 when "ProjectCustomField"
41 @custom_field = ProjectCustomField.new(params[:custom_field])
41 @custom_field = ProjectCustomField.new(params[:custom_field])
42 when "TimeEntryCustomField"
43 @custom_field = TimeEntryCustomField.new(params[:custom_field])
42 else
44 else
43 redirect_to :action => 'list'
45 redirect_to :action => 'list'
44 return
46 return
@@ -160,6 +160,7 class IssuesController < ApplicationController
160 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
160 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
161 @priorities = Enumeration::get_values('IPRI')
161 @priorities = Enumeration::get_values('IPRI')
162 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
162 @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
163 @time_entry = TimeEntry.new
163
164
164 @notes = params[:notes]
165 @notes = params[:notes]
165 journal = @issue.init_journal(User.current, @notes)
166 journal = @issue.init_journal(User.current, @notes)
@@ -19,6 +19,7 module CustomFieldsHelper
19
19
20 def custom_fields_tabs
20 def custom_fields_tabs
21 tabs = [{:name => 'IssueCustomField', :label => :label_issue_plural},
21 tabs = [{:name => 'IssueCustomField', :label => :label_issue_plural},
22 {:name => 'TimeEntryCustomField', :label => :label_spent_time},
22 {:name => 'ProjectCustomField', :label => :label_project_plural},
23 {:name => 'ProjectCustomField', :label => :label_project_plural},
23 {:name => 'UserCustomField', :label => :label_user_plural}
24 {:name => 'UserCustomField', :label => :label_user_plural}
24 ]
25 ]
@@ -25,6 +25,7 class TimeEntry < ActiveRecord::Base
25
25
26 attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
26 attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
27
27
28 acts_as_customizable
28 acts_as_event :title => Proc.new {|o| "#{o.user}: #{lwr(:label_f_hour, o.hours)} (#{(o.issue || o.project).event_title})"},
29 acts_as_event :title => Proc.new {|o| "#{o.user}: #{lwr(:label_f_hour, o.hours)} (#{(o.issue || o.project).event_title})"},
29 :url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project}},
30 :url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project}},
30 :author => :user,
31 :author => :user,
@@ -105,6 +105,9 when "IssueCustomField" %>
105 <% when "ProjectCustomField" %>
105 <% when "ProjectCustomField" %>
106 <p><%= f.check_box :is_required %></p>
106 <p><%= f.check_box :is_required %></p>
107
107
108 <% when "TimeEntryCustomField" %>
109 <p><%= f.check_box :is_required %></p>
110
108 <% end %>
111 <% end %>
109 </div>
112 </div>
110 <%= javascript_tag "toggle_custom_field_format();" %>
113 <%= javascript_tag "toggle_custom_field_format();" %>
@@ -25,6 +25,9
25 <p><%= time_entry.select :activity_id, activity_collection_for_select_options %></p>
25 <p><%= time_entry.select :activity_id, activity_collection_for_select_options %></p>
26 </div>
26 </div>
27 <p><%= time_entry.text_field :comments, :size => 60 %></p>
27 <p><%= time_entry.text_field :comments, :size => 60 %></p>
28 <% @time_entry.custom_field_values.each do |value| %>
29 <p><%= custom_field_tag_with_label :time_entry, value %></p>
30 <% end %>
28 <% end %>
31 <% end %>
29 </fieldset>
32 </fieldset>
30 <% end %>
33 <% end %>
@@ -10,6 +10,9
10 <p><%= f.text_field :hours, :size => 6, :required => true %></p>
10 <p><%= f.text_field :hours, :size => 6, :required => true %></p>
11 <p><%= f.text_field :comments, :size => 100 %></p>
11 <p><%= f.text_field :comments, :size => 100 %></p>
12 <p><%= f.select :activity_id, activity_collection_for_select_options, :required => true %></p>
12 <p><%= f.select :activity_id, activity_collection_for_select_options, :required => true %></p>
13 <% @time_entry.custom_field_values.each do |value| %>
14 <p><%= custom_field_tag_with_label :time_entry, value %></p>
15 <% end %>
13 </div>
16 </div>
14
17
15 <%= submit_tag l(:button_save) %>
18 <%= submit_tag l(:button_save) %>
General Comments 0
You need to be logged in to leave comments. Login now