add belongsToCurrentTenant to ui

This commit is contained in:
Efstratios Giannopoulos 2024-04-05 17:49:20 +03:00
parent 4963d8ffc3
commit 5176916ce7
10 changed files with 44 additions and 34 deletions

View File

@ -199,6 +199,7 @@ export class DescriptionListingComponent extends BaseComponent implements OnInit
nameof<Description>(x => x.label),
nameof<Description>(x => x.status),
nameof<Description>(x => x.updatedAt),
nameof<Description>(x => x.belongsToCurrentTenant),
[nameof<Description>(x => x.authorizationFlags), AppPermission.EditDescription].join('.'),

View File

@ -85,14 +85,14 @@ export class DescriptionListingItemComponent extends BaseComponent implements On
this.setIsUserOwner();
}
this.canDelete = this.authService.hasPermission(AppPermission.DeleteDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.DeleteDescription);
this.canDelete = (this.authService.hasPermission(AppPermission.DeleteDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.DeleteDescription)) && this.description.belongsToCurrentTenant != false;
this.canEdit = this.authService.hasPermission(AppPermission.EditDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.EditDescription);
this.canEdit = (this.authService.hasPermission(AppPermission.EditDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.EditDescription)) && this.description.belongsToCurrentTenant != false;
this.canInviteDmpUsers = this.authService.hasPermission(AppPermission.InviteDmpUsers) ||
this.description.authorizationFlags?.some(x => x === AppPermission.InviteDmpUsers);
this.canInviteDmpUsers = (this.authService.hasPermission(AppPermission.InviteDmpUsers) ||
this.description.authorizationFlags?.some(x => x === AppPermission.InviteDmpUsers)) && this.description.belongsToCurrentTenant != false;
}

View File

@ -110,7 +110,7 @@
<div class="row" *ngIf="!description.description">
<div class="col-12">
<span class="material-icons">horizontal_rule</span>
</div>
</div>
</div>
</div>
<div class="col-12 col-lg-4">
@ -190,4 +190,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@ -115,17 +115,17 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
this.researchers = this.referenceService.getReferencesForTypes(this.description?.dmp?.dmpReferences, [this.referenceTypeService.getResearcherReferenceType()]);
// this.users = this.description.dmp.users;
this.checkLockStatus(this.description.id);
this.canDelete = this.authService.hasPermission(AppPermission.DeleteDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.DeleteDescription);
this.canDelete = (this.authService.hasPermission(AppPermission.DeleteDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.DeleteDescription)) && this.description.belongsToCurrentTenant != false;
this.canEdit = this.authService.hasPermission(AppPermission.EditDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.EditDescription);
this.canEdit = (this.authService.hasPermission(AppPermission.EditDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.EditDescription)) && this.description.belongsToCurrentTenant != false;
this.canFinalize = this.authService.hasPermission(AppPermission.FinalizeDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.FinalizeDescription);
this.canFinalize = (this.authService.hasPermission(AppPermission.FinalizeDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.FinalizeDescription)) && this.description.belongsToCurrentTenant != false;
this.canInviteDmpUsers = this.authService.hasPermission(AppPermission.InviteDmpUsers) ||
this.description.authorizationFlags?.some(x => x === AppPermission.InviteDmpUsers);
this.canInviteDmpUsers = (this.authService.hasPermission(AppPermission.InviteDmpUsers) ||
this.description.authorizationFlags?.some(x => x === AppPermission.InviteDmpUsers)) && this.description.belongsToCurrentTenant != false;
// const breadCrumbs = [];
// breadCrumbs.push({ parentComponentName: null, label: this.language.instant('NAV-BAR.MY-DESCRIPTION-DESCRIPTIONS'), url: "/descriptions" });
// breadCrumbs.push({ parentComponentName: 'DescriptionListingComponent', label: this.description.label, url: '/descriptions/overview/' + this.description.id });
@ -470,6 +470,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
nameof<Description>(x => x.description),
nameof<Description>(x => x.status),
nameof<Description>(x => x.updatedAt),
nameof<Description>(x => x.belongsToCurrentTenant),
nameof<Description>(x => x.hash),
[nameof<Description>(x => x.authorizationFlags), AppPermission.EditDescription].join('.'),

View File

