hide undo finalize button in plan editor when plan is deposited

This commit is contained in:
amentis 2024-07-08 15:15:58 +03:00
parent 34873ca03c
commit cacfd9375d
3 changed files with 12 additions and 2 deletions

View File

@ -57,12 +57,12 @@
<button [disabled]="saving" mat-menu-item (click)="formSubmit()" type="button">{{ 'PLAN-EDITOR.ACTIONS.SAVE-AND-CONTINUE' | translate }}</button> <button [disabled]="saving" mat-menu-item (click)="formSubmit()" type="button">{{ 'PLAN-EDITOR.ACTIONS.SAVE-AND-CONTINUE' | translate }}</button>
</mat-menu> </mat-menu>
</div> </div>
<div class="col-auto d-flex align-items-center" *ngIf="canFinalize" [matTooltipDisabled]="canFinalize && formGroup.pristine" matTooltip="{{'PLAN-EDITOR.ACTIONS.FINALIZE.CAN-NOT-FINALIZE' | translate}}"> <div class="col-auto d-flex align-items-center" *ngIf="canFinalize && this.hasNotDoi()" [matTooltipDisabled]="canFinalize && formGroup.pristine" matTooltip="{{'PLAN-EDITOR.ACTIONS.FINALIZE.CAN-NOT-FINALIZE' | translate}}">
<button [disabled]="!formGroup.pristine" mat-raised-button class="save-btn mr-2" type="button" (click)="finalize()">{{ 'PLAN-EDITOR.ACTIONS.FINALIZE.FINALIZE' | translate }}</button> <button [disabled]="!formGroup.pristine" mat-raised-button class="save-btn mr-2" type="button" (click)="finalize()">{{ 'PLAN-EDITOR.ACTIONS.FINALIZE.FINALIZE' | translate }}</button>
</div> </div>
<div *ngIf="formGroup.pristine" class="col-auto d-flex align-items-center"> <div *ngIf="formGroup.pristine" class="col-auto d-flex align-items-center">
<button [disabled]="saving" *ngIf="isLocked" mat-raised-button class="save-btn mr-2" type="button">{{ 'PLAN-EDITOR.ACTIONS.LOCKED' | translate}}</button> <button [disabled]="saving" *ngIf="isLocked" mat-raised-button class="save-btn mr-2" type="button">{{ 'PLAN-EDITOR.ACTIONS.LOCKED' | translate}}</button>
<button [disabled]="saving" *ngIf="canReverseFinalize" mat-raised-button class="save-btn mr-2" type="button" (click)="reverseFinalization()">{{ 'PLAN-EDITOR.ACTIONS.REVERSE' | translate }}</button> <button [disabled]="saving" *ngIf="canReverseFinalize && this.hasNotDoi()" mat-raised-button class="save-btn mr-2" type="button" (click)="reverseFinalization()">{{ 'PLAN-EDITOR.ACTIONS.REVERSE' | translate }}</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -227,6 +227,7 @@ export class PlanEditorComponent extends BaseEditor<PlanEditorModel, Plan> imple
if (data.planDescriptionTemplates) { if (data.planDescriptionTemplates) {
data.planDescriptionTemplates = data.planDescriptionTemplates.filter(x => x.isActive === IsActive.Active); data.planDescriptionTemplates = data.planDescriptionTemplates.filter(x => x.isActive === IsActive.Active);
} }
if (data.entityDois && data.entityDois.length > 0) data.entityDois = data.entityDois.filter(x => x.isActive === IsActive.Active);
} }
this.item = data; this.item = data;
@ -400,6 +401,10 @@ export class PlanEditorComponent extends BaseEditor<PlanEditorModel, Plan> imple
}); });
} }
hasNotDoi() {
return (this.item.entityDois == null || this.item.entityDois.length == 0);
}
finalize() { finalize() {
const dialogRef = this.dialog.open(PlanFinalizeDialogComponent, { const dialogRef = this.dialog.open(PlanFinalizeDialogComponent, {
maxWidth: '500px', maxWidth: '500px',

View File

@ -14,6 +14,7 @@ import { BaseEditorResolver } from '@common/base/base-editor.resolver';
import { Guid } from '@common/types/guid'; import { Guid } from '@common/types/guid';
import { takeUntil, tap } from 'rxjs/operators'; import { takeUntil, tap } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof'; import { nameof } from 'ts-simple-nameof';
import { EntityDoi } from '@app/core/model/entity-doi/entity-doi';
@Injectable() @Injectable()
export class PlanEditorEntityResolver extends BaseEditorResolver { export class PlanEditorEntityResolver extends BaseEditorResolver {
@ -84,6 +85,10 @@ export class PlanEditorEntityResolver extends BaseEditorResolver {
[nameof<Plan>(x => x.planDescriptionTemplates), nameof<PlanDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'), [nameof<Plan>(x => x.planDescriptionTemplates), nameof<PlanDescriptionTemplate>(x => x.descriptionTemplateGroupId)].join('.'),
[nameof<Plan>(x => x.planDescriptionTemplates), nameof<PlanDescriptionTemplate>(x => x.isActive)].join('.'), [nameof<Plan>(x => x.planDescriptionTemplates), nameof<PlanDescriptionTemplate>(x => x.isActive)].join('.'),
[nameof<Plan>(x => x.entityDois), nameof<EntityDoi>(x => x.id)].join('.'),
[nameof<Plan>(x => x.entityDois), nameof<EntityDoi>(x => x.repositoryId)].join('.'),
[nameof<Plan>(x => x.entityDois), nameof<EntityDoi>(x => x.doi)].join('.'),
[nameof<Plan>(x => x.entityDois), nameof<EntityDoi>(x => x.isActive)].join('.'),
...PlanEditorEntityResolver.blueprintLookupFields(nameof<Plan>(x => x.blueprint)), ...PlanEditorEntityResolver.blueprintLookupFields(nameof<Plan>(x => x.blueprint)),