description authz changes

This commit is contained in:
Efstratios Giannopoulos 2024-04-30 14:06:24 +03:00
parent 965af355d8
commit da8efe5130
19 changed files with 78 additions and 36 deletions

View File

@ -73,6 +73,7 @@ public final class Permission {
//Dmp
public static String BrowseDmp = "BrowseDmp";
public static String EditDmp = "EditDmp";
public static String ReviewDmp = "ReviewDmp";
public static String NewDmp = "NewDmp";
public static String DepositDmp = "DepositDmp";
public static String DeleteDmp = "DeleteDmp";
@ -105,6 +106,7 @@ public final class Permission {
//Description
public static String BrowseDescription = "BrowseDescription";
public static String ReviewDescription = "ReviewDescription";
public static String EditDescription = "EditDescription";
public static String FinalizeDescription = "FinalizeDescription";
public static String DeleteDescription = "DeleteDescription";

View File

@ -179,6 +179,18 @@ permissions:
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
ReviewDescription:
roles:
- TenantAdmin
dmp:
roles:
- Owner
- User
- DescriptionContributor
- Reviewer
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
EditDescription:
roles:
- TenantAdmin
@ -408,6 +420,18 @@ permissions:
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
ReviewDmp:
roles:
- TenantAdmin
dmp:
roles:
- Owner
- User
- DescriptionContributor
- Reviewer
clients: [ ]
allowAnonymous: false
allowAuthenticated: false
NewDmp:
roles:
- TenantAdmin

View File

@ -71,6 +71,7 @@ export enum AppPermission {
//Dmp
BrowseDmp = "BrowseDmp",
EditDmp = "EditDmp",
ReviewDmp = "ReviewDmp",
NewDmp = "NewDmp",
DepositDmp = "DepositDmp",
DeleteDmp = "DeleteDmp",
@ -103,10 +104,12 @@ export enum AppPermission {
//Description
BrowseDescription = "BrowseDescription",
ReviewDescription = "ReviewDescription",
EditDescription = "EditDescription",
FinalizeDescription = "FinalizeDescription",
DeleteDescription = "DeleteDescription",
CloneDescription = "CloneDescription",
ExportDescription = "ExportDescription",
//DescriptionTag
BrowseDescriptionTag = "BrowseDescriptionTag",

View File

@ -8,11 +8,11 @@
<mat-progress-bar color="primary" mode="indeterminate"></mat-progress-bar>
</div>
<div mat-dialog-content class="definition-content">
<app-description-form *ngIf="formGroup && formGroup.get('properties')" [propertiesFormGroup]="previewPropertiesFormGroup" [descriptionId]="descriptionId" [descriptionTemplate]="descriptionTemplate" [visibilityRulesService]="visibilityRulesService" [isNew]="true"></app-description-form>
<app-description-form *ngIf="formGroup && formGroup.get('properties')" [propertiesFormGroup]="previewPropertiesFormGroup" [descriptionId]="descriptionId" [descriptionTemplate]="descriptionTemplate" [canReview]="false" [visibilityRulesService]="visibilityRulesService" [isNew]="true"></app-description-form>
</div>
<div mat-mat-dialog-actions *ngIf="formGroup">
<div class="col-auto d-flex pb-4 pt-2">
<button mat-raised-button type="button" class="start-btn ml-auto" (click)="select()">{{'TYPES.EXTERNAL-DATASET-TYPE.SELECT' | translate}}</button>
</div>
</div>
</div>
</div>

View File

@ -104,7 +104,7 @@
</div>
<div [id]="'preview_container'+ form.get('id').value" class="row">
<div *ngIf="previewFieldSet && showPreview && firstField?.get('data')?.get('fieldType')?.value" class="col-12" [@fade-in-fast]>
<app-description-form-field-set class="w-100" [propertiesFormGroup]="previewPropertiesFormGroup" [fieldSet]="previewFieldSet" [visibilityRulesService]="visibilityRulesService" [hideAnnotations]="true"></app-description-form-field-set>
<app-description-form-field-set class="w-100" [canReview]="false" [propertiesFormGroup]="previewPropertiesFormGroup" [fieldSet]="previewFieldSet" [visibilityRulesService]="visibilityRulesService" [hideAnnotations]="true"></app-description-form-field-set>
</div>
</div>
</div>

View File

@ -1 +1 @@
<app-description-form *ngIf="previewPropertiesFormGroup" [propertiesFormGroup]="previewPropertiesFormGroup" [descriptionTemplate]="descriptionTemplate" [visibilityRulesService]="visibilityRulesService" [isNew]="true"></app-description-form>
<app-description-form *ngIf="previewPropertiesFormGroup" [canReview]="false" [propertiesFormGroup]="previewPropertiesFormGroup" [descriptionTemplate]="descriptionTemplate" [visibilityRulesService]="visibilityRulesService" [isNew]="true"></app-description-form>

View File

@ -176,14 +176,14 @@
<div class="row sticky-top table-container" style="top : 7em;">
<description-template-table-of-contents class="toc-pane-container col" style="margin-bottom: 2em;"
[links]="toCEntries"
(itemClick)="displayItem($event)"
(createEntry)="addNewEntry($event)"
(removeEntry)="onRemoveEntry($event)"
[itemSelected]="selectedTocEntry"
[viewOnly]="formGroup.disabled"
(dataNeedsRefresh)="onDataNeedsRefresh($event)"
<description-template-table-of-contents class="toc-pane-container col" style="margin-bottom: 2em;"
[links]="toCEntries"
(itemClick)="displayItem($event)"
(createEntry)="addNewEntry($event)"
(removeEntry)="onRemoveEntry($event)"
[itemSelected]="selectedTocEntry"
[viewOnly]="formGroup.disabled"
(dataNeedsRefresh)="onDataNeedsRefresh($event)"
[colorizeInvalid]="colorizeInvalid">
</description-template-table-of-contents>
</div>
@ -210,7 +210,7 @@
<div class="col-12">
<mat-form-field class="w-100">
<input type="text" matInput formControlName="title" [placeholder]="('DESCRIPTION-TEMPLATE-EDITOR.STEPS.GENERAL-INFO.UNTITLED' | translate) +' '+ ('DESCRIPTION-TEMPLATE-EDITOR.STEPS.PAGE-INFO.PAGE' |translate)">
<mat-error *ngIf="selectedTocEntry.form.get('title').hasError('backendError')">{{selectedTocEntry.form.get('title').getError('backendError').message}}</mat-error>
<mat-error *ngIf="selectedTocEntry.form.get('title').hasError('backendError')">{{selectedTocEntry.form.get('title').getError('backendError').message}}</mat-error>
<mat-error *ngIf="selectedTocEntry.form.get('title').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
</div>
@ -223,11 +223,11 @@
</div>
<div class="col-12" *ngIf="(selectedTocEntry.type === tocEntryEnumValues.Section) || (selectedTocEntry.type === tocEntryEnumValues.FieldSet)">
<app-description-template-editor-section-fieldset-component
[tocentry]="selectedTocEntry"
[viewOnly]="formGroup.disabled"
[datasetProfileId]="datasetProfileId"
[validationErrorModel]="editorModel.validationErrorModel"
<app-description-template-editor-section-fieldset-component
[tocentry]="selectedTocEntry"
[viewOnly]="formGroup.disabled"
[datasetProfileId]="datasetProfileId"
[validationErrorModel]="editorModel.validationErrorModel"
[validationRootPath]="selectedTocEntry.validationRootPath"
(addNewFieldSet)="addNewEntry({childType: tocEntryEnumValues.FieldSet,parent: {formGroup: $event}})" (removeFieldSet)="onRemoveEntry(_findTocEntryById($event, toCEntries))" (cloneFieldSet)="cloneFieldSet($event, selectedTocEntry.validationRootPath)" (selectedEntryId)="displayItem(_findTocEntryById($event, toCEntries))" (dataNeedsRefresh)="onDataNeedsRefresh()"
>
@ -270,7 +270,7 @@
<div class="col-9">
<div class="col">
<div class="col-12">
<app-final-preview-component [descriptionTemplatePersist]="finalPreviewDescriptionTemplatePersist">
<app-final-preview-component [descriptionTemplatePersist]="finalPreviewDescriptionTemplatePersist">
</app-final-preview-component>
</div>
@ -340,4 +340,4 @@
{{'DESCRIPTION-TEMPLATE-EDITOR.ACTIONS.FINALIZE' | translate}}
</button>
</div>
</ng-template>
</ng-template>

View File

@ -103,7 +103,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row mt-3 stepper-actions justify-content-around">
<div class="col-auto mb-1">
@ -150,6 +150,7 @@
[linkToScroll]="linkToScroll"
[validationErrorModel]="editorModel.validationErrorModel"
[isNew]="isNew || isCopy"
[canReview]="canReview"
(fieldsetFocusChange)="fieldsetIdWithFocus = $event"
></app-description-form>
</div>

View File

@ -63,6 +63,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
isNew = true;
isDeleted = false;
isCopy = false;
canReview = false;
item: Description;
fieldsetIdWithFocus: string;
fileTransformerEntityTypeEnum = FileTransformerEntityType;
@ -217,7 +218,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
});
dialogRef.afterClosed().subscribe((result: Description) => {
if (result) {
this.titleService.setTitle(result.label);
this.titleService.setTitle(result.label);
result.dmp = this.item.dmp;
result.dmpDescriptionTemplate = this.item.dmpDescriptionTemplate;
@ -582,19 +583,20 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
const descriptionSectionPermissionResolverModel: DescriptionSectionPermissionResolver = {
dmpId: this.item.dmp.id,
sectionIds: [this.item.dmpDescriptionTemplate.sectionId],
permissions: [AppPermission.EditDescription, AppPermission.DeleteDescription]
permissions: [AppPermission.EditDescription, AppPermission.DeleteDescription, AppPermission.FinalizeDescription, AppPermission.ReviewDescription]
}
this.descriptionService.getDescriptionSectionPermissions(descriptionSectionPermissionResolverModel)
.pipe(takeUntil(this._destroyed)).subscribe(
permissionPerSection => {
const canedit = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.EditDescription);
this.canReview = permissionPerSection && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()] && permissionPerSection[this.item.dmpDescriptionTemplate.sectionId.toString()].some(x => x === AppPermission.ReviewDescription);
this.formGroup = this.editorModel.buildForm(null, this.isDeleted || !canedit);
if (this.item.descriptionTemplate?.definition) this.visibilityRulesService.setContext(this.item.descriptionTemplate.definition, this.formGroup.get('properties'));
if (this.item.descriptionTemplate?.definition) this.pageToFieldSetMap = this.mapPageToFieldSet(this.item.descriptionTemplate);;
// this.selectedSystemFields = this.selectedSystemFieldDisabled();
this.descriptionEditorService.setValidationErrorModel(this.editorModel.validationErrorModel);
if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted) {
if (this.editorModel.status == DescriptionStatus.Finalized || this.isDeleted || !canedit) {
this.viewOnly = true;
this.isFinalized = true;
this.formGroup.disable();
@ -943,7 +945,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
get maxStep() {
return this.visibleFieldSets.length;
}
public nextStep() {
if (this.step < this.maxStep) {//view is changing
this.step = Math.floor(this.step + 1);
@ -990,9 +992,9 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
get countErrorsOfBaseInfoPage(): number {
if (this.formGroup == null) return 0;
let errorsCount: number = 0;
const baseInfoControlNames: string[] = [nameof<DescriptionEditorModel>(x => x.label), nameof<DescriptionEditorModel>(x => x.descriptionTemplateId)];
baseInfoControlNames.forEach((name: string) => {
if (this.formGroup.get(name)?.touched && !this.formGroup.get(name)?.valid) errorsCount += 1;
@ -1034,7 +1036,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
this.formGroup.get('properties').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(next => this.tocValidationService.validateForm());
// // const labelSubscription =
// this.formGroup.get('label').valueChanges
// .pipe(takeUntil(this._destroyed))
@ -1089,7 +1091,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
// this.getDefinition(profiledId);
}
}
mapPageToFieldSet(descriptionTemplate: DescriptionTemplate): Map<string, DescriptionFieldIndicator[]> {
const pageToFieldSetMap = new Map<string, DescriptionFieldIndicator[]>();
@ -1103,7 +1105,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
getFieldsetsOfPage(page: DescriptionTemplatePage): DescriptionFieldIndicator[] {
const fieldsByPage: DescriptionFieldIndicator[] = []
page.sections?.forEach((section: DescriptionTemplateSection) => {
let fieldsets = this.getNestedSectionFieldsets(section);
let fieldsBySection: DescriptionFieldIndicator[] = fieldsets?.flatMap((fieldset: DescriptionTemplateFieldSet) =>
@ -1126,7 +1128,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
else return section.fieldSets;
}
getNestedSectionIdsByField(section: DescriptionTemplateSection, fieldSetId: string): string[] {
if (section.sections) {
return [section.id, ...section.sections.flatMap((subsection: DescriptionTemplateSection) => this.getNestedSectionIdsByField(subsection, fieldSetId))];

View File

@ -55,6 +55,7 @@ export class DescriptionEditorResolver extends BaseEditorResolver {
[nameof<Description>(x => x.authorizationFlags), AppPermission.EditDescription].join('.'),
[nameof<Description>(x => x.authorizationFlags), AppPermission.DeleteDescription].join('.'),
[nameof<Description>(x => x.authorizationFlags), AppPermission.FinalizeDescription].join('.'),
[nameof<Description>(x => x.authorizationFlags), AppPermission.ReviewDescription].join('.'),
[nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'),
[nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),

View File

@ -6,7 +6,7 @@
<app-description-form-field-set-title class="row" [fieldSet]="fieldSet" [path]="path" [isChild]="isChild"></app-description-form-field-set-title>
</div>
<div *ngIf="!hideAnnotations" class="col-auto">
<button mat-icon-button class="col-auto annotation-icon" (click)="showAnnotations(fieldSet.id)" [disabled]="propertiesFormGroup.disabled">
<button mat-icon-button class="col-auto annotation-icon" (click)="showAnnotations(fieldSet.id)" [disabled]="!canReview">
<mat-icon matTooltip="{{'DATASET-EDITOR.QUESTION.EXTENDED-DESCRIPTION.ANNOTATIONS' | translate}}" [matBadge]="annotationsCount" [matBadgeHidden]="annotationsCount <= 0" matBadgeColor="warn">comment</mat-icon>
</button>
</div>

View File

@ -28,6 +28,7 @@ export class DescriptionFormFieldSetComponent extends BaseComponent {
@Input() propertiesFormGroup: UntypedFormGroup;
@Input() descriptionId: Guid;
@Input() hideAnnotations: boolean = false;
@Input() canReview: boolean = false;
get isMultiplicityEnabled() {
return this.fieldSet.hasMultiplicity && this.fieldSet.multiplicity != null;

View File

@ -23,6 +23,7 @@
[validationErrorModel]="validationErrorModel"
[isChild]="false"
[hideAnnotations]="isNew"
[canReview]="canReview"
></app-description-form-field-set>
</div>
</div>
@ -32,7 +33,7 @@
<div *ngIf="section?.sections?.length > 0" class="col-12">
<ng-container *ngFor="let innerSection of section.sections; let j = index;">
<div class="row" *ngIf="visibilityRulesService.isVisibleMap[innerSection.id]">
<app-description-form-section class="col-12" [section]="innerSection" [path]="path+'.'+(j+1)" [pathName]="pathName+'.sections.'+j" (askedToScroll)="onAskedToScroll($event)" [propertiesFormGroup]="propertiesFormGroup" [descriptionId]="descriptionId" [visibilityRulesService]="visibilityRulesService" [linkToScroll]="subsectionLinkToScroll"></app-description-form-section>
<app-description-form-section class="col-12" [section]="innerSection" [canReview]="canReview" [path]="path+'.'+(j+1)" [pathName]="pathName+'.sections.'+j" (askedToScroll)="onAskedToScroll($event)" [propertiesFormGroup]="propertiesFormGroup" [descriptionId]="descriptionId" [visibilityRulesService]="visibilityRulesService" [linkToScroll]="subsectionLinkToScroll"></app-description-form-section>
</div>
</ng-container>
</div>

View File

@ -19,6 +19,7 @@ import { Guid } from '@common/types/guid';
export class DescriptionFormSectionComponent extends BaseComponent implements OnInit, OnChanges {
@Input() isNew: boolean = false;
@Input() canReview: boolean = false;
@Input() section: DescriptionTemplateSection;
@Input() propertiesFormGroup: UntypedFormGroup;
@Input() visibilityRulesService: VisibilityRulesService;

View File

@ -15,7 +15,7 @@
</mat-expansion-panel-header>
<ng-container *ngFor="let section of page.sections; let i = index;">
<div class="row" *ngIf="visibilityRulesService.isVisibleMap[section.id]">
<app-description-form-section class="col-12" [section]="section" [path]="(z+1)+'.'+(i+1)" [pathName]="'pages.'+z+'.sections.'+i" [propertiesFormGroup]="propertiesFormGroup" [descriptionId]="descriptionId" [visibilityRulesService]="visibilityRulesService" (askedToScroll)="onAskedToScroll(expansionPanel, $event)" [linkToScroll]="linkToScroll" [validationErrorModel]="validationErrorModel" [isNew]="isNew"></app-description-form-section>
<app-description-form-section class="col-12" [section]="section" [canReview]="canReview" [path]="(z+1)+'.'+(i+1)" [pathName]="'pages.'+z+'.sections.'+i" [propertiesFormGroup]="propertiesFormGroup" [descriptionId]="descriptionId" [visibilityRulesService]="visibilityRulesService" (askedToScroll)="onAskedToScroll(expansionPanel, $event)" [linkToScroll]="linkToScroll" [validationErrorModel]="validationErrorModel" [isNew]="isNew"></app-description-form-section>
</div>
</ng-container>
</mat-expansion-panel>

View File

@ -21,6 +21,7 @@ export class DescriptionFormComponent extends BaseComponent implements OnInit, A
@Input() visibilityRulesService: VisibilityRulesService;
@Input() descriptionId: Guid;
@Input() isNew: boolean = false;
@Input() canReview: boolean = false;
// @ViewChild('stepper', { static: false }) stepper: MatStepper;
@Input() path: string;

View File

@ -37,7 +37,7 @@
</div>
</div>
<div class="row mb-4 pb-3">
<div *ngIf="canEdit && isDraftDescription(description) && !isLocked" class="col-auto pr-0">
<div *ngIf="(canEdit || canReview) && isDraftDescription(description) && !isLocked" class="col-auto pr-0">
<button (click)="editClicked(description)" mat-mini-fab class="mr-3 actions-btn" matTooltip="{{'DESCRIPTION-OVERVIEW.ACTIONS.EDIT' | translate}}" matTooltipPosition="above">
<mat-icon class="mat-mini-fab-icon">create</mat-icon>
</button>

View File

@ -68,6 +68,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
canEdit = false;
canDelete = false;
canFinalize = false;
canReview = false;
canInviteDmpUsers = false;
constructor(
@ -123,6 +124,9 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
this.canEdit = (this.authService.hasPermission(AppPermission.EditDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.EditDescription)) && this.description.belongsToCurrentTenant != false;
this.canReview = (this.authService.hasPermission(AppPermission.ReviewDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.ReviewDescription)) && this.description.belongsToCurrentTenant != false;
this.canFinalize = (this.authService.hasPermission(AppPermission.FinalizeDescription) ||
this.description.authorizationFlags?.some(x => x === AppPermission.FinalizeDescription)) && this.description.belongsToCurrentTenant != false;
@ -479,6 +483,7 @@ export class DescriptionOverviewComponent extends BaseComponent implements OnIni
[nameof<Description>(x => x.authorizationFlags), AppPermission.DeleteDescription].join('.'),
[nameof<Description>(x => x.authorizationFlags), AppPermission.FinalizeDescription].join('.'),
[nameof<Description>(x => x.authorizationFlags), AppPermission.InviteDmpUsers].join('.'),
[nameof<Description>(x => x.authorizationFlags), AppPermission.ReviewDescription].join('.'),
[nameof<Description>(x => x.descriptionTemplate), nameof<DescriptionTemplate>(x => x.id)].join('.'),
[nameof<Description>(x => x.descriptionTemplate), nameof<DescriptionTemplate>(x => x.label)].join('.'),