summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-05-25 09:53:05 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-05-25 09:53:05 +0000
commit0ad09e3aef86d4e6c6784d5d906bfa6d1767757f (patch)
treec626a05d630f6529294dbf6a8065f17a235f3256 /app
parent09b935b44ed897afc3f0abcc614558bf6356b6ba (diff)
downloadredmine-0ad09e3aef86d4e6c6784d5d906bfa6d1767757f.tar.gz
redmine-0ad09e3aef86d4e6c6784d5d906bfa6d1767757f.zip
Adds settings to control start/due dates and priority on parent tasks (#5490).
git-svn-id: http://svn.redmine.org/redmine/trunk@14269 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/helpers/settings_helper.rb25
-rw-r--r--app/models/issue.rb57
-rw-r--r--app/views/issues/_attributes.html.erb10
-rw-r--r--app/views/settings/_issues.html.erb9
4 files changed, 76 insertions, 25 deletions
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index fcf8ec2e3..0dcdbb040 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -79,7 +79,12 @@ module SettingsHelper
def setting_label(setting, options={})
label = options.delete(:label)
- label != false ? label_tag("settings_#{setting}", l(label || "setting_#{setting}"), options[:label_options]).html_safe : ''
+ if label == false
+ ''
+ else
+ text = label.is_a?(String) ? label : l(label || "setting_#{setting}")
+ label_tag("settings_#{setting}", text, options[:label_options])
+ end
end
# Renders a notification field for a Redmine::Notifiable option
@@ -126,6 +131,24 @@ module SettingsHelper
options.map {|label, value| [l(label), value.to_s]}
end
+ def parent_issue_dates_options
+ options = [
+ [:label_parent_task_attributes_derived, 'derived'],
+ [:label_parent_task_attributes_independent, 'independent']
+ ]
+
+ options.map {|label, value| [l(label), value.to_s]}
+ end
+
+ def parent_issue_priority_options
+ options = [
+ [:label_parent_task_attributes_derived, 'derived'],
+ [:label_parent_task_attributes_independent, 'independent']
+ ]
+
+ options.map {|label, value| [l(label), value.to_s]}
+ end
+
# Returns the options for the date_format setting
def date_format_setting_options(locale)
Setting::DATE_FORMATS.map do |f|
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 9ea7f6c57..7d04d1e15 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -426,6 +426,15 @@ class Issue < ActiveRecord::Base
# Make sure that project_id can always be set for new issues
names |= %w(project_id)
end
+ if dates_derived?
+ names -= %w(start_date due_date)
+ end
+ if priority_derived?
+ names -= %w(priority_id)
+ end
+ unless leaf?
+ names -= %w(done_ratio estimated_hours)
+ end
names
end
@@ -463,10 +472,6 @@ class Issue < ActiveRecord::Base
attrs = delete_unsafe_attributes(attrs, user)
return if attrs.empty?
- unless leaf?
- attrs.reject! {|k,v| %w(priority_id done_ratio start_date due_date estimated_hours).include?(k)}
- end
-
if attrs['parent_issue_id'].present?
s = attrs['parent_issue_id'].to_s
unless (m = s.match(%r{\A#?(\d+)\z})) && (m[1] == parent_id.to_s || Issue.visible(user).exists?(m[1]))
@@ -1094,11 +1099,15 @@ class Issue < ActiveRecord::Base
end
def soonest_start(reload=false)
- @soonest_start = nil if reload
- @soonest_start ||= (
- relations_to(reload).collect{|relation| relation.successor_soonest_start} +
- [(@parent_issue || parent).try(:soonest_start)]
- ).compact.max
+ if @soonest_start.nil? || reload
+ dates = relations_to(reload).collect{|relation| relation.successor_soonest_start}
+ p = @parent_issue || parent
+ if p && Setting.parent_issue_dates == 'derived'
+ dates << p.soonest_start
+ end
+ @soonest_start = dates.compact.max
+ end
+ @soonest_start
end
# Sets start_date on the given date or the next working day
@@ -1114,7 +1123,7 @@ class Issue < ActiveRecord::Base
# If the issue is a parent task, this is done by rescheduling its subtasks.
def reschedule_on!(date)
return if date.nil?
- if leaf?
+ if leaf? || !dates_derived?
if start_date.nil? || start_date != date
if start_date && start_date > date
# Issue can not be moved earlier than its soonest start date
@@ -1144,6 +1153,14 @@ class Issue < ActiveRecord::Base
end
end
+ def dates_derived?
+ !leaf? && Setting.parent_issue_dates == 'derived'
+ end
+
+ def priority_derived?
+ !leaf? && Setting.parent_issue_priority == 'derived'
+ end
+
def <=>(issue)
if issue.nil?
-1
@@ -1430,16 +1447,20 @@ class Issue < ActiveRecord::Base
def recalculate_attributes_for(issue_id)
if issue_id && p = Issue.find_by_id(issue_id)
- # priority = highest priority of children
- if priority_position = p.children.joins(:priority).maximum("#{IssuePriority.table_name}.position")
- p.priority = IssuePriority.find_by_position(priority_position)
+ if p.priority_derived?
+ # priority = highest priority of children
+ if priority_position = p.children.joins(:priority).maximum("#{IssuePriority.table_name}.position")
+ p.priority = IssuePriority.find_by_position(priority_position)
+ end
end
- # start/due dates = lowest/highest dates of children
- p.start_date = p.children.minimum(:start_date)
- p.due_date = p.children.maximum(:due_date)
- if p.start_date && p.due_date && p.due_date < p.start_date
- p.start_date, p.due_date = p.due_date, p.start_date
+ if p.dates_derived?
+ # start/due dates = lowest/highest dates of children
+ p.start_date = p.children.minimum(:start_date)
+ p.due_date = p.children.maximum(:due_date)
+ if p.start_date && p.due_date && p.due_date < p.start_date
+ p.start_date, p.due_date = p.due_date, p.start_date
+ end
end
# done ratio = weighted average ratio of leaves
diff --git a/app/views/issues/_attributes.html.erb b/app/views/issues/_attributes.html.erb
index 61ffa8ae3..3d5f85c7b 100644
--- a/app/views/issues/_attributes.html.erb
+++ b/app/views/issues/_attributes.html.erb
@@ -48,25 +48,23 @@
<% if @issue.safe_attribute? 'start_date' %>
<p id="start_date_area">
- <%= f.text_field(:start_date, :size => 10, :disabled => !@issue.leaf?,
- :required => @issue.required_attribute?('start_date')) %>
+ <%= f.text_field(:start_date, :size => 10, :required => @issue.required_attribute?('start_date')) %>
<%= calendar_for('issue_start_date') if @issue.leaf? %>
</p>
<% end %>
<% if @issue.safe_attribute? 'due_date' %>
<p id="due_date_area">
- <%= f.text_field(:due_date, :size => 10, :disabled => !@issue.leaf?,
- :required => @issue.required_attribute?('due_date')) %>
+ <%= f.text_field(:due_date, :size => 10, :required => @issue.required_attribute?('due_date')) %>
<%= calendar_for('issue_due_date') if @issue.leaf? %>
</p>
<% end %>
<% if @issue.safe_attribute? 'estimated_hours' %>
-<p><%= f.text_field :estimated_hours, :size => 3, :disabled => !@issue.leaf?, :required => @issue.required_attribute?('estimated_hours') %> <%= l(:field_hours) %></p>
+<p><%= f.text_field :estimated_hours, :size => 3, :required => @issue.required_attribute?('estimated_hours') %> <%= l(:field_hours) %></p>
<% end %>
-<% if @issue.safe_attribute?('done_ratio') && @issue.leaf? && Issue.use_field_for_done_ratio? %>
+<% if @issue.safe_attribute?('done_ratio') && Issue.use_field_for_done_ratio? %>
<p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :required => @issue.required_attribute?('done_ratio') %></p>
<% end %>
</div>
diff --git a/app/views/settings/_issues.html.erb b/app/views/settings/_issues.html.erb
index c1e802238..a0dfd786c 100644
--- a/app/views/settings/_issues.html.erb
+++ b/app/views/settings/_issues.html.erb
@@ -23,6 +23,15 @@
</div>
<fieldset class="box">
+ <legend><%= l(:label_parent_task_attributes) %></legend>
+ <div class="tabular settings">
+ <p><%= setting_select :parent_issue_dates, parent_issue_dates_options, :label => "#{l(:field_start_date)} / #{l(:field_due_date)}" %></p>
+
+ <p><%= setting_select :parent_issue_priority, parent_issue_priority_options, :label => :field_priority %></p>
+ </div>
+</fieldset>
+
+<fieldset class="box">
<legend><%= l(:setting_issue_list_default_columns) %></legend>
<%= render_query_columns_selection(
IssueQuery.new(:column_names => Setting.issue_list_default_columns),