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
recreate order for wp with delta 0
ulfertse2b375fb57b3
diff --git a/frontend/src/app/modules/common/drag-and-drop/reorder-delta-builder.spec.ts b/frontend/src/app/modules/common/drag-and-drop/reorder-delta-builder.spec.tsindex ff9c05544ab..083cc4a7972 100644--- a/frontend/src/app/modules/common/drag-and-drop/reorder-delta-builder.spec.ts+++ b/frontend/src/app/modules/common/drag-and-drop/reorder-delta-builder.spec.ts@@ -40,14 +40,17 @@ describe('ReorderDeltaBuilder', () => {wpId:string,positions:QueryOrder,wps:string[] = work_packages,- fromIndex:number|null = null) {+ fromIndex:number|null = null,+ toIndex:number|null = null) {// As work_packages is already the list with moved element, simply compute the index- let index:number = work_packages.indexOf(wpId);+ if (!toIndex) {+ toIndex = work_packages.indexOf(wpId);- if (index === -1) {- throw "Invalid wpId given for work_packages, must be contained.";+ if (toIndex === -1) {+ throw "Invalid wpId given for work_packages, must be contained.";+ }}- return new ReorderDeltaBuilder(wps, positions, wpId, index, fromIndex).buildDelta();+ return new ReorderDeltaBuilder(wps, positions, wpId, toIndex, fromIndex).buildDelta();}it('Empty, inserting at beginning sets the delta for wpId 1 to the default value', () => {@@ -263,6 +266,20 @@ describe('ReorderDeltaBuilder', () => {});});+ it('reorders on incomplete positions information and moving the first (0 positioned) work package', () => {+ // This can happen if a query is saved and the filters on it changed later on so that+ // additional work packages are now present.+ let delta = buildDelta('1', { '1': 0, '5': 8196 }, ['2', '3', '4', '1', '5'], 0, 3);++ expect(delta).toEqual({+ '2': 0,+ '3': 2049,+ '4': 4098,+ '1': 6147,+ '5': 8196+ });+ });+// It will reassign default orders when not in ascending order and min/max not sufficient});diff --git a/frontend/src/app/modules/common/drag-and-drop/reorder-delta-builder.ts b/frontend/src/app/modules/common/drag-and-drop/reorder-delta-builder.tsindex 1cf7a6b0257..04b094c7271 100644--- a/frontend/src/app/modules/common/drag-and-drop/reorder-delta-builder.ts+++ b/frontend/src/app/modules/common/drag-and-drop/reorder-delta-builder.ts@@ -231,7 +231,8 @@ export class ReorderDeltaBuilder {* @param wpId*/private livePosition(wpId:string):number|undefined {- return this.delta[wpId] || this.positions[wpId];+ // Explicitly check for undefined here as the delta might be 0 which is falsey.+ return this.delta[wpId] === undefined ? this.positions[wpId] : this.delta[wpId];}/**