disable add description in dmp editor when description templates is not selected
This commit is contained in:
parent
91bef6f7f0
commit
e5abbe9aae
|
@ -104,8 +104,14 @@
|
||||||
</ol>
|
</ol>
|
||||||
<ul *ngIf="item.id && section.hasTemplates && canEditSection(section.id) && !formGroup.disabled" class="add-description-option">
|
<ul *ngIf="item.id && section.hasTemplates && canEditSection(section.id) && !formGroup.disabled" class="add-description-option">
|
||||||
<li>
|
<li>
|
||||||
<a class="add-description-action" [ngClass]="{'drag-handle-disabled': !canAddDescription(section)}" [routerLink]="canAddDescription(section) ? ['/descriptions/edit/' + item.id + '/' + section.id] : null">
|
<a class="add-description-action" [ngClass]="{'drag-handle-disabled': !hasDescriptionTemplates(section) || !hasValidMultiplicity(section)}" [routerLink]="hasDescriptionTemplates(section) && hasValidMultiplicity(section) ? ['/descriptions/edit/' + item.id + '/' + section.id] : null">
|
||||||
<mat-icon [matTooltipDisabled]="canAddDescription(section)" [matTooltip]="'DMP-EDITOR.DESCRIPTION-TEMPLATES-MAX-MULTIPLICITY' | translate">add</mat-icon>{{'DMP-EDITOR.ACTIONS.ADD-DESCRIPTION-IN-SECTION' | translate}}
|
<ng-container *ngIf="!hasDescriptionTemplates(section)" >
|
||||||
|
<mat-icon [matTooltipDisabled]="hasDescriptionTemplates(section)" [matTooltip]="'DMP-EDITOR.DESCRIPTION-TEMPLATES.EMPTY' | translate">add</mat-icon>{{'DMP-EDITOR.ACTIONS.ADD-DESCRIPTION-IN-SECTION' | translate}}
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngIf="hasDescriptionTemplates(section)">
|
||||||
|
<mat-icon [matTooltipDisabled]="hasValidMultiplicity(section)" [matTooltip]="'DMP-EDITOR.DESCRIPTION-TEMPLATES.MAX-MULTIPLICITY' | translate">add</mat-icon>{{'DMP-EDITOR.ACTIONS.ADD-DESCRIPTION-IN-SECTION' | translate}}
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -298,9 +298,11 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
//Transform descriptionTemplates
|
//Transform descriptionTemplates
|
||||||
formData.descriptionTemplates = [];
|
formData.descriptionTemplates = [];
|
||||||
for (const sectionId in (this.formGroup.get('descriptionTemplates') as UntypedFormGroup).controls) {
|
for (const sectionId in (this.formGroup.get('descriptionTemplates') as UntypedFormGroup).controls) {
|
||||||
formData.descriptionTemplates.push(
|
if (this.formGroup.get('descriptionTemplates').get(sectionId).value != undefined){
|
||||||
...(this.formGroup.get('descriptionTemplates').get(sectionId).value as Guid[]).map(x => { return { sectionId: Guid.parse(sectionId), descriptionTemplateGroupId: x } })
|
formData.descriptionTemplates.push(
|
||||||
);
|
...(this.formGroup.get('descriptionTemplates').get(sectionId).value as Guid[]).map(x => { return { sectionId: Guid.parse(sectionId), descriptionTemplateGroupId: x } })
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dmpService.persist(formData)
|
this.dmpService.persist(formData)
|
||||||
|
@ -572,7 +574,12 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
canAddDescription(section: DmpBlueprintDefinitionSection): boolean {
|
hasDescriptionTemplates(section: DmpBlueprintDefinitionSection): boolean {
|
||||||
|
if (this.item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id).length > 0) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
hasValidMultiplicity(section: DmpBlueprintDefinitionSection): boolean {
|
||||||
if (section.hasTemplates) {
|
if (section.hasTemplates) {
|
||||||
if (section.descriptionTemplates?.length > 0) {
|
if (section.descriptionTemplates?.length > 0) {
|
||||||
const descriptions = this.descriptionsInSection(section.id)
|
const descriptions = this.descriptionsInSection(section.id)
|
||||||
|
|
Loading…
Reference in New Issue