@ -187,6 +187,7 @@ export class DmpListingComponent extends BaseComponent implements OnInit { //IBr
nameof<Dmp>(x => x.version),
nameof<Dmp>(x => x.groupId),
nameof<Dmp>(x => x.updatedAt),
nameof<Dmp>(x => x.belongsToCurrentTenant),
nameof<Dmp>(x => x.hash),
[nameof<Dmp>(x => x.authorizationFlags), AppPermission.CreateNewVersionDmp].join('.'),
[nameof<Dmp>(x => x.authorizationFlags), AppPermission.DeleteDmp].join('.'),

View File

@ -216,17 +216,17 @@ export class DmpListingItemComponent 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);
}
canEditDmp(dmp: Dmp): boolean {
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.EditDmp) || this.authentication.hasPermission(AppPermission.EditDmp)) && this.isPublic == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.EditDmp) || this.authentication.hasPermission(AppPermission.EditDmp)) && this.isPublic == false && this.dmp.belongsToCurrentTenant != false;
}
canCreateNewVersion(dmp: Dmp): boolean {
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.CreateNewVersionDmp) || this.authentication.hasPermission(AppPermission.CreateNewVersionDmp)) && this.isPublic == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.CreateNewVersionDmp) || this.authentication.hasPermission(AppPermission.CreateNewVersionDmp)) && this.isPublic == false && this.dmp.belongsToCurrentTenant != false;
}
canDeleteDmp(dmp: Dmp): boolean {
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.DeleteDmp) || this.authentication.hasPermission(AppPermission.DeleteDmp)) && this.isPublic == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.DeleteDmp) || this.authentication.hasPermission(AppPermission.DeleteDmp)) && this.isPublic == false && this.dmp.belongsToCurrentTenant != false;
}
canCloneDmp(dmp: Dmp): boolean {
@ -234,7 +234,7 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
}
canFinalizeDmp(dmp: Dmp): boolean {
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.FinalizeDmp) || this.authentication.hasPermission(AppPermission.FinalizeDmp)) && this.isPublic == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.FinalizeDmp) || this.authentication.hasPermission(AppPermission.FinalizeDmp)) && this.isPublic == false && this.dmp.belongsToCurrentTenant != false;
}
canExportDmp(dmp: Dmp): boolean {
@ -242,10 +242,10 @@ export class DmpListingItemComponent extends BaseComponent implements OnInit {
}
canInviteDmpUsers(dmp: Dmp): boolean {
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.InviteDmpUsers) || this.authentication.hasPermission(AppPermission.InviteDmpUsers)) && this.isPublic == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.InviteDmpUsers) || this.authentication.hasPermission(AppPermission.InviteDmpUsers)) && this.isPublic == false && this.dmp.belongsToCurrentTenant != false;
}
canAssignDmpUsers(dmp: Dmp): boolean {
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.AssignDmpUsers) || this.authentication.hasPermission(AppPermission.AssignDmpUsers)) && this.isPublic == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.AssignDmpUsers) || this.authentication.hasPermission(AppPermission.AssignDmpUsers)) && this.isPublic == false && this.dmp.belongsToCurrentTenant != false;
}
}

View File

@ -241,7 +241,7 @@
</div>
</div>
<!-- <div *ngIf="canInviteDmpUsers()" class="col-12 d-flex align-items-center justify-content-center"> -->
<div class="col-12 d-flex align-items-center justify-content-center">
<div *ngIf="canInviteDmpUsers()" class="col-12 d-flex align-items-center justify-content-center">
<button mat-raised-button class="invite-btn" (click)="openShareDialog(dmp.id,dmp.label)">
<mat-icon>group_add</mat-icon>
{{'DMP-OVERVIEW.ACTIONS.INVITE-SHORT' | translate}}
@ -255,4 +255,4 @@
</div>
</div>
</div>
</div>
</div>

View File

