Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring

This commit is contained in:
Sofia Papacharalampous 2024-03-22 11:49:08 +02:00
commit 0d40d56484
3 changed files with 9 additions and 11 deletions

View File

@ -15,7 +15,7 @@
</div> </div>
<div class="col"></div> <div class="col"></div>
<div class="col-auto" *ngIf="!isNew"> <div class="col-auto" *ngIf="!isNew">
<button [disabled]="!isLockedByUser" mat-button class="action-btn" type="button" (click)="delete()"> <button [disabled]="isLocked" mat-button class="action-btn" type="button" (click)="delete()">
<mat-icon>delete</mat-icon> <mat-icon>delete</mat-icon>
{{'DMP-BLUEPRINT-EDITOR.ACTIONS.DELETE' | translate}} {{'DMP-BLUEPRINT-EDITOR.ACTIONS.DELETE' | translate}}
</button> </button>

View File

@ -47,7 +47,7 @@
</mat-menu> </mat-menu>
</div> </div>
<mat-divider *ngIf="formGroup.get('id').value && (!viewOnly || (isLockedByUser && !viewOnly) || !isLockedByUser || (hasReversableStatus() && isLockedByUser))" [vertical]="true" class="ml-2 mr-2"></mat-divider> <mat-divider *ngIf="formGroup.get('id').value && (!viewOnly || (!isLocked && !viewOnly) || isLocked || (hasReversableStatus() && !isLocked))" [vertical]="true" class="ml-2 mr-2"></mat-divider>
<div *ngIf="isDirty() && !viewOnly" class="col-auto d-flex align-items-center pr-0"> <div *ngIf="isDirty() && !viewOnly" class="col-auto d-flex align-items-center pr-0">
<button [disabled]="saving" type="button" mat-raised-button class="description-discard-btn" (click)="discardChanges()"> <button [disabled]="saving" type="button" mat-raised-button class="description-discard-btn" (click)="discardChanges()">
@ -55,7 +55,7 @@
</button> </button>
</div> </div>
<div class="col-auto d-flex align-items-center"> <div class="col-auto d-flex align-items-center">
<button [disabled]="saving" *ngIf="isLockedByUser && !viewOnly && hasReversableStatus() == false" mat-raised-button class="description-save-btn mr-2" type="button"> <button [disabled]="saving" *ngIf="!isLocked && !viewOnly && hasReversableStatus() == false" mat-raised-button class="description-save-btn mr-2" type="button">
<span class="d-flex flex-row row"> <span class="d-flex flex-row row">
<span (click)="!saving?formSubmit():null" class="col">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE' | translate }}</span> <span (click)="!saving?formSubmit():null" class="col">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE' | translate }}</span>
<mat-divider [vertical]="true"></mat-divider> <mat-divider [vertical]="true"></mat-divider>
@ -73,9 +73,9 @@
<button [disabled]="saving" mat-menu-item (click)="save()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CONTINUE' | translate }}</button> <button [disabled]="saving" mat-menu-item (click)="save()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-CONTINUE' | translate }}</button>
</mat-menu> </mat-menu>
<button [disabled]="saving" *ngIf="isLockedByUser && !viewOnly && hasReversableStatus() == false" mat-raised-button class="description-save-btn mr-2" type="button" (click)="finalize()">{{ 'DESCRIPTION-EDITOR.ACTIONS.FINALIZE' | translate }}</button> <button [disabled]="saving" *ngIf="!isLocked && !viewOnly && hasReversableStatus() == false" mat-raised-button class="description-save-btn mr-2" type="button" (click)="finalize()">{{ 'DESCRIPTION-EDITOR.ACTIONS.FINALIZE' | translate }}</button>
<button [disabled]="saving" *ngIf="!isLockedByUser" mat-raised-button disabled class="description-save-btn cursor-default" type="button">{{ 'DMP-OVERVIEW.LOCKED' | translate}}</button> <button [disabled]="saving" *ngIf="isLocked" mat-raised-button disabled class="description-save-btn cursor-default" type="button">{{ 'DMP-OVERVIEW.LOCKED' | translate}}</button>
<button [disabled]="saving" *ngIf="hasReversableStatus() && isLockedByUser" mat-raised-button class="description-save-btn mr-2" (click)="reverse()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.REVERSE' | translate }}</button> <button [disabled]="saving" *ngIf="hasReversableStatus() && !isLocked" mat-raised-button class="description-save-btn mr-2" (click)="reverse()" type="button">{{ 'DESCRIPTION-EDITOR.ACTIONS.REVERSE' | translate }}</button>
</div> </div>
</div> </div>
</div> </div>
@ -116,7 +116,7 @@
<div>{{'DESCRIPTION-EDITOR.TOC.NEXT' | translate}}</div> <div>{{'DESCRIPTION-EDITOR.TOC.NEXT' | translate}}</div>
<span class="material-icons">chevron_right</span> <span class="material-icons">chevron_right</span>
</div> </div>
<button [disabled]="saving" (click)="save(saveAnd.addNew)" *ngIf="(step === maxStep) && isLockedByUser && formGroup.get('descriptionTemplateId').value && !viewOnly" mat-raised-button type="button" class="col-auto stepper-btn add-description-btn ml-auto"> <button [disabled]="saving" (click)="save(saveAnd.addNew)" *ngIf="(step === maxStep) && !isLocked && formGroup.get('descriptionTemplateId').value && !viewOnly" mat-raised-button type="button" class="col-auto stepper-btn add-description-btn ml-auto">
{{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-ADD-NEW' | translate }} {{ 'DESCRIPTION-EDITOR.ACTIONS.SAVE-AND-ADD-NEW' | translate }}
</button> </button>
</div> </div>

View File

@ -186,14 +186,12 @@ export abstract class BaseEditor<EditorModelType extends BaseEditorModel, Entity
message: this.language.instant(message) message: this.language.instant(message)
}, maxWidth: '30em' }, maxWidth: '30em'
}); });
} else{
this.isLockedByUser = true;
} }
if (!this.isLocked && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) { if (!this.isLocked && !isNullOrUndefined(this.authService.currentAccountIsAuthenticated())) {
// lock it. // lock it.
this.lockService.lock(itemId, targetType).pipe(takeUntil(this._destroyed)).subscribe(async result => { this.lockService.lock(itemId, targetType).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.isLocked = true; this.isLockedByUser = true;
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.touchLock(itemId)); interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.touchLock(itemId));
}); });
} }
@ -211,6 +209,6 @@ export abstract class BaseEditor<EditorModelType extends BaseEditorModel, Entity
ngOnDestroy(): void { ngOnDestroy(): void {
super.ngOnDestroy(); super.ngOnDestroy();
if(this.isLocked) this.unlockTarget(this.editorModel.id); if(this.isLockedByUser) this.unlockTarget(this.editorModel.id);
} }
} }