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
Use require for more work packages
Oliver Günther4ca38af86388
diff --git a/frontend/src/app/components/wp-card-view/services/wp-card-drag-and-drop.service.ts b/frontend/src/app/components/wp-card-view/services/wp-card-drag-and-drop.service.tsindex 10e3a847201..6d7a0b80349 100644--- a/frontend/src/app/components/wp-card-view/services/wp-card-drag-and-drop.service.ts+++ b/frontend/src/app/components/wp-card-view/services/wp-card-drag-and-drop.service.ts@@ -59,9 +59,9 @@ export class WorkPackageCardDragAndDropService {scrollContainers: [this.cardView.container.nativeElement],moves: (card:HTMLElement) => {const wpId:string = card.dataset.workPackageId!;- const workPackage = this.states.workPackages.get(wpId).value!;+ const workPackage = this.states.workPackages.get(wpId).value;- return this.cardView.canDragOutOf(workPackage) && !card.dataset.isNew;+ return !!workPackage && this.cardView.canDragOutOf(workPackage) && !card.dataset.isNew;},accepts: () => this.cardView.dragInto,onMoved: async (card:HTMLElement) => {@@ -83,7 +83,7 @@ export class WorkPackageCardDragAndDropService {const wpId:string = card.dataset.workPackageId!;const toIndex = DragAndDropHelpers.findIndex(card);- const workPackage = this.states.workPackages.get(wpId).value!;+ const workPackage = await this.wpCacheService.require(wpId);const result = await this.addWorkPackageToQuery(workPackage, toIndex);if (card.parentElement) {diff --git a/frontend/src/app/components/wp-fast-table/handlers/state/drag-and-drop-transformer.ts b/frontend/src/app/components/wp-fast-table/handlers/state/drag-and-drop-transformer.tsindex 7f3b2b83784..b310c2dfe50 100644--- a/frontend/src/app/components/wp-fast-table/handlers/state/drag-and-drop-transformer.ts+++ b/frontend/src/app/components/wp-fast-table/handlers/state/drag-and-drop-transformer.ts@@ -65,15 +65,15 @@ export class DragAndDropTransformer {}const wpId:string = el.dataset.workPackageId!;- const workPackage = this.states.workPackages.get(wpId).value!;- return this.actionService.canPickup(workPackage);+ const workPackage = this.states.workPackages.get(wpId).value;+ return !!workPackage && this.actionService.canPickup(workPackage);},onMoved: async (el:HTMLElement, target:HTMLElement, source:HTMLElement) => {const wpId:string = el.dataset.workPackageId!;- const workPackage = this.states.workPackages.get(wpId).value!;const rowIndex = this.findRowIndex(el);try {+ const workPackage = await this.wpCacheService.require(wpId);const newOrder = await this.wpTableOrder.move(this.currentOrder, wpId, rowIndex);await this.actionService.handleDrop(workPackage, el);this.updateRenderedOrder(newOrder);@@ -96,9 +96,9 @@ export class DragAndDropTransformer {const newOrder = this.wpTableOrder.remove(this.currentOrder, wpId);this.updateRenderedOrder(newOrder);},- onAdded: (el:HTMLElement) => {+ onAdded: async (el:HTMLElement) => {const wpId:string = el.dataset.workPackageId!;- const workPackage = this.states.workPackages.get(wpId).value!;+ const workPackage = await this.wpCacheService.require(wpId);const rowIndex = this.findRowIndex(el);return this.actionService@@ -112,10 +112,10 @@ export class DragAndDropTransformer {}).catch(() => false);},- onCloned: (clone:HTMLElement, original:HTMLElement) => {+ onCloned: async (clone:HTMLElement, original:HTMLElement) => {// Replace clone with one TD of the subjectconst wpId:string = original.dataset.workPackageId!;- const workPackage = this.states.workPackages.get(wpId).value!;+ const workPackage = await this.wpCacheService.require(wpId);const colspan = clone.children.length;const td = document.createElement('td');diff --git a/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy-indentation.service.spec.ts b/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy-indentation.service.spec.tsindex 33f7781daea..63702783093 100644--- a/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy-indentation.service.spec.ts+++ b/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy-indentation.service.spec.ts@@ -40,6 +40,9 @@ import {WorkPackageRelationsHierarchyService} from "core-components/wp-relationsimport {WorkPackageViewHierarchyIdentationService} from "core-app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy-indentation.service";import SpyObj = jasmine.SpyObj;import {WorkPackageResource} from "core-app/modules/hal/resources/work-package-resource";+import {WorkPackageCacheService} from "core-components/work-packages/work-package-cache.service";+import {SchemaCacheService} from "core-components/schemas/schema-cache.service";+import {WorkPackageDmService} from "core-app/modules/hal/dm-services/work-package-dm.service";describe('WorkPackageViewIndentation service', function() {let service:WorkPackageViewHierarchyIdentationService;@@ -54,6 +57,12 @@ describe('WorkPackageViewIndentation service', function() {}}+ class WorkPackageCacheServiceStub {+ require(wpId:string) {+ return Promise.resolve(states.workPackages.get(wpId).value);+ }+ }+beforeEach(async(() => {parentServiceSpy = jasmine.createSpyObj('WorkPackageRelationHierarchyService',@@ -67,6 +76,8 @@ describe('WorkPackageViewIndentation service', function() {providers: [States,IsolatedQuerySpace,+ WorkPackageCacheService,+ { provide: WorkPackageCacheService, useClass: WorkPackageCacheServiceStub },{ provide: WorkPackageViewHierarchiesService, useClass: HierarchyServiceStub },{ provide: WorkPackageRelationsHierarchyService, useValue: parentServiceSpy },WorkPackageViewHierarchyIdentationServicediff --git a/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy-indentation.service.ts b/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy-indentation.service.tsindex 46612d46330..993c773eb7a 100644--- a/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy-indentation.service.ts+++ b/frontend/src/app/modules/work_packages/routing/wp-view-base/view-services/wp-view-hierarchy-indentation.service.ts@@ -7,6 +7,7 @@ import {WorkPackageViewHierarchiesService} from "core-app/modules/work_packages/import {IsolatedQuerySpace} from "core-app/modules/work_packages/query-space/isolated-query-space";import {WorkPackageRelationsHierarchyService} from "core-components/wp-relations/wp-relations-hierarchy/wp-relations-hierarchy.service";import {States} from "core-components/states.service";+import {WorkPackageCacheService} from "core-components/work-packages/work-package-cache.service";@Injectable()export class WorkPackageViewHierarchyIdentationService {@@ -14,6 +15,7 @@ export class WorkPackageViewHierarchyIdentationService {constructor(private wpViewHierarchies:WorkPackageViewHierarchiesService,private states:States,private wpRelationHierarchy:WorkPackageRelationsHierarchyService,+ private wpCacheService:WorkPackageCacheService,private querySpace:IsolatedQuerySpace) {}@@ -74,7 +76,7 @@ export class WorkPackageViewHierarchyIdentationService {* Try to indent the work package.* @return a Promise with the change parent result*/- public indent(workPackage:WorkPackageResource):Promise<unknown> {+ public async indent(workPackage:WorkPackageResource):Promise<unknown> {if (!this.canIndent(workPackage)) {return Promise.reject();}@@ -88,7 +90,7 @@ export class WorkPackageViewHierarchyIdentationService {// If the predecessor is in an ancestor chain.// get the first element of the ancestor chain that workPackage is not in- const predecessor = this.states.workPackages.get(predecessorId).value!;+ const predecessor = await this.wpCacheService.require(predecessorId);const difference = _.difference(predecessor.ancestorIds, workPackage.ancestorIds);if (difference && difference.length > 0) {