diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatus.java b/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatus.java index 73be295ca..5c89d1c2d 100644 --- a/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatus.java +++ b/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatus.java @@ -14,6 +14,9 @@ public class PublicDescriptionStatus { public final static String _internalStatus = "internalStatus"; private org.opencdmp.commons.enums.DescriptionStatus internalStatus; + public final static String _definition = "definition"; + private PublicDescriptionStatusDefinition definition; + public UUID getId() { return this.id; } public void setId(UUID id) { this.id = id; } @@ -22,4 +25,12 @@ public class PublicDescriptionStatus { public org.opencdmp.commons.enums.DescriptionStatus getInternalStatus() { return this.internalStatus; } public void setInternalStatus(org.opencdmp.commons.enums.DescriptionStatus internalStatus) { this.internalStatus = internalStatus; } + + public PublicDescriptionStatusDefinition getDefinition() { + return definition; + } + + public void setDefinition(PublicDescriptionStatusDefinition definition) { + this.definition = definition; + } } diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatusDefinition.java b/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatusDefinition.java new file mode 100644 index 000000000..6a0e26f82 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/PublicDescriptionStatusDefinition.java @@ -0,0 +1,20 @@ +package org.opencdmp.model; + +import org.opencdmp.commons.enums.DescriptionStatusAvailableActionType; + +import java.util.List; + +public class PublicDescriptionStatusDefinition { + + + public final static String _availableActions = "availableActions"; + private List availableActions; + + public List getAvailableActions() { + return availableActions; + } + + public void setAvailableActions(List availableActions) { + this.availableActions = availableActions; + } +} diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatus.java b/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatus.java index 0962270f4..dc80f6816 100644 --- a/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatus.java +++ b/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatus.java @@ -16,6 +16,9 @@ public class PublicPlanStatus { public final static String _internalStatus = "internalStatus"; private PlanStatus internalStatus; + public final static String _definition = "definition"; + private PublicPlanStatusDefinition definition; + public UUID getId() { return this.id; } public void setId(UUID id) { this.id = id; } @@ -29,4 +32,12 @@ public class PublicPlanStatus { public void setInternalStatus(PlanStatus internalStatus) { this.internalStatus = internalStatus; } + + public PublicPlanStatusDefinition getDefinition() { + return definition; + } + + public void setDefinition(PublicPlanStatusDefinition definition) { + this.definition = definition; + } } diff --git a/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatusDefinition.java b/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatusDefinition.java new file mode 100644 index 000000000..ad38047bb --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/PublicPlanStatusDefinition.java @@ -0,0 +1,21 @@ +package org.opencdmp.model; + +import org.opencdmp.commons.enums.PlanStatusAvailableActionType; + +import java.util.List; + +public class PublicPlanStatusDefinition { + + + public final static String _availableActions = "availableActions"; + private List availableActions; + + + public List getAvailableActions() { + return availableActions; + } + + public void setAvailableActions(List availableActions) { + this.availableActions = availableActions; + } +} diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusBuilder.java index 7234b7944..099d2406b 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusBuilder.java @@ -1,10 +1,13 @@ package org.opencdmp.model.builder; +import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.XmlHandlingService; +import org.opencdmp.commons.types.descriptionstatus.DescriptionStatusDefinitionEntity; import org.opencdmp.convention.ConventionService; @@ -22,11 +25,16 @@ import java.util.*; @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class PublicDescriptionStatusBuilder extends BaseBuilder { + private final XmlHandlingService xmlHandlingService; + private final BuilderFactory builderFactory; + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired public PublicDescriptionStatusBuilder( - ConventionService conventionService) { + ConventionService conventionService, XmlHandlingService xmlHandlingService, BuilderFactory builderFactory) { super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDescriptionStatusBuilder.class))); + this.xmlHandlingService = xmlHandlingService; + this.builderFactory = builderFactory; } public PublicDescriptionStatusBuilder authorize(EnumSet values) { @@ -41,11 +49,17 @@ public class PublicDescriptionStatusBuilder extends BaseBuilder(); List models = new ArrayList<>(); + FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(PublicDescriptionStatus._definition)); + for (DescriptionStatusEntity d : data) { PublicDescriptionStatus m = new PublicDescriptionStatus(); if (fields.hasField(this.asIndexer(PublicDescriptionStatus._id))) m.setId(d.getId()); if (fields.hasField(this.asIndexer(PublicDescriptionStatus._name))) m.setName(d.getName()); if (fields.hasField(this.asIndexer(PublicDescriptionStatus._internalStatus))) m.setInternalStatus(d.getInternalStatus()); + if (!definitionFields.isEmpty() && d.getDefinition() != null) { + DescriptionStatusDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(DescriptionStatusDefinitionEntity.class, d.getDefinition()); + m.setDefinition(this.builderFactory.builder(PublicDescriptionStatusDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition)); + } models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusDefinitionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusDefinitionBuilder.java new file mode 100644 index 000000000..3445595d7 --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicDescriptionStatusDefinitionBuilder.java @@ -0,0 +1,51 @@ +package org.opencdmp.model.builder; + +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.types.descriptionstatus.DescriptionStatusDefinitionEntity; +import org.opencdmp.convention.ConventionService; + +import org.opencdmp.model.PublicDescriptionStatusDefinition; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.*; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class PublicDescriptionStatusDefinitionBuilder extends BaseBuilder { + + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + @Autowired + public PublicDescriptionStatusDefinitionBuilder( + ConventionService conventionService) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicDescriptionStatusDefinitionBuilder.class))); + } + + public PublicDescriptionStatusDefinitionBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + List models = new ArrayList<>(); + for (DescriptionStatusDefinitionEntity d : data) { + PublicDescriptionStatusDefinition m = new PublicDescriptionStatusDefinition(); + if (fields.hasField(this.asIndexer(PublicDescriptionStatusDefinition._availableActions))) m.setAvailableActions(d.getAvailableActions()); + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + return models; + } +} diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusBuilder.java index f0cba11c5..e1c5a31f6 100644 --- a/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusBuilder.java +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusBuilder.java @@ -1,13 +1,17 @@ package org.opencdmp.model.builder; +import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.logging.DataLogEntry; import gr.cite.tools.logging.LoggerService; import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.XmlHandlingService; +import org.opencdmp.commons.types.planstatus.PlanStatusDefinitionEntity; import org.opencdmp.convention.ConventionService; import org.opencdmp.data.PlanStatusEntity; import org.opencdmp.model.PublicPlanStatus; +import org.opencdmp.model.builder.planstatus.PlanStatusDefinitionBuilder; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.config.ConfigurableBeanFactory; @@ -20,11 +24,16 @@ import java.util.*; @Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) public class PublicPlanStatusBuilder extends BaseBuilder { + private final XmlHandlingService xmlHandlingService; + private final BuilderFactory builderFactory; + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); @Autowired public PublicPlanStatusBuilder( - ConventionService conventionService) { + ConventionService conventionService, XmlHandlingService xmlHandlingService, BuilderFactory builderFactory) { super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicPlanStatusBuilder.class))); + this.xmlHandlingService = xmlHandlingService; + this.builderFactory = builderFactory; } public PublicPlanStatusBuilder authorize(EnumSet values) { @@ -38,12 +47,19 @@ public class PublicPlanStatusBuilder extends BaseBuilder(); + + FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(PublicPlanStatus._definition)); List models = new ArrayList<>(); + for (PlanStatusEntity d : data) { PublicPlanStatus m = new PublicPlanStatus(); if (fields.hasField(this.asIndexer(PublicPlanStatus._id))) m.setId(d.getId()); if (fields.hasField(this.asIndexer(PublicPlanStatus._name))) m.setName(d.getName()); if (fields.hasField(this.asIndexer(PublicPlanStatus._internalStatus))) m.setInternalStatus(d.getInternalStatus()); + if (!definitionFields.isEmpty() && d.getDefinition() != null) { + PlanStatusDefinitionEntity definition = this.xmlHandlingService.fromXmlSafe(PlanStatusDefinitionEntity.class, d.getDefinition()); + m.setDefinition(this.builderFactory.builder(PublicPlanStatusDefinitionBuilder.class).authorize(this.authorize).build(definitionFields, definition)); + } models.add(m); } this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); diff --git a/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusDefinitionBuilder.java b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusDefinitionBuilder.java new file mode 100644 index 000000000..6ba1fcfdb --- /dev/null +++ b/backend/core/src/main/java/org/opencdmp/model/builder/PublicPlanStatusDefinitionBuilder.java @@ -0,0 +1,50 @@ +package org.opencdmp.model.builder; + +import gr.cite.tools.exception.MyApplicationException; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.DataLogEntry; +import gr.cite.tools.logging.LoggerService; +import org.opencdmp.authorization.AuthorizationFlags; +import org.opencdmp.commons.types.planstatus.PlanStatusDefinitionEntity; +import org.opencdmp.convention.ConventionService; +import org.opencdmp.model.PublicPlanStatusDefinition; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.*; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class PublicPlanStatusDefinitionBuilder extends BaseBuilder { + + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + @Autowired + public PublicPlanStatusDefinitionBuilder( + ConventionService conventionService) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(PublicPlanStatusDefinitionBuilder.class))); + } + + public PublicPlanStatusDefinitionBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + List models = new ArrayList<>(); + for (PlanStatusDefinitionEntity d : data) { + PublicPlanStatusDefinition m = new PublicPlanStatusDefinition(); + if (fields.hasField(this.asIndexer(PublicPlanStatusDefinition._availableActions))) m.setAvailableActions(d.getAvailableActions()); + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + return models; + } +} diff --git a/backend/core/src/main/java/org/opencdmp/query/DescriptionStatusQuery.java b/backend/core/src/main/java/org/opencdmp/query/DescriptionStatusQuery.java index 486bc155c..7f0e42822 100644 --- a/backend/core/src/main/java/org/opencdmp/query/DescriptionStatusQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/DescriptionStatusQuery.java @@ -198,7 +198,7 @@ public class DescriptionStatusQuery extends QueryBase { return DescriptionStatusEntity._tenantId; else if (item.match(DescriptionStatus._internalStatus)) return DescriptionStatusEntity._internalStatus; - else if (item.match(DescriptionStatusEntity._definition)) + else if (item.prefix(DescriptionStatusEntity._definition)) return DescriptionStatusEntity._definition; else return null; diff --git a/backend/core/src/main/java/org/opencdmp/query/PlanStatusQuery.java b/backend/core/src/main/java/org/opencdmp/query/PlanStatusQuery.java index 4670f010f..46daf0ea5 100644 --- a/backend/core/src/main/java/org/opencdmp/query/PlanStatusQuery.java +++ b/backend/core/src/main/java/org/opencdmp/query/PlanStatusQuery.java @@ -189,7 +189,7 @@ public class PlanStatusQuery extends QueryBase { return PlanStatusEntity._name; else if (item.match(PlanStatus._internalStatus)) return PlanStatusEntity._internalStatus; - else if (item.match(PlanStatus._definition)) + else if (item.prefix(PlanStatus._definition)) return PlanStatusEntity._definition; else if (item.match(PlanStatus._createdAt)) return PlanStatusEntity._createdAt; diff --git a/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java b/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java index 98eefe61f..2bd711e0e 100644 --- a/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java +++ b/backend/core/src/main/java/org/opencdmp/service/plan/PlanServiceImpl.java @@ -314,6 +314,10 @@ public class PlanServiceImpl implements PlanService { } private void sendNotification(PlanEntity plan) throws InvalidApplicationException { + PlanStatusEntity planStatusEntity = this.entityManager.find(PlanStatusEntity.class, plan.getStatusId(), true); + if (planStatusEntity == null) throw new MyNotFoundException(this.messageSource.getMessage("General_ItemNotFound", new Object[]{plan.getStatusId(), PlanStatusEntity.class.getSimpleName()}, LocaleContextHolder.getLocale())); + if (planStatusEntity.getInternalStatus() == null) return; + List existingUsers = this.queryFactory.query(PlanUserQuery.class).disableTracking() .planIds(plan.getId()) .isActives(IsActive.Active) @@ -327,16 +331,16 @@ public class PlanServiceImpl implements PlanService { if (!planUser.getUserId().equals(this.userScope.getUserIdSafe())){ UserEntity user = this.queryFactory.query(UserQuery.class).disableTracking().ids(planUser.getUserId()).first(); if (user == null || user.getIsActive().equals(IsActive.Inactive)) throw new MyValidationException(this.errors.getPlanInactiveUser().getCode(), this.errors.getPlanInactiveUser().getMessage()); - this.createPlanNotificationEvent(plan, user); + this.createPlanNotificationEvent(plan, planStatusEntity.getInternalStatus(), user); } } } - private void createPlanNotificationEvent(PlanEntity plan, UserEntity user) throws InvalidApplicationException { + private void createPlanNotificationEvent(PlanEntity plan, PlanStatus internalStatus, UserEntity user) throws InvalidApplicationException { NotifyIntegrationEvent event = new NotifyIntegrationEvent(); event.setUserId(user.getId()); - this.applyNotificationType(plan.getStatus(), event); + this.applyNotificationType(internalStatus, event); NotificationFieldData data = new NotificationFieldData(); List fieldInfoList = new ArrayList<>(); fieldInfoList.add(new FieldInfo("{recipient}", DataType.String, user.getName())); diff --git a/frontend/src/app/core/model/description/description.ts b/frontend/src/app/core/model/description/description.ts index 2ee633917..77026b86a 100644 --- a/frontend/src/app/core/model/description/description.ts +++ b/frontend/src/app/core/model/description/description.ts @@ -7,7 +7,7 @@ import { Reference, ReferencePersist } from "../reference/reference"; import { Tag, TagPersist } from "../tag/tag"; import { User } from "../user/user"; import { AppPermission } from "@app/core/common/enum/permission.enum"; -import { DescriptionStatus } from "../description-status/description-status"; +import { DescriptionStatus, DescriptionStatusDefinition } from "../description-status/description-status"; export interface Description extends BaseDescription { label?: string; @@ -155,6 +155,7 @@ export interface PublicDescriptionStatus { id: Guid; name: string; internalStatus: DescriptionStatusEnum; + definition: DescriptionStatusDefinition; } export interface DescriptionSectionPermissionResolver { diff --git a/frontend/src/app/ui/description/editor/description-editor.component.html b/frontend/src/app/ui/description/editor/description-editor.component.html index d431952d0..5c12941e9 100644 --- a/frontend/src/app/ui/description/editor/description-editor.component.html +++ b/frontend/src/app/ui/description/editor/description-editor.component.html @@ -30,7 +30,7 @@
- diff --git a/frontend/src/app/ui/description/editor/description-editor.component.ts b/frontend/src/app/ui/description/editor/description-editor.component.ts index a0f3f1c7f..66c3329bd 100644 --- a/frontend/src/app/ui/description/editor/description-editor.component.ts +++ b/frontend/src/app/ui/description/editor/description-editor.component.ts @@ -47,6 +47,7 @@ import { TableOfContentsService } from './table-of-contents/services/table-of-co import { TableOfContentsComponent } from './table-of-contents/table-of-contents.component'; import { DescriptionStatusService } from '@app/core/services/description-status/description-status.service'; import { DescriptionStatus } from '@app/core/model/description-status/description-status'; +import { DescriptionStatusAvailableActionType } from '@app/core/common/enum/description-status-available-action-type'; @Component({ selector: 'app-description-editor-component', @@ -61,6 +62,7 @@ export class DescriptionEditorComponent extends BaseEditor x === DescriptionStatusAvailableActionType.Export).length > 0) this.canExport = true; } if (data && data?.plan?.planUsers) data.plan.planUsers = data.plan.planUsers.filter(x => x.isActive === IsActive.Active); this.item = data; diff --git a/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts b/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts index 1071be175..1cfce9017 100644 --- a/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts +++ b/frontend/src/app/ui/description/editor/resolvers/description-editor-entity.resolver.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router'; import { IsActive } from '@app/core/common/enum/is-active.enum'; import { AppPermission } from '@app/core/common/enum/permission.enum'; -import { DescriptionStatus } from '@app/core/model/description-status/description-status'; +import { DescriptionStatus, DescriptionStatusDefinition } from '@app/core/model/description-status/description-status'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { Description, DescriptionExternalIdentifier, DescriptionField, DescriptionPropertyDefinition, DescriptionPropertyDefinitionFieldSet, DescriptionPropertyDefinitionFieldSetItem, DescriptionReference, DescriptionReferenceData, DescriptionTag } from '@app/core/model/description/description'; import { DescriptionTemplatesInSection, PlanBlueprint, PlanBlueprintDefinition, PlanBlueprintDefinitionSection } from '@app/core/model/plan-blueprint/plan-blueprint'; @@ -57,6 +57,7 @@ export class DescriptionEditorEntityResolver extends BaseEditorResolver { [nameof(x => x.status), nameof(x => x.id)].join('.'), [nameof(x => x.status), nameof(x => x.name)].join('.'), [nameof(x => x.status), nameof(x => x.internalStatus)].join('.'), + [nameof(x => x.status), nameof(x => x.definition), nameof(x => x.availableActions)].join('.'), [nameof(x => x.authorizationFlags), AppPermission.EditDescription].join('.'), [nameof(x => x.authorizationFlags), AppPermission.DeleteDescription].join('.'), diff --git a/frontend/src/app/ui/description/overview/description-overview.component.html b/frontend/src/app/ui/description/overview/description-overview.component.html index ab4ebebcb..f1ad94eb9 100644 --- a/frontend/src/app/ui/description/overview/description-overview.component.html +++ b/frontend/src/app/ui/description/overview/description-overview.component.html @@ -156,7 +156,7 @@
- +
- - - +
diff --git a/frontend/src/app/ui/plan/overview/plan-overview.component.ts b/frontend/src/app/ui/plan/overview/plan-overview.component.ts index 28ae2b750..e48a29973 100644 --- a/frontend/src/app/ui/plan/overview/plan-overview.component.ts +++ b/frontend/src/app/ui/plan/overview/plan-overview.component.ts @@ -51,8 +51,9 @@ import { PlanInvitationDialogComponent } from '../invitation/dialog/plan-invitat import { NewVersionPlanDialogComponent } from '../new-version-dialog/plan-new-version-dialog.component'; import { RouterUtilsService } from '@app/core/services/router/router-utils.service'; import { DescriptionStatus } from '@app/core/model/description-status/description-status'; -import { PlanStatus } from '@app/core/model/plan-status/plan-status'; +import { PlanStatus, PlanStatusDefinition } from '@app/core/model/plan-status/plan-status'; import { PlanStatusService } from '@app/core/services/plan/plan-status.service'; +import { PlanStatusAvailableActionType } from '@app/core/common/enum/plan-status-available-action-type'; @Component({ selector: 'app-plan-overview', @@ -310,7 +311,9 @@ export class PlanOverviewComponent extends BaseComponent implements OnInit { canExportPlan(): boolean { const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : []; - return (authorizationFlags?.some(x => x === AppPermission.ExportPlan) || this.authentication.hasPermission(AppPermission.ExportPlan)); + return (authorizationFlags?.some(x => x === AppPermission.ExportPlan) || this.authentication.hasPermission(AppPermission.ExportPlan)) && + this.plan?.status?.definition?.availableActions?.filter(x => x === PlanStatusAvailableActionType.Export).length > 0; + } canInvitePlanUsers(): boolean { @@ -328,7 +331,8 @@ export class PlanOverviewComponent extends BaseComponent implements OnInit { canDepositPlan(): boolean { const authorizationFlags = !this.isPublicView ? (this.plan as Plan).authorizationFlags : []; - return (authorizationFlags?.some(x => x === AppPermission.DepositPlan) || this.authentication.hasPermission(AppPermission.DepositPlan)) && this.isPublicView == false && this.plan.belongsToCurrentTenant != false; + return (authorizationFlags?.some(x => x === AppPermission.DepositPlan) || this.authentication.hasPermission(AppPermission.DepositPlan)) && this.isPublicView == false && this.plan.belongsToCurrentTenant != false && + this.plan?.status?.definition?.availableActions?.filter(x => x === PlanStatusAvailableActionType.Deposit).length > 0; } @@ -426,11 +430,7 @@ export class PlanOverviewComponent extends BaseComponent implements OnInit { } isDraftPlan() { - return this.plan.status?.internalStatus == PlanStatusEnum.Draft; - } - - isFinalizedPlan(plan: Plan) { - return plan.status?.internalStatus == PlanStatusEnum.Finalized; + return this.plan.status?.internalStatus != PlanStatusEnum.Finalized; } isPublishedPlan() { @@ -670,7 +670,8 @@ export class PlanOverviewComponent extends BaseComponent implements OnInit { nameof(x => x.description), [nameof(x => x.status), nameof(x => x.id)].join('.'), [nameof(x => x.status), nameof(x => x.name)].join('.'), - [nameof(x => x.status), nameof(x => x.internalStatus)].join('.'), + [nameof(x => x.status), nameof(x => x.internalStatus)].join('.'), + [nameof(x => x.status), nameof(x => x.definition), nameof(x => x.availableActions)].join('.'), nameof(x => x.accessType), nameof(x => x.version), nameof(x => x.versionStatus), diff --git a/frontend/src/app/ui/plan/plan-editor-blueprint/plan-editor.component.html b/frontend/src/app/ui/plan/plan-editor-blueprint/plan-editor.component.html index ff12dd0ac..763495708 100644 --- a/frontend/src/app/ui/plan/plan-editor-blueprint/plan-editor.component.html +++ b/frontend/src/app/ui/plan/plan-editor-blueprint/plan-editor.component.html @@ -11,7 +11,7 @@
-
+