disable system fields/description templates multiple select input and prefill them if any values exist when blueprint is finalized

This commit is contained in:
Bernaldo Mihasi 2023-09-21 09:31:30 +03:00
parent 69548e5a8b
commit 3c0dce93a8
2 changed files with 16 additions and 3 deletions

View File

@ -81,7 +81,7 @@
<div class="col-6"> <div class="col-6">
<mat-form-field> <mat-form-field>
<mat-label>System fields</mat-label> <mat-label>System fields</mat-label>
<mat-select multiple [value]="systemFieldListPerSection[0]"> <mat-select multiple [disabled]="viewOnly" [value]="systemFieldListPerSection[sectionIndex]">
<mat-option *ngFor="let f of fieldList" [disabled]="systemFieldDisabled(f.type, sectionIndex)" [value]="f.type" (click)="selectedFieldType(f.label, f.type, sectionIndex)">{{f.label}}</mat-option> <mat-option *ngFor="let f of fieldList" [disabled]="systemFieldDisabled(f.type, sectionIndex)" [value]="f.type" (click)="selectedFieldType(f.label, f.type, sectionIndex)">{{f.label}}</mat-option>
</mat-select> </mat-select>
<mat-error *ngIf="fieldsArray(sectionIndex).hasError('required')"> <mat-error *ngIf="fieldsArray(sectionIndex).hasError('required')">
@ -218,7 +218,7 @@
<div class="col-12"> <div class="col-12">
<mat-form-field> <mat-form-field>
<mat-label>Description Templates</mat-label> <mat-label>Description Templates</mat-label>
<app-multiple-auto-complete placeholder="Description Templates" [hidePlaceholder]="true" required='false' [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event, sectionIndex)" (optionSelected)="onOptionSelected($event, sectionIndex)"> <app-multiple-auto-complete placeholder="Description Templates" [disabled]="viewOnly" [value]="descriptionTemplatesPerSection[sectionIndex]" [hidePlaceholder]="true" required='false' [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event, sectionIndex)" (optionSelected)="onOptionSelected($event, sectionIndex)">
</app-multiple-auto-complete> </app-multiple-auto-complete>
<!-- <button matSuffix class="input-btn" (click)="allAvailableProfiles($event)"> <!-- <button matSuffix class="input-btn" (click)="allAvailableProfiles($event)">
<mat-icon class="icon-btn">view_list</mat-icon> <mat-icon class="icon-btn">view_list</mat-icon>

View File

@ -76,6 +76,7 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
]; ];
selectedSystemFields: string[] = []; selectedSystemFields: string[] = [];
systemFieldListPerSection: Array<Array<any>> = new Array(); systemFieldListPerSection: Array<Array<any>> = new Array();
descriptionTemplatesPerSection: Array<Array<DatasetProfileModel>> = new Array<Array<DatasetProfileModel>>();
constructor( constructor(
private dmpProfileService: DmpProfileService, private dmpProfileService: DmpProfileService,
@ -121,6 +122,7 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
this.dmpBlueprintModel = new DmpBlueprintEditor().fromModel(data); this.dmpBlueprintModel = new DmpBlueprintEditor().fromModel(data);
this.formGroup = this.dmpBlueprintModel.buildForm(); this.formGroup = this.dmpBlueprintModel.buildForm();
this.buildSystemFields(); this.buildSystemFields();
this.fillDescriptionTemplatesInMultAutocomplete();
if (this.dmpBlueprintModel.status == DmpProfileStatus.Finalized) { if (this.dmpBlueprintModel.status == DmpProfileStatus.Finalized) {
this.formGroup.disable(); this.formGroup.disable();
this.viewOnly = true this.viewOnly = true
@ -156,13 +158,24 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
let systemFieldsInSection = new Array(); let systemFieldsInSection = new Array();
this.fieldsArray(i).controls.forEach((field) => { this.fieldsArray(i).controls.forEach((field) => {
if((field.get('category').value == FieldCategory.SYSTEM || field.get('category').value == 'SYSTEM')){ if((field.get('category').value == FieldCategory.SYSTEM || field.get('category').value == 'SYSTEM')){
systemFieldsInSection.push(this.fieldList.find(f => f.type == field.get('type').value).label); systemFieldsInSection.push(this.fieldList.find(f => f.type == field.get('type').value).type);
} }
}) })
this.systemFieldListPerSection.push(systemFieldsInSection); this.systemFieldListPerSection.push(systemFieldsInSection);
} }
} }
fillDescriptionTemplatesInMultAutocomplete(){
const sections = this.sectionsArray().controls.length;
for(let i = 0; i < sections; i++){
let descriptionTemplatesInSection = new Array<DatasetProfileModel>();
this.descriptionTemplatesArray(i).controls.forEach((template) => {
descriptionTemplatesInSection.push({id: template.value.descriptionTemplateId, label: template.value.label, description: ""});
})
this.descriptionTemplatesPerSection.push(descriptionTemplatesInSection);
}
}
filterProfiles(value: string): Observable<DatasetProfileModel[]> { filterProfiles(value: string): Observable<DatasetProfileModel[]> {
const request = new DataTableRequest<DatasetProfileCriteria>(null, null, { fields: ['+label'] }); const request = new DataTableRequest<DatasetProfileCriteria>(null, null, { fields: ['+label'] });
const criteria = new DatasetProfileCriteria(); const criteria = new DatasetProfileCriteria();