OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[49409] Update UI to allow marking a status as excluded from totals
Christophe Bliard4b5292de3f30
diff --git a/app/components/statuses/row_component.rb b/app/components/statuses/row_component.rbindex 8c2f1d8d6b6..0533192cbb8 100644--- a/app/components/statuses/row_component.rb+++ b/app/components/statuses/row_component.rb@@ -50,6 +50,10 @@ module Statusescheckmark(status.is_readonly?)end+ def excluded_from_totals?+ checkmark(status.excluded_from_totals?)+ end+def colorhelpers.icon_for_color status.colorenddiff --git a/app/components/statuses/table_component.rb b/app/components/statuses/table_component.rbindex b0c5dbadf55..240cf1490e5 100644--- a/app/components/statuses/table_component.rb+++ b/app/components/statuses/table_component.rb@@ -60,9 +60,10 @@ module Statuses[:name, { caption: Status.human_attribute_name(:name) }],[:color, { caption: Status.human_attribute_name(:color) }],[:done_ratio, { caption: WorkPackage.human_attribute_name(:done_ratio) }],- [:default?, { caption: Status.human_attribute_name(:is_default) }],- [:closed?, { caption: Status.human_attribute_name(:is_closed) }],- [:readonly?, { caption: Status.human_attribute_name(:is_readonly) }],+ [:default?, { caption: I18n.t("statuses.index.headers.is_default") }],+ [:closed?, { caption: I18n.t("statuses.index.headers.is_closed") }],+ [:readonly?, { caption: I18n.t("statuses.index.headers.is_readonly") }],+ [:excluded_from_totals?, { caption: I18n.t("statuses.index.headers.excluded_from_totals") }],[:sort, { caption: I18n.t(:label_sort) }]]enddiff --git a/app/controllers/statuses_controller.rb b/app/controllers/statuses_controller.rbindex 53f549af30b..691ee4bf271 100644--- a/app/controllers/statuses_controller.rb+++ b/app/controllers/statuses_controller.rb@@ -61,7 +61,7 @@ class StatusesController < ApplicationControllerdef update@status = Status.find(params[:id])if @status.update(permitted_params.status)- apply_status_p_complete_change+ recompute_progress_valuesflash[:notice] = I18n.t(:notice_successful_update)redirect_to action: "index"else@@ -97,6 +97,11 @@ class StatusesController < ApplicationControllertrueend+ def recompute_progress_values+ apply_status_p_complete_change+ apply_status_excluded_from_totals_change+ end+def apply_status_p_complete_changereturn unless WorkPackage.use_status_for_done_ratio?return unless @status.default_done_ratio_previously_changed?@@ -107,4 +112,14 @@ class StatusesController < ApplicationControllerstatus_id: @status.id,change: @status.default_done_ratio_previous_change)end++ def apply_status_excluded_from_totals_change+ return unless @status.excluded_from_totals_previously_changed?++ WorkPackages::Progress::ApplyStatusesChangeJob+ .perform_later(cause_type: "status_excluded_from_totals_changed",+ status_name: @status.name,+ status_id: @status.id,+ change: @status.excluded_from_totals_previous_change)+ endenddiff --git a/app/models/permitted_params.rb b/app/models/permitted_params.rbindex c768af525dd..d7a6eda9347 100644--- a/app/models/permitted_params.rb+++ b/app/models/permitted_params.rb@@ -596,6 +596,7 @@ class PermittedParamsnamecolor_iddefault_done_ratio+ excluded_from_totalsis_closedis_defaultis_readonlydiff --git a/app/views/statuses/_form.html.erb b/app/views/statuses/_form.html.erbindex 6122dec98b7..d2e43dab859 100644--- a/app/views/statuses/_form.html.erb+++ b/app/views/statuses/_form.html.erb@@ -34,6 +34,7 @@ See COPYRIGHT and LICENSE files for more details.<div class="form--field"><%= f.select :default_done_ratio,(0..100).step(10).map { |r| ["#{r} %", r] },+ { container_class: "-xslim" },label: WorkPackage.human_attribute_name(:done_ratio) %></div><div class="form--field"><%= f.check_box "is_closed" %></div>@@ -63,6 +64,13 @@ See COPYRIGHT and LICENSE files for more details.<% end %></div>+ <div class="form--field">+ <%= f.check_box "excluded_from_totals" %>+ <div class="form--field-instructions">+ <p><%= t("statuses.edit.status_excluded_from_totals_text") %></p>+ </div>+ </div>+<%= render partial: "/colors/color_autocomplete_field",locals: {form: f,diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 169751efa9c..c9402466916 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -478,12 +478,20 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}No attributes can be changed with the exception of the status.<br/><strong>Note</strong>: Inherited values (e.g., from children or relations) will still apply.+ status_excluded_from_totals_text: |-+ Check this option to exclude work packages with this status from totals of Work,+ Remaining work, and % Complete in a hierarchy.status_color_text: |Click to assign or change the color of this status.It is shown in the status button and can be used for highlighting work packages in the table.index:no_results_title_text: There are currently no work package statuses.no_results_content_text: Add a new status+ headers:+ is_default: "Default"+ is_closed: "Closed"+ is_readonly: "Read-only"+ excluded_from_totals: "Excluded from totals"themes:light: "Light"@@ -676,6 +684,7 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}status:is_closed: "Work package closed"is_readonly: "Work package read-only"+ excluded_from_totals: "Exclude from calculation of totals in hierarchy"journal:notes: "Notes"member:diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rbindex d0cf513f71f..d3e446f269f 100644--- a/spec/controllers/statuses_controller_spec.rb+++ b/spec/controllers/statuses_controller_spec.rb@@ -180,7 +180,40 @@ RSpec.describe StatusesController doendend- context "when changing something else than the default % complete" do+ context "when marking a status as excluded from totals calculations" do+ before_all do+ status.update_columns(name: "Rejected",+ default_done_ratio: 70)+ end++ shared_let(:status_new) { create(:status, name: "New", default_done_ratio: "0") }+ shared_let_work_packages(<<~TABLE)+ hierarchy | status | work | remaining work | % complete | ∑ work | ∑ remaining work | ∑ % complete+ parent | New | | | | 20h | 16h | 20%+ child | Rejected | 10h | 3h | 70% | | |+ other child | New | 10h | 10h | 0% | | |+ TABLE++ let(:status_params) { { excluded_from_totals: true } }++ it "starts a job to update totals of work packages having excluded children" do+ expect(status.reload).to have_attributes(excluded_from_totals: true)+ expect(WorkPackages::Progress::ApplyStatusesChangeJob)+ .to have_been_enqueued.with(cause_type: "status_excluded_from_totals_changed",+ status_name: status.name,+ status_id: status.id,+ change: [false, true])++ perform_enqueued_jobs++ expect(parent.reload.read_attribute(:derived_estimated_hours)).to eq(10)+ expect(parent.reload.read_attribute(:derived_remaining_hours)).to eq(10)+ expect(parent.reload.read_attribute(:derived_done_ratio)).to eq(0)+ expect(parent.last_journal.details["cause"].last).to include("type" => "status_excluded_from_totals_changed")+ end+ end++ context "when changing something else than default % complete or exclude from totals" dolet(:status_params) { { name: "Another status name" } }it "does not start any jobs" do