From 5c9b07654de750ed8a57ae3dde3e8a64b150ff73 Mon Sep 17 00:00:00 2001 From: Timo Uhlmann Date: Mon, 7 Sep 2015 10:48:21 +0200 Subject: Add is_quota to issue --- app/models/issue.rb | 1 + db/migrate/20150907080738_add_is_quota_to_issue.rb | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 db/migrate/20150907080738_add_is_quota_to_issue.rb diff --git a/app/models/issue.rb b/app/models/issue.rb index c7ad2a0..917265f 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -395,6 +395,7 @@ class Issue < ActiveRecord::Base 'due_date', 'done_ratio', 'estimated_hours', + 'is_quota', 'custom_field_values', 'custom_fields', 'lock_version', diff --git a/db/migrate/20150907080738_add_is_quota_to_issue.rb b/db/migrate/20150907080738_add_is_quota_to_issue.rb new file mode 100644 index 0000000..4f43e52 --- /dev/null +++ b/db/migrate/20150907080738_add_is_quota_to_issue.rb @@ -0,0 +1,5 @@ +class AddIsQuotaToIssue < ActiveRecord::Migration + def change + add_column :issues, :is_quota, :boolean + end +end -- 2.4.1 From 334e05ba6c510390451c2209fa4edebd15002686 Mon Sep 17 00:00:00 2001 From: Timo Uhlmann Date: Mon, 7 Sep 2015 10:52:29 +0200 Subject: Added is_quota field to issues/_attributes --- app/views/issues/_attributes.html.erb | 4 ++++ config/locales/en.yml | 1 + 2 files changed, 5 insertions(+) diff --git a/app/views/issues/_attributes.html.erb b/app/views/issues/_attributes.html.erb index 3d5f85c..21b6949 100644 --- a/app/views/issues/_attributes.html.erb +++ b/app/views/issues/_attributes.html.erb @@ -64,6 +64,10 @@

<%= f.text_field :estimated_hours, :size => 3, :required => @issue.required_attribute?('estimated_hours') %> <%= l(:field_hours) %>

<% end %> +<% if @issue.safe_attribute? 'is_quota' %> +

<%= f.check_box :is_quota %>

+<% end %> + <% if @issue.safe_attribute?('done_ratio') && Issue.use_field_for_done_ratio? %>

<%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }), :required => @issue.required_attribute?('done_ratio') %>

<% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 56f9cac..ce8373c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -307,6 +307,7 @@ en: field_assignable: Issues can be assigned to this role field_redirect_existing_links: Redirect existing links field_estimated_hours: Estimated time + field_is_quota: Quota issue field_column_names: Columns field_time_entries: Log time field_time_zone: Time zone -- 2.4.1 From 44c73487e809dff03d65a98a983904ccd76edead Mon Sep 17 00:00:00 2001 From: Timo Uhlmann Date: Mon, 7 Sep 2015 10:52:53 +0200 Subject: total_estimated_hours for quota issues --- app/helpers/issues_helper.rb | 2 +- app/models/issue.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index d803df0..db2bf36 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -119,7 +119,7 @@ module IssuesHelper l_hours_short(issue.estimated_hours) else s = issue.estimated_hours.present? ? l_hours_short(issue.estimated_hours) : "" - s << " (#{l(:label_total)}: #{l_hours_short(issue.total_estimated_hours)})" + s << " (#{l(issue.is_quota? ? :label_subtask_plural : :label_total)}: #{l_hours_short(issue.total_estimated_hours)})" s.html_safe end end diff --git a/app/models/issue.rb b/app/models/issue.rb index 917265f..4152808 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -941,7 +941,8 @@ class Issue < ActiveRecord::Base if leaf? estimated_hours else - @total_estimated_hours ||= self_and_descendants.sum(:estimated_hours) + targets = is_quota? ? descendants : self_and_descendants + @total_estimated_hours ||= targets.sum(:estimated_hours) end end @@ -1194,7 +1195,7 @@ class Issue < ActiveRecord::Base end def done_ratio_derived? - !leaf? && Setting.parent_issue_done_ratio == 'derived' + !leaf? || is_quota? && Setting.parent_issue_done_ratio == 'derived' end def <=>(issue) -- 2.4.1 From fa2775db6e1fc5e0aad6140e3ffbe8843af1e5c2 Mon Sep 17 00:00:00 2001 From: Timo Uhlmann Date: Mon, 7 Sep 2015 10:57:36 +0200 Subject: Added is_quota for :de locale. Not a 1:1 translation, still unsure about the naming --- config/locales/de.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/config/locales/de.yml b/config/locales/de.yml index dd40e4f..a1e9a04 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -307,6 +307,7 @@ de: field_editable: Bearbeitbar field_effective_date: Datum field_estimated_hours: Geschätzter Aufwand + field_is_quota: Soll-Aufwand field_field_format: Format field_filename: Datei field_filesize: Größe -- 2.4.1