]> source.dussan.org Git - redmine.git/commitdiff
Adds custom fields on time entries (#772).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 22 Jul 2008 18:52:00 +0000 (18:52 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 22 Jul 2008 18:52:00 +0000 (18:52 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1689 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/custom_fields_controller.rb
app/controllers/issues_controller.rb
app/helpers/custom_fields_helper.rb
app/models/time_entry.rb
app/models/time_entry_custom_field.rb [new file with mode: 0644]
app/views/custom_fields/_form.rhtml
app/views/issues/_edit.rhtml
app/views/timelog/edit.rhtml

index 1e1c988d984047ab2b18721c295ca57a4a52023c..d30e89493c6047e8cd5a74df11effa3579f801fb 100644 (file)
@@ -39,6 +39,8 @@ class CustomFieldsController < ApplicationController
         @custom_field = UserCustomField.new(params[:custom_field])
       when "ProjectCustomField" 
         @custom_field = ProjectCustomField.new(params[:custom_field])
+      when "TimeEntryCustomField" 
+        @custom_field = TimeEntryCustomField.new(params[:custom_field])
       else
         redirect_to :action => 'list'
         return
index c0f31814b72c08165182a7a5249af0fce675b35a..c8edd172669185b99c774191a00f2a5ad1534270 100644 (file)
@@ -160,6 +160,7 @@ class IssuesController < ApplicationController
     @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
     @priorities = Enumeration::get_values('IPRI')
     @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
+    @time_entry = TimeEntry.new
     
     @notes = params[:notes]
     journal = @issue.init_journal(User.current, @notes)
index 3c795dc1fea67ba6f6ab505b4dc1948523edbe12..f61824e65bb0b06931d2c78c59485f04370df4d9 100644 (file)
@@ -19,6 +19,7 @@ module CustomFieldsHelper
 
   def custom_fields_tabs
     tabs = [{:name => 'IssueCustomField', :label => :label_issue_plural},
+            {:name => 'TimeEntryCustomField', :label => :label_spent_time},
             {:name => 'ProjectCustomField', :label => :label_project_plural},
             {:name => 'UserCustomField', :label => :label_user_plural}
             ]
index 759f9bed0dca4b5c06d13c481e59135d8cfd12dc..57a75604d677c1291d8def4ab9e0f1ad863e8544 100644 (file)
@@ -25,6 +25,7 @@ class TimeEntry < ActiveRecord::Base
   
   attr_protected :project_id, :user_id, :tyear, :tmonth, :tweek
 
+  acts_as_customizable
   acts_as_event :title => Proc.new {|o| "#{o.user}: #{lwr(:label_f_hour, o.hours)} (#{(o.issue || o.project).event_title})"},
                 :url => Proc.new {|o| {:controller => 'timelog', :action => 'details', :project_id => o.project}},
                 :author => :user,
diff --git a/app/models/time_entry_custom_field.rb b/app/models/time_entry_custom_field.rb
new file mode 100644 (file)
index 0000000..2ec3d27
--- /dev/null
@@ -0,0 +1,23 @@
+# redMine - project management software
+# Copyright (C) 2008  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+class TimeEntryCustomField < CustomField
+  def type_name
+    :label_spent_time
+  end
+end
+
index 5e4eadf21f713f924b1fb9225b37d2771dc319d7..f4aee68706fcf6b8105d52671e3b1943c236a5d1 100644 (file)
@@ -105,6 +105,9 @@ when "IssueCustomField" %>
 <% when "ProjectCustomField" %>
     <p><%= f.check_box :is_required %></p>
 
+<% when "TimeEntryCustomField" %>
+    <p><%= f.check_box :is_required %></p>
+
 <% end %>
 </div>
 <%= javascript_tag "toggle_custom_field_format();" %>
index ba59c3ae975d2d8667fd45bf673e3bba5168aeea..2c7a4286edafd37f09d67ce480419653d6eee38d 100644 (file)
@@ -25,6 +25,9 @@
         <p><%= time_entry.select :activity_id, activity_collection_for_select_options %></p>
         </div>
         <p><%= time_entry.text_field :comments, :size => 60 %></p>
+        <% @time_entry.custom_field_values.each do |value| %>
+               <p><%= custom_field_tag_with_label :time_entry, value %></p>
+        <% end %>
         <% end %>
     </fieldset>
     <% end %>
index 7e8cc4591d1288787d8404a127b1c137086b4cf3..0dd3503ec8d9d58030a0631e2f97c5444d989517 100644 (file)
@@ -10,6 +10,9 @@
 <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, activity_collection_for_select_options, :required => true %></p>\r
+<% @time_entry.custom_field_values.each do |value| %>\r
+       <p><%= custom_field_tag_with_label :time_entry, value %></p>\r
+<% end %>\r
 </div>\r
 \r
 <%= submit_tag l(:button_save) %>\r