bug fixes

(cherry picked from commit 53b61853e1)
This commit is contained in:
Bernaldo Mihasi 2023-10-02 09:34:58 +03:00 committed by Diamantis Tziotzios
parent 94c0f7ac9c
commit c58de51b33
4 changed files with 20 additions and 13 deletions

View File

@ -82,7 +82,7 @@
<mat-form-field>
<mat-label>System fields</mat-label>
<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.type, sectionIndex)">{{f.label}}</mat-option>
</mat-select>
<mat-error *ngIf="fieldsArray(sectionIndex).hasError('required')">
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>

View File

@ -74,7 +74,6 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
{label: 'License', type: SystemFieldType.LICENSE},
{label: 'Access Rights', type: SystemFieldType.ACCESS_RIGHTS}
];
selectedSystemFields: string[] = [];
systemFieldListPerSection: Array<Array<any>> = new Array();
descriptionTemplatesPerSection: Array<Array<DatasetProfileModel>> = new Array<Array<DatasetProfileModel>>();
@ -195,9 +194,11 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
section.ordinal = this.sectionsArray().length + 1;
section.hasTemplates = false;
this.sectionsArray().push(section.buildForm());
this.systemFieldListPerSection.push(new Array());
}
removeSection(sectionIndex: number): void {
this.systemFieldListPerSection.splice(sectionIndex, 1);
this.sectionsArray().removeAt(sectionIndex);
}
@ -245,14 +246,14 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
return this.fieldList.find(f => f.type == type).label;
}
selectedFieldType(systemField: string, type: SystemFieldType, sectionIndex: number): void {
let index = this.selectedSystemFields.indexOf(systemField);
selectedFieldType(type: SystemFieldType, sectionIndex: number): void {
let index = this.systemFieldListPerSection[sectionIndex].indexOf(type);
if (index == -1) {
this.selectedSystemFields.push(systemField);
this.systemFieldListPerSection[sectionIndex].push(type);
this.addSystemField(sectionIndex, type);
}
else {
this.selectedSystemFields.splice(index, 1);
this.systemFieldListPerSection[sectionIndex].splice(index, 1);
this.removeSystemField(sectionIndex, type);
}
}
@ -273,6 +274,9 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
}
removeSystemFieldWithIndex(sectionIndex: number, fieldIndex: number): void {
let type: SystemFieldType = this.fieldsArray(sectionIndex).at(fieldIndex).get('type').value;
let index = this.systemFieldListPerSection[sectionIndex].indexOf(type);
this.systemFieldListPerSection[sectionIndex] = this.systemFieldListPerSection[sectionIndex].filter(types => types != type);
this.fieldsArray(sectionIndex).removeAt(fieldIndex);
}
@ -337,6 +341,9 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
dropSections(event: CdkDragDrop<string[]>) {
moveItemInArray(this.sectionsArray().controls, event.previousIndex, event.currentIndex);
moveItemInArray(this.sectionsArray().value, event.previousIndex, event.currentIndex);
this.sectionsArray().controls.forEach((section, index) => {
section.get('ordinal').setValue(index + 1);
});
}
moveItemInFormArray(formArray: FormArray, fromIndex: number, toIndex: number): void {
@ -430,12 +437,12 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie
hasTitle(): boolean {
const dmpBlueprint: DmpBlueprint = this.formGroup.value;
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => field.category as unknown === 'SYSTEM' && field.type === SystemFieldType.TEXT));
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category === FieldCategory.SYSTEM || field.category as unknown === 'SYSTEM') && field.type === SystemFieldType.TEXT));
}
hasDescription(): boolean {
const dmpBlueprint: DmpBlueprint = this.formGroup.value;
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => field.category as unknown === 'SYSTEM' && field.type === SystemFieldType.HTML_TEXT));
return dmpBlueprint.definition.sections.some(section => section.fields.some(field => (field.category === FieldCategory.SYSTEM || field.category as unknown === 'SYSTEM') && field.type === SystemFieldType.HTML_TEXT));
}
hasDescriptionTemplates(): boolean {

View File

@ -473,7 +473,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
}
hasProfile(sectionIndex: number): boolean {
return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.filter(x => x.data.dmpSectionIndex.includes(sectionIndex)).length > 0;
return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.some(x => x.data.dmpSectionIndex.includes(sectionIndex));
}
addDataset(dmpSectionIndex: number) {
@ -893,7 +893,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
else {
section.descriptionTemplates.forEach(template => {
this.sectionTemplates[section.ordinal - 1].push({id: template.descriptionTemplateId, label: template.label, description: ""})
let found: DmpDatasetProfile = templates.find(dmpDatasetProfile => dmpDatasetProfile.id == template.descriptionTemplateId);
let found: DmpDatasetProfile = templates.find(dmpDatasetProfile => dmpDatasetProfile.descriptionTemplateId == template.descriptionTemplateId);
if (found === undefined) {
let data: DmpDatasetProfileSectionsFormModel= new DmpDatasetProfileSectionsFormModel();
data.dmpSectionIndex.push(section.ordinal - 1);

View File

@ -30,14 +30,14 @@
<input class="hidden" #fileInput type="file" onClick="this.form.reset()" (change)="uploadFile($event)" accept="text/xml, application/json">
</form>
</div>
<div class="upload-form col-sm-12 col-md-12">
<!-- <div class="upload-form col-sm-12 col-md-12">
<mat-form-field>
<mat-label>{{'DMP-EDITOR.FIELDS.DATASET-TEMPLATES' | translate}}</mat-label>
<app-multiple-auto-complete [(ngModel)]="dmpProfiles" [configuration]="profilesAutoCompleteConfiguration" (optionActionClicked)="onPreviewTemplate($event)">
<!-- <app-multiple-auto-complete required='true' [(ngModel)]="dmpProfiles" placeholder="{{'DMP-EDITOR.FIELDS.DATASET-TEMPLATES' | translate}}" [configuration]="profilesAutoCompleteConfiguration" (optionActionClicked)="onPreviewTemplate($event)"> -->
<app-multiple-auto-complete required='true' [(ngModel)]="dmpProfiles" placeholder="{{'DMP-EDITOR.FIELDS.DATASET-TEMPLATES' | translate}}" [configuration]="profilesAutoCompleteConfiguration" (optionActionClicked)="onPreviewTemplate($event)">
</app-multiple-auto-complete>
</mat-form-field>
</div>
</div> -->
</div>
<div class="row mt-3">
<div class="col-auto ml-auto">