import { Component, Input } from '@angular/core'; import { UntypedFormGroup } from '@angular/forms'; import { DescriptionTemplate } from '@app/core/model/description-template/description-template'; import { BaseComponent } from '@common/base/base.component'; @Component({ selector: 'app-description-base-fields-editor-component', templateUrl: 'description-base-fields-editor.component.html', styleUrls: ['./description-base-fields-editor.component.scss'] }) export class DescriptionBaseFieldsEditorComponent extends BaseComponent { @Input() formGroup: UntypedFormGroup; @Input() availableDescriptionTemplates: DescriptionTemplate[]; @Input() dmpId: string; viewOnly = false; //TODO: not used. constructor( ) { super(); } checkMinMax(event, profile: DescriptionTemplate) { //TODO: Add logic for validating description templates. // event.stopPropagation(); // const dmpSectionIndex = this.formGroup.get('dmpSectionIndex').value; // const blueprintId = this.formGroup.get('dmp').value.profile.id; // this.dmpBlueprintService.getSingle(blueprintId, // [ // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.id)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.label)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.description)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.hasTemplates)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.id)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.category)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.dataType)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.systemFieldType)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.label)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.placeholder)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.description)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.required)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fields), nameof(x => x.ordinal)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.id)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.descriptionTemplateId)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.label)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.minMultiplicity)].join('.'), // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.descriptionTemplates), nameof(x => x.maxMultiplicity)].join('.'), // ] // ) // .pipe(takeUntil(this._destroyed)) // .subscribe(result => { // const section = result.definition.sections[dmpSectionIndex]; // if(section.hasTemplates){ // const foundTemplate = section.descriptionTemplates.find(template => template.descriptionTemplateId === Guid.parse(profile.id)); // if (foundTemplate !== undefined) { // let count = 0; // if(this.formGroup.get('dmp').value.datasets != null){ // for(let dataset of this.formGroup.get('dmp').value.datasets){ // if(dataset.dmpSectionIndex === dmpSectionIndex && dataset.profile.id === foundTemplate.descriptionTemplateId){ // count++; // } // } // if(count === foundTemplate.maxMultiplicity){ // this.dialog.open(PopupNotificationDialogComponent, { // data: { // title: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.TITLE'), // message: this.language.instant('DATASET-EDITOR.MAX-DESCRIPTION-DIALOG.MESSAGE') // }, maxWidth: '30em' // }); // } // else{ // this.formGroup.get('profile').setValue(profile); // } // } // } // else { // this.formGroup.get('profile').setValue(profile); // } // } // else { // this.formGroup.get('profile').setValue(profile); // } // }); } public compareWith(object1: any, object2: any) { return object1 && object2 && object1.id === object2.id; } }