From f68a657b822c30496fe7f7e090f727a03fc4a8c2 Mon Sep 17 00:00:00 2001 From: "CITE\\spapacharalampous" Date: Thu, 5 Sep 2024 16:04:32 +0300 Subject: [PATCH] ui fix on plan view versions listing --- .../plan-listing-item.component.html | 24 +++--- .../plan-listing-item.component.ts | 83 +++++++++---------- .../plan/listing/plan-listing.component.html | 49 +++++------ .../ui/plan/listing/plan-listing.component.ts | 5 +- 4 files changed, 82 insertions(+), 79 deletions(-) diff --git a/frontend/src/app/ui/plan/listing/listing-item/plan-listing-item.component.html b/frontend/src/app/ui/plan/listing/listing-item/plan-listing-item.component.html index 6f35d93da..0bc1af233 100644 --- a/frontend/src/app/ui/plan/listing/listing-item/plan-listing-item.component.html +++ b/frontend/src/app/ui/plan/listing/listing-item/plan-listing-item.component.html @@ -20,10 +20,10 @@ public{{'TYPES.PLAN-VISIBILITY.PUBLIC' | translate}} done{{ enumUtils.toPlanStatusString(plan.status) }} - create{{ enumUtils.toPlanStatusString(plan.status) }} + create{{ enumUtils.toPlanStatusString(plan.status) }} - visibility{{ enumUtils.toPlanStatusString(plan.status) }} + visibility{{ enumUtils.toPlanStatusString(plan.status) }} . {{'PLAN-LISTING.VERSION' | translate}} {{plan.version}} @@ -41,14 +41,14 @@ {{'GENERAL.ACTIONS.SHOW-MORE' | translate}}
- open_in_new{{'PLAN-LISTING.ACTIONS.EXPORT' | translate}} - add{{'PLAN-LISTING.ACTIONS.ADD-DESCRIPTION-SHORT' | translate}} - group_add{{'PLAN-LISTING.ACTIONS.INVITE-SHORT' | translate}} - filter_none{{'PLAN-LISTING.ACTIONS.CLONE' | translate}} - library_books{{'PLAN-LISTING.ACTIONS.VIEW-VERSION' | translate}} + open_in_new{{'PLAN-LISTING.ACTIONS.EXPORT' | translate}} + add{{'PLAN-LISTING.ACTIONS.ADD-DESCRIPTION-SHORT' | translate}} + group_add{{'PLAN-LISTING.ACTIONS.INVITE-SHORT' | translate}} + filter_none{{'PLAN-LISTING.ACTIONS.CLONE' | translate}} + library_books{{'PLAN-LISTING.ACTIONS.VIEW-VERSION' | translate}} - delete{{ 'PLAN-LISTING.ACTIONS.DELETE' | translate }} - more_horiz + delete{{ 'PLAN-LISTING.ACTIONS.DELETE' | translate }} + more_horiz
- - + library_books{{'PLAN-LISTING.ACTIONS.VIEW-VERSION' | translate}} - diff --git a/frontend/src/app/ui/plan/listing/listing-item/plan-listing-item.component.ts b/frontend/src/app/ui/plan/listing/listing-item/plan-listing-item.component.ts index 7831cc55b..355283033 100644 --- a/frontend/src/app/ui/plan/listing/listing-item/plan-listing-item.component.ts +++ b/frontend/src/app/ui/plan/listing/listing-item/plan-listing-item.component.ts @@ -1,11 +1,9 @@ import { Location } from '@angular/common'; -import { HttpClient } from '@angular/common/http'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; import { PlanAccessType } from '@app/core/common/enum/plan-access-type'; import { Plan } from '@app/core/model/plan/plan'; -import { PlanBlueprintService } from '@app/core/services/plan/plan-blueprint.service'; import { PlanService } from '@app/core/services/plan/plan.service'; import { FileTransformerService } from '@app/core/services/file-transformer/file-transformer.service'; import { LockService } from '@app/core/services/lock/lock.service'; @@ -13,7 +11,6 @@ import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/serv import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service'; import { ReferenceService } from '@app/core/services/reference/reference.service'; import { EnumUtils } from '@app/core/services/utilities/enum-utils.service'; -import { FileUtils } from '@app/core/services/utilities/file-utils.service'; import { BaseComponent } from '@common/base/base.component'; import { ConfirmationDialogComponent } from '@common/modules/confirmation-dialog/confirmation-dialog.component'; import { Guid } from '@common/types/guid'; @@ -42,6 +39,7 @@ export class PlanListingItemComponent extends BaseComponent implements OnInit { @Input() plan: Plan; @Input() showDivider: boolean = true; + @Input() showAllVersionsAction: boolean = true; @Input() isPublic: boolean; @Input() tenants: Tenant[] = []; @Output() onClick: EventEmitter = new EventEmitter(); @@ -52,6 +50,46 @@ export class PlanListingItemComponent extends BaseComponent implements OnInit { planStatusEnum = PlanStatusEnum; fileTransformerEntityTypeEnum = FileTransformerEntityType; + get canEditPlan(): boolean { + return (this.isDraft) && (this.plan.authorizationFlags?.some(x => x === AppPermission.EditPlan) || this.authentication.hasPermission(AppPermission.EditPlan)) && !this.isPublic && this.plan.belongsToCurrentTenant != false; + } + + get canCreateNewVersion(): boolean { + return (this.plan.authorizationFlags?.some(x => x === AppPermission.CreateNewVersionPlan) || this.authentication.hasPermission(AppPermission.CreateNewVersionPlan)) && this.plan.versionStatus === PlanVersionStatus.Current && !this.isPublic && this.plan.belongsToCurrentTenant != false; + } + + get canDeletePlan(): boolean { + return (this.plan.authorizationFlags?.some(x => x === AppPermission.DeletePlan) || this.authentication.hasPermission(AppPermission.DeletePlan)) && !this.isPublic && this.plan.belongsToCurrentTenant != false && this.isDraftPlan; + } + + get canClonePlan(): boolean { + return this.plan.authorizationFlags?.some(x => x === AppPermission.ClonePlan) || this.authentication.hasPermission(AppPermission.ClonePlan) || (this.authentication.hasPermission(AppPermission.PublicClonePlan) && this.isPublic); + } + + get canFinalizePlan(): boolean { + return (this.plan.authorizationFlags?.some(x => x === AppPermission.FinalizePlan) || this.authentication.hasPermission(AppPermission.FinalizePlan)) && !this.isPublic && this.plan.belongsToCurrentTenant != false; + } + + get canExportPlan(): boolean { + return this.plan.authorizationFlags?.some(x => x === AppPermission.ExportPlan) || this.authentication.hasPermission(AppPermission.ExportPlan); + } + + get canInvitePlanUsers(): boolean { + return (this.plan.authorizationFlags?.some(x => x === AppPermission.InvitePlanUsers) || this.authentication.hasPermission(AppPermission.InvitePlanUsers)) && !this.isPublic && this.plan.belongsToCurrentTenant != false; + } + + get canAssignPlanUsers(): boolean { + return (this.plan.authorizationFlags?.some(x => x === AppPermission.AssignPlanUsers) || this.authentication.hasPermission(AppPermission.AssignPlanUsers)) && !this.isPublic && this.plan.belongsToCurrentTenant != false; + } + + get showActionsMenu(): boolean { + return this.isAuthenticated() && (this.canCreateNewVersion || this.showAllVersionsAction || this.canDeletePlan) + } + + get isDraftPlan(): boolean { + return this.plan.status == PlanStatusEnum.Draft; + } + constructor( public routerUtils: RouterUtilsService, private router: Router, @@ -59,16 +97,13 @@ export class PlanListingItemComponent extends BaseComponent implements OnInit { private authentication: AuthService, public enumUtils: EnumUtils, private planService: PlanService, - private planBlueprintService: PlanBlueprintService, private language: TranslateService, private uiNotificationService: UiNotificationService, private lockService: LockService, private location: Location, - private httpClient: HttpClient, public referenceService: ReferenceService, public referenceTypeService: ReferenceTypeService, public fileTransformerService: FileTransformerService, - private fileUtils: FileUtils, private analyticsService: AnalyticsService, private httpErrorHandlingService: HttpErrorHandlingService, ) { @@ -226,10 +261,6 @@ export class PlanListingItemComponent extends BaseComponent implements OnInit { }); } - isDraftPlan(activity: Plan) { - return activity.status == PlanStatusEnum.Draft; - } - reloadPage(): void { const path = this.location.path(); this.router.navigateByUrl('/reload', { skipLocationChange: true }).then(() => { @@ -245,36 +276,4 @@ export class PlanListingItemComponent extends BaseComponent implements OnInit { onDeleteCallbackError(error) { this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); } - - canEditPlan(): boolean { - return (this.isDraft) && (this.plan.authorizationFlags?.some(x => x === AppPermission.EditPlan) || this.authentication.hasPermission(AppPermission.EditPlan)) && !this.isPublic && this.plan.belongsToCurrentTenant != false; - } - - canCreateNewVersion(): boolean { - return (this.plan.authorizationFlags?.some(x => x === AppPermission.CreateNewVersionPlan) || this.authentication.hasPermission(AppPermission.CreateNewVersionPlan)) && this.plan.versionStatus === PlanVersionStatus.Current && !this.isPublic && this.plan.belongsToCurrentTenant != false; - } - - canDeletePlan(): boolean { - return (this.plan.authorizationFlags?.some(x => x === AppPermission.DeletePlan) || this.authentication.hasPermission(AppPermission.DeletePlan)) && !this.isPublic && this.plan.belongsToCurrentTenant != false; - } - - canClonePlan(): boolean { - return this.plan.authorizationFlags?.some(x => x === AppPermission.ClonePlan) || this.authentication.hasPermission(AppPermission.ClonePlan) || (this.authentication.hasPermission(AppPermission.PublicClonePlan) && this.isPublic); - } - - canFinalizePlan(): boolean { - return (this.plan.authorizationFlags?.some(x => x === AppPermission.FinalizePlan) || this.authentication.hasPermission(AppPermission.FinalizePlan)) && !this.isPublic && this.plan.belongsToCurrentTenant != false; - } - - canExportPlan(): boolean { - return this.plan.authorizationFlags?.some(x => x === AppPermission.ExportPlan) || this.authentication.hasPermission(AppPermission.ExportPlan); - } - - canInvitePlanUsers(): boolean { - return (this.plan.authorizationFlags?.some(x => x === AppPermission.InvitePlanUsers) || this.authentication.hasPermission(AppPermission.InvitePlanUsers)) && !this.isPublic && this.plan.belongsToCurrentTenant != false; - } - - canAssignPlanUsers(): boolean { - return (this.plan.authorizationFlags?.some(x => x === AppPermission.AssignPlanUsers) || this.authentication.hasPermission(AppPermission.AssignPlanUsers)) && !this.isPublic && this.plan.belongsToCurrentTenant != false; - } } diff --git a/frontend/src/app/ui/plan/listing/plan-listing.component.html b/frontend/src/app/ui/plan/listing/plan-listing.component.html index 24eba51fe..454c51c93 100644 --- a/frontend/src/app/ui/plan/listing/plan-listing.component.html +++ b/frontend/src/app/ui/plan/listing/plan-listing.component.html @@ -50,35 +50,36 @@ {{ 'GENERAL.ACTIONS.TAKE-A-TOUR'| translate }}
- +
- @if(!isLoading){ -
-
- -
-
- -
-
-
- {{'PLAN-LISTING.EMPTY-LIST' | translate}} -
-
- {{'PLAN-LISTING.FILTERS.NO-ITEMS-FOUND' | translate}} -
- } - + @if(!isLoading) { +
+
+ +
+
+ +
+
+
+ {{'PLAN-LISTING.EMPTY-LIST' | translate}} +
+
+ {{'PLAN-LISTING.FILTERS.NO-ITEMS-FOUND' | translate}} +
+ } + - + \ No newline at end of file diff --git a/frontend/src/app/ui/plan/listing/plan-listing.component.ts b/frontend/src/app/ui/plan/listing/plan-listing.component.ts index 21578822e..853283cb8 100644 --- a/frontend/src/app/ui/plan/listing/plan-listing.component.ts +++ b/frontend/src/app/ui/plan/listing/plan-listing.component.ts @@ -69,6 +69,9 @@ export class PlanListingComponent extends BaseListingComponent(x => x.finalizedAt)) : this.toDescSortField(nameof(x => x.updatedAt)); lookup.order = { items: [recentActivityOrder] }; - if (this.mode && this.mode == 'versions-listing') { + if (this.mode && this.isVersionsListing) { this.groupId = Guid.parse(this.route.snapshot.paramMap.get('groupId')); lookup.groupIds = [this.groupId];