add can remove description template logic in dmp editor
This commit is contained in:
parent
db90097c16
commit
1e2eb7545d
|
@ -299,6 +299,7 @@
|
||||||
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
|
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
|
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
|
||||||
|
<!-- <app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="getDescriptionTemplateMultipleAutoCompleteConfiguration(section.id)" (optionActionClicked)="onPreviewDescriptionTemplate($event, section.id)"> -->
|
||||||
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionActionClicked)="onPreviewDescriptionTemplate($event, section.id)" (optionRemoved)="onRemoveDescriptionTemplate($event, section.id)">
|
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionActionClicked)="onPreviewDescriptionTemplate($event, section.id)" (optionRemoved)="onRemoveDescriptionTemplate($event, section.id)">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error>
|
||||||
|
|
|
@ -51,6 +51,8 @@ import { DmpEditorModel, DmpFieldIndicator } from './dmp-editor.model';
|
||||||
import { DmpEditorResolver } from './dmp-editor.resolver';
|
import { DmpEditorResolver } from './dmp-editor.resolver';
|
||||||
import { DmpEditorService } from './dmp-editor.service';
|
import { DmpEditorService } from './dmp-editor.service';
|
||||||
import { DescriptionTemplatePreviewDialogComponent } from '@app/ui/admin/description-template/description-template-preview/description-template-preview-dialog.component';
|
import { DescriptionTemplatePreviewDialogComponent } from '@app/ui/admin/description-template/description-template-preview/description-template-preview-dialog.component';
|
||||||
|
import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
|
||||||
|
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-editor',
|
selector: 'app-dmp-editor',
|
||||||
|
@ -93,6 +95,20 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
valueAssign: (item: DmpBlueprint) => item.id,
|
valueAssign: (item: DmpBlueprint) => item.id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getDescriptionTemplateMultipleAutoCompleteConfiguration(sectionId: Guid): MultipleAutoCompleteConfiguration {
|
||||||
|
return {
|
||||||
|
initialItems: (excludedItems: any[], data?: any) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup(null, excludedItems ? excludedItems : null)).pipe(map(x => x.items)),
|
||||||
|
filterFn: (searchQuery: string, excludedItems: any[]) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup(searchQuery, excludedItems)).pipe(map(x => x.items)),
|
||||||
|
getSelectedItems: (selectedItems: any[]) => this.descriptionTemplateService.query(this.descriptionTemplateService.buildDescriptionTempalteGroupAutocompleteLookup(null, null, selectedItems)).pipe(map(x => x.items)),
|
||||||
|
displayFn: (item: DescriptionTemplate) => item.label,
|
||||||
|
titleFn: (item: DescriptionTemplate) => item.label,
|
||||||
|
subtitleFn: (item: DescriptionTemplate) => item.description,
|
||||||
|
valueAssign: (item: DescriptionTemplate) => item.groupId,
|
||||||
|
canRemoveItem: (item: DescriptionTemplate) => this.canRemoveDescriptionTemplate(item, sectionId),
|
||||||
|
popupItemActionIcon: 'visibility'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
sectionToFieldsMap: Map<string, DmpFieldIndicator> = new Map<string, DmpFieldIndicator>();
|
sectionToFieldsMap: Map<string, DmpFieldIndicator> = new Map<string, DmpFieldIndicator>();
|
||||||
|
|
||||||
protected get canDelete(): boolean {
|
protected get canDelete(): boolean {
|
||||||
|
@ -620,6 +636,23 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canRemoveDescriptionTemplate(item: DescriptionTemplate, sectionId){
|
||||||
|
if(item){
|
||||||
|
const descriptionsInSection = this.descriptionsInSection(sectionId);
|
||||||
|
|
||||||
|
if (descriptionsInSection && descriptionsInSection.length > 0){
|
||||||
|
for (let index = 0; index < descriptionsInSection.length; index++) {
|
||||||
|
const description = descriptionsInSection[index];
|
||||||
|
if(description.dmpDescriptionTemplate?.descriptionTemplateGroupId === item.groupId) {
|
||||||
|
return {canRemove: false,
|
||||||
|
message: 'DMP-EDITOR.UNSUCCESSFUL-REMOVE-TEMPLATE'
|
||||||
|
} as CanRemoveDescriptionTemplate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// Misc
|
// Misc
|
||||||
|
@ -633,3 +666,8 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
return this.languageInfoService.getLanguageInfoValues();
|
return this.languageInfoService.getLanguageInfoValues();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CanRemoveDescriptionTemplate {
|
||||||
|
canRemove: boolean;
|
||||||
|
message: string;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue