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
[30994] Update empty changesets to match the latest resource
Oliver Günther5a9c08036d18
diff --git a/frontend/src/app/components/wp-edit-form/work-package-changeset.ts b/frontend/src/app/components/wp-edit-form/work-package-changeset.tsindex 9b70c1ae53d..2cd6c67762c 100644--- a/frontend/src/app/components/wp-edit-form/work-package-changeset.ts+++ b/frontend/src/app/components/wp-edit-form/work-package-changeset.ts@@ -175,6 +175,7 @@ export class WorkPackageChangeset extends EditChangeset<WorkPackageResource> {this.wpCacheService.loadWorkPackage(this.resource.parent.id.toString(), true);}this.clear();+ this.wpEditing.stopEditing(this.resource.id!);resolve(this.resource);});})diff --git a/frontend/src/app/components/wp-edit-form/work-package-editing-service.ts b/frontend/src/app/components/wp-edit-form/work-package-editing-service.tsindex 1528fed820e..c8ca40866ac 100644--- a/frontend/src/app/components/wp-edit-form/work-package-editing-service.ts+++ b/frontend/src/app/components/wp-edit-form/work-package-editing-service.ts@@ -69,13 +69,17 @@ export class WorkPackageEditingService extends StateCacheService<WorkPackageChanconst wpId = oldReference.id!;const workPackage = this.wpCacheService.state(wpId).getValueOr(oldReference);const state = this.multiState.get(wpId);-- if (state.isPristine()) {- state.putValue(new WorkPackageChangeset(this.injector, workPackage));+ let changeset = state.value;++ // If there is no changeset, or+ // If there is an empty one for a older work package reference+ // build a new changeset+ if (!changeset || (changeset.empty && changeset.resource.lockVersion < workPackage.lockVersion)) {+ changeset = new WorkPackageChangeset(this.injector, workPackage)+ state.putValue(changeset);+ return changeset;}- const changeset = state.value!;-return changeset;}@@ -109,10 +113,7 @@ export class WorkPackageEditingService extends StateCacheService<WorkPackageChan}public stopEditing(workPackageId:string) {- const state = this.multiState.get(workPackageId);- if (state && state.value) {- state.value.clear();- }+ this.multiState.get(workPackageId).clear();}protected load(id:string) {diff --git a/frontend/src/app/components/wp-edit-form/work-package-editing.service.interface.ts b/frontend/src/app/components/wp-edit-form/work-package-editing.service.interface.tsindex f1ad30bcdec..5479e1322b1 100644--- a/frontend/src/app/components/wp-edit-form/work-package-editing.service.interface.ts+++ b/frontend/src/app/components/wp-edit-form/work-package-editing.service.interface.ts@@ -38,6 +38,7 @@ export const IWorkPackageEditingServiceToken = new InjectionToken<IWorkPackageEd*/export interface IWorkPackageEditingService {updateValue(id:string, changeset:any):void;+ stopEditing(id:string):void;changesetFor(wp:WorkPackageResource):WorkPackageChangeset;}diff --git a/spec/features/work_packages/table/hierarchy/hierarchy_indent_spec.rb b/spec/features/work_packages/table/hierarchy/hierarchy_indent_spec.rbindex 8d0209e37a1..bf1afa73875 100644--- a/spec/features/work_packages/table/hierarchy/hierarchy_indent_spec.rb+++ b/spec/features/work_packages/table/hierarchy/hierarchy_indent_spec.rb@@ -87,4 +87,38 @@ describe 'Work Package table hierarchy and sorting', js: true dohierarchy.expect_indent(wp_child2, indent: false, outdent: false)hierarchy.expect_indent(wp_child3, indent: false, outdent: false)end++ it 'can edit a work package, then indent, and then edit again (Regression #30994)' do+ wp_table.visit!+ wp_table.expect_work_package_listed(wp_root, wp_child1, wp_child2, wp_child3)+ hierarchy.expect_hierarchy_at(wp_root)+ hierarchy.expect_leaf_at(wp_child1, wp_child2, wp_child3)++ subject = wp_table.edit_field(wp_child3, :subject)+ subject.update 'First edit'+ wp_table.expect_and_dismiss_notification message: 'Successful update.'++ # Wait a bit before moving+ sleep 2++ # Indent last child+ hierarchy.indent! wp_child3+ wp_table.expect_and_dismiss_notification message: 'Successful update.'++ # Expect changed+ hierarchy.expect_hierarchy_at(wp_root, wp_child2)+ hierarchy.expect_leaf_at(wp_child1, wp_child3)++ # Wait a bit again+ sleep 2++ subject = wp_table.edit_field(wp_child3, :subject)+ subject.update 'Second edit'+ wp_table.expect_and_dismiss_notification message: 'Successful update.'++ sleep 2+ wp_child3.reload+ expect(wp_child3.subject).to eq 'Second edit'+ expect(wp_child3.parent).to eq wp_child2+ endend