Skip to content

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

Ensure the actionService may be undefined for basic boards

Oliver Güntherae626eab2c7b
diff --git a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
index a4b5f152eb6..3f7f52e9012 100644
--- a/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
+++ b/frontend/src/app/modules/boards/board/add-list-modal/add-list-modal.component.ts
@@ -147,6 +147,7 @@ export class AddListModalComponent extends OpModalComponent implements OnInit {
}
onNewActionCreated(newValue:HalResource) {
+ this.actionService.cache.clear("New attribute added.");
this.selectedAttribute = newValue;
this.create();
}
diff --git a/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts b/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts
index 71b73ebe3f4..e7a4c8a815c 100644
--- a/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts
+++ b/frontend/src/app/modules/boards/board/board-actions/board-action.service.ts
@@ -19,12 +19,13 @@ import {IFieldSchema} from "core-app/modules/fields/field.base";
import {WorkPackageChangeset} from "core-components/wp-edit/work-package-changeset";
import {WorkPackageFilterValues} from "core-components/wp-edit-form/work-package-filter-values";
import {APIV3Service} from "core-app/modules/apiv3/api-v3.service";
+import {SchemaCacheService} from "core-components/schemas/schema-cache.service";
@Injectable()
export abstract class BoardActionService {
// Cache the available values for the duration of the board
- protected cache = input<HalResource[]>();
+ readonly cache = input<HalResource[]>();
constructor(readonly injector:Injector,
protected boardListsService:BoardListsService,
@@ -32,7 +33,8 @@ export abstract class BoardActionService {
protected halResourceService:HalResourceService,
protected pathHelper:PathHelperService,
protected currentProject:CurrentProjectService,
- protected apiV3Service:APIV3Service) {
+ protected apiV3Service:APIV3Service,
+ protected schemaCache:SchemaCacheService) {
}
/**
@@ -180,7 +182,8 @@ export abstract class BoardActionService {
* Determine whether the given work package can be moved
*/
canMove(workPackage:WorkPackageResource):boolean {
- const fieldSchema = workPackage.schema[this.filterName] as IFieldSchema;
+ const schema = this.schemaCache.of(workPackage);
+ const fieldSchema = schema[this.filterName] as IFieldSchema;
return fieldSchema?.writable;
}
diff --git a/frontend/src/app/modules/boards/board/board-list/board-list.component.ts b/frontend/src/app/modules/boards/board/board-list/board-list.component.ts
index 9bfd8b55489..725d5414975 100644
--- a/frontend/src/app/modules/boards/board/board-list/board-list.component.ts
+++ b/frontend/src/app/modules/boards/board/board-list/board-list.component.ts
@@ -238,11 +238,7 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
}
public canMove(workPackage:WorkPackageResource) {
- if (this.board.isAction) {
- return this.canDragOutOf && this.actionService.canMove(workPackage);
- } else {
- return this.canDragOutOf;
- }
+ return this.canDragOutOf && (!this.actionService || this.actionService.canMove(workPackage));
}
public get canReference() {
@@ -336,7 +332,8 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
return;
}
- const id = this.actionService.getActionValueHrefForColumn(query);
+ let actionService = this.actionService!;
+ const id = actionService.getActionValueHrefForColumn(query);
// Test if we loaded the resource already
if (this.actionResource && id === this.actionResource.href) {
@@ -344,14 +341,14 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
}
// Load the resource
- this.actionService.getLoadedActionValue(query).then(async resource => {
+ actionService.getLoadedActionValue(query).then(async resource => {
this.actionResource = resource;
- this.headerComponent = this.actionService.headerComponent();
- this.buttonPlaceholder = this.actionService.disabledAddButtonPlaceholder(resource);
+ this.headerComponent = actionService.headerComponent();
+ this.buttonPlaceholder = actionService.disabledAddButtonPlaceholder(resource);
this.actionResourceClass = this.boardListActionColorClass(resource);
- this.canDragInto = this.actionService.dragIntoAllowed(query, resource);
+ this.canDragInto = actionService.dragIntoAllowed(query, resource);
- const canWriteAttribute = await this.actionService.canAddToQuery(query);
+ const canWriteAttribute = await actionService.canAddToQuery(query);
this.showAddButton = this.canDragInto && this.wpInlineCreate.canAdd && canWriteAttribute;
this.cdRef.detectChanges();
});
@@ -360,8 +357,12 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
/**
* Return the linked action service
*/
- private get actionService():BoardActionService {
- return this.boardActionRegistry.get(this.board.actionAttribute!);
+ private get actionService():BoardActionService|undefined {
+ if (this.board.actionAttribute) {
+ return this.boardActionRegistry.get(this.board.actionAttribute);
+ }
+
+ return undefined;
}
/**