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 work when cleared and remaining work is set again
Christophe Bliard7e5bfe1d60db
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 1e5b090bb89..d458b0a60e0 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@@ -45,14 +45,17 @@ export default class TouchedFieldMarkerController extends Controller {private markFieldAsTouched(event:{ target:HTMLInputElement }) {this.targetFieldName = event.target.name.replace(/^work_package\[([^\]]+)\]$/, '$1');- const touchedInput = this.findTouchedInput(this.targetFieldName);+ this.markTouched(this.targetFieldName);- if (touchedInput) {- touchedInput.value = 'true';+ if (this.isWorkBasedMode()) {this.keepWorkValue();}}+ private isWorkBasedMode() {+ return this.findValueInput('done_ratio') !== undefined;+ }+private keepWorkValue() {if (this.isInitialValueEmpty('estimated_hours') && !this.isTouched('estimated_hours')) {// let work be derived@@ -79,7 +82,11 @@ export default class TouchedFieldMarkerController extends Controller {}private untouchFieldsWhenRemainingWorkIsEdited() {- if (this.isValueSet('estimated_hours')) {+ if (this.isValueEmpty('estimated_hours') && this.isTouched('estimated_hours') && this.isValueSet('done_ratio')) {+ // force work recalculation+ this.markUntouched('estimated_hours');+ this.markTouched('done_ratio');+ } else if (this.isValueSet('estimated_hours')) {this.markUntouched('done_ratio');}}@@ -144,6 +151,13 @@ export default class TouchedFieldMarkerController extends Controller {return valueInput !== undefined && valueInput.value !== '';}+ private markTouched(fieldName:string) {+ const touchedInput = this.findTouchedInput(fieldName);+ if (touchedInput) {+ touchedInput.value = 'true';+ }+ }+private markUntouched(fieldName:string) {const touchedInput = this.findTouchedInput(fieldName);if (touchedInput) {diff --git a/spec/features/work_packages/progress_modal_spec.rb b/spec/features/work_packages/progress_modal_spec.rbindex 47f9f3f58b2..cbe7e512607 100644--- a/spec/features/work_packages/progress_modal_spec.rb+++ b/spec/features/work_packages/progress_modal_spec.rb@@ -480,6 +480,22 @@ RSpec.describe "Progress modal", :js, :with_cuprite,progress_popover.set_values(remaining_work: "9h")progress_popover.expect_values(work: "10h", percent_complete: "10%")end++ # scenario from https://community.openproject.org/wp/57370+ specify "Case 5: when work is cleared, and remaining work is set, " \+ "then work is derived again" do+ visit_progress_query_displaying_work_package++ progress_popover.open+ # clear work+ progress_popover.set_values(work: "")+ progress_popover.expect_values(work: "", remaining_work: "", percent_complete: "60%")++ # set remaining work+ progress_popover.set_values(remaining_work: "8h")+ # 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