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
Recompute remaining work when cleared and work is set again
Christophe Bliarda09b683d5104
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/progress/touched-field-marker.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/progress/touched-field-marker.controller.tsindex d458b0a60e0..5b8414b427e 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/progress/touched-field-marker.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/progress/touched-field-marker.controller.ts@@ -78,12 +78,16 @@ export default class TouchedFieldMarkerController extends Controller {} else {this.markUntouched('remaining_hours');}+ } else if (this.isTouchedAndEmpty('remaining_hours') && this.isValueSet('done_ratio')) {+ // force remaining work derivation+ this.markUntouched('remaining_hours');+ this.markTouched('done_ratio');}}private untouchFieldsWhenRemainingWorkIsEdited() {- if (this.isValueEmpty('estimated_hours') && this.isTouched('estimated_hours') && this.isValueSet('done_ratio')) {- // force work recalculation+ if (this.isTouchedAndEmpty('estimated_hours') && this.isValueSet('done_ratio')) {+ // force work derivationthis.markUntouched('estimated_hours');this.markTouched('done_ratio');} else if (this.isValueSet('estimated_hours')) {@@ -131,6 +135,10 @@ export default class TouchedFieldMarkerController extends Controller {(input.name === fieldName) || (input.name === `work_package[${fieldName}]`));}+ private isTouchedAndEmpty(fieldName:string) {+ return this.isTouched(fieldName) && this.isValueEmpty(fieldName);+ }+private isTouched(fieldName:string) {const touchedInput = this.findTouchedInput(fieldName);return touchedInput?.value === 'true';diff --git a/spec/features/work_packages/progress_modal_spec.rb b/spec/features/work_packages/progress_modal_spec.rbindex cbe7e512607..8ab1ffc0a17 100644--- a/spec/features/work_packages/progress_modal_spec.rb+++ b/spec/features/work_packages/progress_modal_spec.rb@@ -496,6 +496,22 @@ RSpec.describe "Progress modal", :js, :with_cuprite,# work is derivedprogress_popover.expect_values(work: "20h", remaining_work: "8h", percent_complete: "60%")end++ # scenario from https://community.openproject.org/wp/57370+ specify "Case 6: when remaining work is cleared, and work is set, " \+ "then remaining work is derived again" do+ visit_progress_query_displaying_work_package++ progress_popover.open+ # clear work+ progress_popover.set_values(remaining_work: "")+ progress_popover.expect_values(work: "", remaining_work: "", percent_complete: "60%")++ # set remaining work+ progress_popover.set_values(work: "20h")+ # work is derived+ progress_popover.expect_values(work: "20h", remaining_work: "8h", percent_complete: "60%")+ endendcontext "given work, remaining work, and % complete are all empty" do