From a2a3f5000dc70ca594272e9f2477f282ec7b0510 Mon Sep 17 00:00:00 2001 From: Sofia Papacharalampous Date: Fri, 21 Jun 2024 13:06:43 +0300 Subject: [PATCH] show actions conditinally on description-template-listing --- ...escription-template-listing.component.html | 14 ++++----- .../description-template-listing.component.ts | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html index 4e3d3127a..6481467ec 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html +++ b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.html @@ -86,29 +86,29 @@ -
+
- - - - - - diff --git a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts index 697777afc..7420d1f91 100644 --- a/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts +++ b/dmp-frontend/src/app/ui/admin/description-template/listing/description-template-listing.component.ts @@ -192,6 +192,36 @@ export class DescriptionTemplateListingComponent extends BaseListingComponent x.toString())); } + public showActions(descriptionTemplate: DescriptionTemplate): boolean { + return this.canEdit(descriptionTemplate) || this.canAddNewVersion(descriptionTemplate) || + this.canClone(descriptionTemplate) || this.canViewVersions(descriptionTemplate) || + this.canDownloadXml(descriptionTemplate) || this.canDelete(descriptionTemplate); + } + + public canEdit(descriptionTemplate: DescriptionTemplate): boolean { + return descriptionTemplate.status !== DescriptionTemplateStatus.Finalized && this.hasPermission(AppPermission.EditDescriptionTemplate, descriptionTemplate); + } + + public canAddNewVersion(descriptionTemplate: DescriptionTemplate): boolean { + return descriptionTemplate.belongsToCurrentTenant != false && this.hasExplicitPermission(AppPermission.EditDescriptionTemplate); + } + + public canClone(descriptionTemplate: DescriptionTemplate): boolean { + return descriptionTemplate.belongsToCurrentTenant != false && this.hasPermission(AppPermission.CloneDescriptionTemplate, descriptionTemplate); + } + + public canViewVersions(descriptionTemplate: DescriptionTemplate): boolean { + return descriptionTemplate.belongsToCurrentTenant != false && this.hasExplicitPermission(AppPermission.EditDescriptionTemplate); + } + + public canDownloadXml(descriptionTemplate: DescriptionTemplate): boolean { + return descriptionTemplate.belongsToCurrentTenant != false && this.hasPermission(AppPermission.ExportDescriptionTemplate, descriptionTemplate); + } + + public canDelete(descriptionTemplate: DescriptionTemplate): boolean { + return descriptionTemplate.belongsToCurrentTenant != false && this.hasPermission(AppPermission.DeleteDescriptionTemplate, descriptionTemplate); + } + private onColumnsChangedInternal(columns: string[]) { // Here are defined the projection fields that always requested from the api. const fields = new Set(this.lookupFields);