@ -212,39 +212,39 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
}
canEditDmp(): boolean{
return (this.isDraftDmp()) && (this.dmp.authorizationFlags?.some(x => x === AppPermission.EditDmp) || this.authentication.hasPermission(AppPermission.EditDmp)) && this.isPublicView == false;
return (this.isDraftDmp()) && (this.dmp.authorizationFlags?.some(x => x === AppPermission.EditDmp) || this.authentication.hasPermission(AppPermission.EditDmp)) && this.isPublicView == false && this.dmp.belongsToCurrentTenant != false;
}
canCreateNewVersion(): boolean {
return this.dmp.authorizationFlags?.some(x => x === AppPermission.CreateNewVersionDmp) || this.authentication.hasPermission(AppPermission.CreateNewVersionDmp) && this.isPublicView == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.CreateNewVersionDmp) || this.authentication.hasPermission(AppPermission.CreateNewVersionDmp)) && this.isPublicView == false && this.dmp.belongsToCurrentTenant != false;
}
canDeleteDmp(): boolean {
return this.dmp.authorizationFlags?.some(x => x === AppPermission.DeleteDmp) || this.authentication.hasPermission(AppPermission.DeleteDmp) && this.isPublicView == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.DeleteDmp) || this.authentication.hasPermission(AppPermission.DeleteDmp)) && this.isPublicView == false && this.dmp.belongsToCurrentTenant != false;
}
canCloneDmp(): boolean {
return this.dmp.authorizationFlags?.some(x => x === AppPermission.CloneDmp) || this.authentication.hasPermission(AppPermission.CloneDmp);
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.CloneDmp) || this.authentication.hasPermission(AppPermission.CloneDmp));
}
canFinalizeDmp(): boolean {
return this.dmp.authorizationFlags?.some(x => x === AppPermission.FinalizeDmp) || this.authentication.hasPermission(AppPermission.FinalizeDmp) && this.isPublicView == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.FinalizeDmp) || this.authentication.hasPermission(AppPermission.FinalizeDmp)) && this.isPublicView == false && this.dmp.belongsToCurrentTenant != false;
}
canExportDmp(): boolean {
return this.dmp.authorizationFlags?.some(x => x === AppPermission.ExportDmp) || this.authentication.hasPermission(AppPermission.ExportDmp);
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.ExportDmp) || this.authentication.hasPermission(AppPermission.ExportDmp));
}
canInviteDmpUsers(): boolean {
return this.dmp.authorizationFlags?.some(x => x === AppPermission.InviteDmpUsers) || this.authentication.hasPermission(AppPermission.InviteDmpUsers) && this.isPublicView == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.InviteDmpUsers) || this.authentication.hasPermission(AppPermission.InviteDmpUsers)) && this.isPublicView == false && this.dmp.belongsToCurrentTenant != false;
}
canAssignDmpUsers(): boolean {
return this.dmp.authorizationFlags?.some(x => x === AppPermission.AssignDmpUsers) || this.authentication.hasPermission(AppPermission.AssignDmpUsers) && this.isPublicView == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.AssignDmpUsers) || this.authentication.hasPermission(AppPermission.AssignDmpUsers)) && this.isPublicView == false && this.dmp.belongsToCurrentTenant != false;
}
canDepositDmp(): boolean {
return this.dmp.authorizationFlags?.some(x => x === AppPermission.DepositDmp) || this.authentication.hasPermission(AppPermission.DepositDmp) && this.isPublicView == false;
return (this.dmp.authorizationFlags?.some(x => x === AppPermission.DepositDmp) || this.authentication.hasPermission(AppPermission.DepositDmp)) && this.isPublicView == false && this.dmp.belongsToCurrentTenant != false;
}
@ -742,6 +742,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
nameof<Dmp>(x => x.version),
nameof<Dmp>(x => x.updatedAt),
nameof<Dmp>(x => x.entityDois),
nameof<Dmp>(x => x.belongsToCurrentTenant),
[nameof<Dmp>(x => x.authorizationFlags), AppPermission.CreateNewVersionDmp].join('.'),
[nameof<Dmp>(x => x.authorizationFlags), AppPermission.DeleteDmp].join('.'),
[nameof<Dmp>(x => x.authorizationFlags), AppPermission.CloneDmp].join('.'),

View File

@ -76,6 +76,9 @@ export abstract class BaseEditor<EditorModelType extends BaseEditorModel, Entity
if(entity) {
this.isNew = false;
this.prepareForm(entity);
if (this.formGroup && this.editorModel.belongsToCurrentTenant == false) {
this.formGroup.disable();
}
}else{
this.prepareForm(null);
}
@ -169,6 +172,7 @@ export abstract class BaseEditor<EditorModelType extends BaseEditorModel, Entity
nameof<BaseEntity>(x => x.createdAt),
nameof<BaseEntity>(x => x.updatedAt),
nameof<BaseEntity>(x => x.hash),
nameof<BaseEntity>(x => x.belongsToCurrentTenant),
];
}

View File

@ -10,6 +10,7 @@ export abstract class BaseEditorModel implements IEditorModel {
hash: string;
createdAt: Date;
updatedAt: Date;
belongsToCurrentTenant?: boolean;
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
@ -19,6 +20,7 @@ export abstract class BaseEditorModel implements IEditorModel {
this.id = item.id;
this.isActive = item.isActive;
this.hash = item.hash;
this.belongsToCurrentTenant = item.belongsToCurrentTenant;
if (item.createdAt) { this.createdAt = item.createdAt; }
if (item.updatedAt) { this.updatedAt = item.updatedAt; }
}