summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-12 23:09:18 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-01-12 23:09:18 +0000
commit04eefdc809b0a85ac83e6fe57f6153eeac333da1 (patch)
tree1aa11a5c3ca5a1ab58bb5de709e400d7740a893c /app
parent82d96258f4418f567ebe5314f3d51c82d15efc8d (diff)
downloadredmine-04eefdc809b0a85ac83e6fe57f6153eeac333da1.tar.gz
redmine-04eefdc809b0a85ac83e6fe57f6153eeac333da1.zip
Adds settings to make the issue and/or comment fields mandatory for time logs (#24577).
Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@16176 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/settings_helper.rb1
-rw-r--r--app/models/time_entry.rb2
-rw-r--r--app/views/settings/_timelog.html.erb10
-rw-r--r--app/views/timelog/_form.html.erb4
4 files changed, 15 insertions, 2 deletions
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index 1bba0f9fa..3736715ba 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -25,6 +25,7 @@ module SettingsHelper
{:name => 'api', :partial => 'settings/api', :label => :label_api},
{:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural},
{:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
+ {:name => 'timelog', :partial => 'settings/timelog', :label => :label_time_tracking},
{:name => 'attachments', :partial => 'settings/attachments', :label => :label_attachment_plural},
{:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification},
{:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails},
diff --git a/app/models/time_entry.rb b/app/models/time_entry.rb
index 431c1a554..09fcfa8a0 100644
--- a/app/models/time_entry.rb
+++ b/app/models/time_entry.rb
@@ -38,6 +38,8 @@ class TimeEntry < ActiveRecord::Base
:scope => joins(:project).preload(:project)
validates_presence_of :user_id, :activity_id, :project_id, :hours, :spent_on
+ validates_presence_of :issue_id, :if => lambda { Setting.timelog_required_fields.include?('issue_id') }
+ validates_presence_of :comments, :if => lambda { Setting.timelog_required_fields.include?('comments') }
validates_numericality_of :hours, :allow_nil => true, :message => :invalid
validates_length_of :comments, :maximum => 1024, :allow_nil => true
validates :spent_on, :date => true
diff --git a/app/views/settings/_timelog.html.erb b/app/views/settings/_timelog.html.erb
new file mode 100644
index 000000000..4f922011b
--- /dev/null
+++ b/app/views/settings/_timelog.html.erb
@@ -0,0 +1,10 @@
+<%= form_tag({:action => 'edit', :tab => 'timelog'}) do %>
+
+<div class="box tabular settings">
+<p><%= setting_multiselect(:timelog_required_fields,
+ [[l(:field_issue), 'issue_id'], [l(:field_comments), 'comments'] ]) %></p>
+
+</div>
+
+<%= submit_tag l(:button_save) %>
+<% end %>
diff --git a/app/views/timelog/_form.html.erb b/app/views/timelog/_form.html.erb
index 712c7bde7..2d1134c4c 100644
--- a/app/views/timelog/_form.html.erb
+++ b/app/views/timelog/_form.html.erb
@@ -12,14 +12,14 @@
<% end %>
<% end %>
<p>
- <%= f.text_field :issue_id, :size => 6 %>
+ <%= f.text_field :issue_id, :size => 6, :required => Setting.timelog_required_fields.include?('issue_id') %>
<span id="time_entry_issue">
<%= link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>
</span>
</p>
<p><%= f.date_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
<p><%= f.hours_field :hours, :size => 6, :required => true %></p>
- <p><%= f.text_field :comments, :size => 100, :maxlength => 1024 %></p>
+ <p><%= f.text_field :comments, :size => 100, :maxlength => 1024, :required => Setting.timelog_required_fields.include?('comments') %></p>
<p><%= f.select :activity_id, activity_collection_for_select_options(@time_entry), :required => true %></p>
<% @time_entry.custom_field_values.each do |value| %>
<p><%= custom_field_tag_with_label :time_entry, value %></p>