diff --git a/dmp-frontend/src/app/core/formatting.module.ts b/dmp-frontend/src/app/core/formatting.module.ts index afa46884f..cac6237cb 100644 --- a/dmp-frontend/src/app/core/formatting.module.ts +++ b/dmp-frontend/src/app/core/formatting.module.ts @@ -7,6 +7,8 @@ import { TimezoneInfoDisplayPipe } from './pipes/timezone-info-display.pipe'; import { EnumUtils } from './services/utilities/enum-utils.service'; import { JsonParserPipe } from './pipes/json-parser.pipe'; import { DateTimeCultureFormatPipe } from './pipes/date-time-culture-format.pipe'; +import {FieldValuePipe} from "@app/core/pipes/field-value.pipe"; +import {ColumnClassPipe} from "@app/core/pipes/column-class.pipe"; // // @@ -21,7 +23,9 @@ import { DateTimeCultureFormatPipe } from './pipes/date-time-culture-format.pipe DateFormatPipe, DateTimeFormatPipe, DateTimeCultureFormatPipe, - JsonParserPipe + JsonParserPipe, + FieldValuePipe, + ColumnClassPipe ], exports: [ NgForLimitPipe, @@ -29,7 +33,9 @@ import { DateTimeCultureFormatPipe } from './pipes/date-time-culture-format.pipe DateFormatPipe, DateTimeFormatPipe, DateTimeCultureFormatPipe, - JsonParserPipe + JsonParserPipe, + FieldValuePipe, + ColumnClassPipe ], providers: [ EnumUtils, @@ -39,7 +45,9 @@ import { DateTimeCultureFormatPipe } from './pipes/date-time-culture-format.pipe DateFormatPipe, DateTimeFormatPipe, DateTimeCultureFormatPipe, - JsonParserPipe + JsonParserPipe, + FieldValuePipe, + ColumnClassPipe ] }) export class FormattingModule { } diff --git a/dmp-frontend/src/app/core/pipes/column-class.pipe.ts b/dmp-frontend/src/app/core/pipes/column-class.pipe.ts new file mode 100644 index 000000000..d51bccd28 --- /dev/null +++ b/dmp-frontend/src/app/core/pipes/column-class.pipe.ts @@ -0,0 +1,11 @@ +import {Pipe, PipeTransform} from "@angular/core"; + +@Pipe({ + name: 'columnClass' +}) +export class ColumnClassPipe implements PipeTransform{ + + transform(value: number): any { + return 'col-' + Math.ceil(12/value); + } +} diff --git a/dmp-frontend/src/app/core/pipes/field-value.pipe.ts b/dmp-frontend/src/app/core/pipes/field-value.pipe.ts new file mode 100644 index 000000000..a4f7873c2 --- /dev/null +++ b/dmp-frontend/src/app/core/pipes/field-value.pipe.ts @@ -0,0 +1,56 @@ +import {Pipe, PipeTransform} from "@angular/core"; +import {DatePipe} from "@angular/common"; +import {DatasetProfileFieldViewStyle} from "@app/core/common/enum/dataset-profile-field-view-style"; + +@Pipe({ + name: 'fieldValue' +}) +export class FieldValuePipe implements PipeTransform { + + constructor(private date: DatePipe) { + } + + transform(controlValue: any): string | null { + let value = controlValue.value; + let renderStyle = controlValue.viewStyle?.renderStyle; + if (renderStyle && controlValue) { + switch (renderStyle) { + case DatasetProfileFieldViewStyle.Currency: + if (value) { + return JSON.parse(value).name; + } + break; + case DatasetProfileFieldViewStyle.BooleanDecision: + return value == 'true' ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO'; + case DatasetProfileFieldViewStyle.CheckBox: + return value ? 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.YES' : 'DATASET-PROFILE-EDITOR.STEPS.FORM.FIELD.DEFAULT-VALUES.BOOLEAN-DECISION.NO'; + case DatasetProfileFieldViewStyle.RadioBox: + if (value && controlValue.data.options) { + return controlValue.data.options.find(option => option.value === value).label; + } + break; + case DatasetProfileFieldViewStyle.DatePicker: + return this.date.transform(controlValue.value, 'dd/MM/yyyy'); + case DatasetProfileFieldViewStyle.FreeText: + return value; + case DatasetProfileFieldViewStyle.ComboBox: + if (value && controlValue.data.options && !controlValue.data.multiList) { + return controlValue.data.options.find(option => value == option.value).label; + } else if (value && controlValue.data.options && controlValue.data.multiList) { + return controlValue.data.options.filter(option => value.includes(option.value)).map(option => option.label).join(','); + } + break; + case DatasetProfileFieldViewStyle.RichTextArea: + if(value) { + return value.replace(/ /g, ' ').replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ").replace(/<[^>]*>/g, ''); + } + break; + case DatasetProfileFieldViewStyle.TextArea: + return value; + default: + return null; + } + } + return null; + } +} diff --git a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html index 2e4c57737..4d514f606 100644 --- a/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html +++ b/dmp-frontend/src/app/ui/admin/dataset-profile/editor/components/composite-field/dataset-profile-editor-composite-field.component.html @@ -204,7 +204,7 @@
- +
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html new file mode 100644 index 000000000..db7baaf85 --- /dev/null +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.html @@ -0,0 +1,15 @@ +
+
+
+ close +
+
+
+ +
+
+
+
+
+
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts new file mode 100644 index 000000000..db4e95837 --- /dev/null +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field-dialog/form-composite-field-dialog.component.ts @@ -0,0 +1,30 @@ +import {Component, Inject} from "@angular/core"; +import {MAT_DIALOG_DATA, MatDialogRef} from "@angular/material/dialog"; +import {VisibilityRulesService} from "@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service"; + +@Component({ + selector: 'app-form-composite-field-dialog', + templateUrl: 'form-composite-field-dialog.component.html' +}) +export class FormCompositeFieldDialogComponent { + + constructor( + private visibilityRulesService: VisibilityRulesService, + private dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public data: any + ) { + this.visibilityRulesService.buildVisibilityRules([], this.data.formGroup); + } + + cancel() { + this.dialogRef.close(); + } + + save() { + this.dialogRef.close(this.data.formGroup); + } + + public close() { + this.dialogRef.close(false); + } +} diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.html index a158ea875..7302fa874 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.html +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-composite-field/form-composite-field.component.html @@ -1,20 +1,19 @@ -
- +
-
+
-
- -
+ [datasetProfileId]="datasetProfileId" [isChild]="isChild"> +
+ +
-
+
@@ -37,6 +36,9 @@ Add one more field +
--> +
+
{{this.fieldFormGroup.get('data').value.label}}
+
- + @@ -32,8 +33,8 @@ -
diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts index b3937f33a..4fdfb42e4 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/dataset-description.component.ts @@ -40,7 +40,7 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit private visibilityRulesService: VisibilityRulesService, ) { super(); - + } ngOnInit() { @@ -48,7 +48,7 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit const rules_to_append = this._enrichWithMultiplicityRules(this.tocentries); this.visibilityRulesService.buildVisibilityRules([...this.visibilityRules, ...rules_to_append ], this.form); - + // if (this.form) { // this.form.valueChanges // .pipe(takeUntil(this._destroyed)) @@ -57,7 +57,7 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit // }); // } this.visibilityRulesInstance.emit(this.visibilityRulesService); - + @@ -139,15 +139,15 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit const childIdsWithVisRules = (entry.form.get('fields') as FormArray).controls.reduce((all, s) => { const sval = s.value as Field; - return this.visibilityRules.find(x => (x.targetField === sval.id) || (x.sourceField === sval.id)) ? [...all, sval] : all; + return this.visibilityRules.find(x => (x.targetField === sval.id) || (x.sourceField === sval.id)) ? [...all, sval] : all; },[]) as Field[]; - + const innerCompositeFieldOriginalIds = (entry.form.get('fields') as FormArray).controls.map( x=> x.get('id').value) as string[]; //multiplicity items const multiplicityItemsValue = entry.form.get('multiplicityItems').value as CompositeField[]; - + // ********* FIELDS OF FIELDSET ARE EITHER TARGETS OR SOURCES ***** @@ -210,7 +210,7 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit const newRule = {...x, targetField: field.id, sourceField: idMappings.find(l => l.original === x.sourceField).multiplicityIdValue} as Rule; rules_to_append.push(newRule); }) - + //outer dependencies const outerDep = original_as_target.filter( x=> !innerCompositeFieldOriginalIds.includes(x.sourceField)); outerDep.forEach(x=>{ @@ -222,10 +222,10 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit }) }); } - - - - + + + + // ** FIELDSET ITSELF IS TARGET // ** source it can never be @@ -239,7 +239,7 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit if(compositeFieldAsTargetRules.length){ - + compositeFieldAsTargetRules.forEach(x =>{ idCompositeFieldMappings.forEach(l=>{ const newRule = {...x, targetField: l.newValue}; @@ -264,7 +264,7 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit const tempResult:ToCEntry[] = []; - + if(sections &§ions.length){ sections.controls.forEach(section=>{ tempResult.push(this._buildRecursively(section as FormGroup, ToCEntryType.Section)); @@ -300,9 +300,9 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit } private _sortByOrdinal(tocentries: ToCEntry[]){ - + if(!tocentries || !tocentries.length) return; - + tocentries.sort(this._customCompare); tocentries.forEach(entry=>{ this._sortByOrdinal(entry.subEntries); @@ -327,7 +327,6 @@ export class DatasetDescriptionComponent extends BaseComponent implements OnInit }); } - getTocEntries(): ToCEntry[] { if (!this.form) { return []; } const result: ToCEntry[] = []; diff --git a/dmp-frontend/src/app/utilities/enhancers/utils.ts b/dmp-frontend/src/app/utilities/enhancers/utils.ts index 6749dc1be..6b439858f 100644 --- a/dmp-frontend/src/app/utilities/enhancers/utils.ts +++ b/dmp-frontend/src/app/utilities/enhancers/utils.ts @@ -1,3 +1,5 @@ +import {AbstractControl, FormArray, FormControl, FormGroup} from "@angular/forms"; + export function isNullOrUndefined(object: any): boolean { return object === null || object === undefined; } @@ -5,3 +7,40 @@ export function isNullOrUndefined(object: any): boolean { export function isNumeric(val: any): val is number | string { return !Array.isArray(val) && (val - parseFloat(val) + 1) >= 0; } + +/** + * Deep clones the given AbstractControl, preserving values, validators, async validators, and disabled status. + * @param control AbstractControl + * @returns AbstractControl + */ +export function cloneAbstractControl(control: T): T { + let newControl: T; + + if (control instanceof FormGroup) { + const formGroup = new FormGroup({}, control.validator, control.asyncValidator); + const controls = control.controls; + + Object.keys(controls).forEach(key => { + formGroup.addControl(key, cloneAbstractControl(controls[key])); + }) + + newControl = formGroup as any; + } + else if (control instanceof FormArray) { + const formArray = new FormArray([], control.validator, control.asyncValidator); + + control.controls.forEach(formControl => formArray.push(cloneAbstractControl(formControl))) + + newControl = formArray as any; + } + else if (control instanceof FormControl) { + newControl = new FormControl(control.value, control.validator, control.asyncValidator) as any; + } + else { + throw new Error('Error: unexpected control value'); + } + + if (control.disabled) newControl.disable({emitEvent: false}); + + return newControl; +} diff --git a/dmp-frontend/src/assets/i18n/de.json b/dmp-frontend/src/assets/i18n/de.json index 0151e067a..b0bb08552 100644 --- a/dmp-frontend/src/assets/i18n/de.json +++ b/dmp-frontend/src/assets/i18n/de.json @@ -376,6 +376,7 @@ "MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text", "MULTIPLICITY-TABLEVIEW": "View inputs in table", "MULTIPLICITY-ADD-ONE-FIELD": "Add more", + "MULTIPLICITY-ADD-ONE-FIELD-TABLEVIEW": "Add row", "ORDER": "Order", "COMMENT-PLACEHOLDER": "Please Specify", "COMMENT-HINT": "Provide additional information or justification about your selection", diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 69d60cc52..df22f30a4 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -376,6 +376,7 @@ "MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text", "MULTIPLICITY-TABLEVIEW": "View inputs in table", "MULTIPLICITY-ADD-ONE-FIELD": "Add more", + "MULTIPLICITY-ADD-ONE-FIELD-TABLEVIEW": "Add row", "ORDER": "Order", "COMMENT-PLACEHOLDER": "Please Specify", "COMMENT-HINT": "Provide additional information or justification about your selection", diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json index 47e474d41..70cfcdb58 100644 --- a/dmp-frontend/src/assets/i18n/es.json +++ b/dmp-frontend/src/assets/i18n/es.json @@ -376,6 +376,7 @@ "MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text", "MULTIPLICITY-TABLEVIEW": "View inputs in table", "MULTIPLICITY-ADD-ONE-FIELD": "Add more", + "MULTIPLICITY-ADD-ONE-FIELD-TABLEVIEW": "Add row", "ORDER": "Orden", "COMMENT-PLACEHOLDER": "Por favir especifique", "COMMENT-HINT": "Proporcione información adicional o justifique su selección", diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json index f8fb87a90..d3af38d8b 100644 --- a/dmp-frontend/src/assets/i18n/gr.json +++ b/dmp-frontend/src/assets/i18n/gr.json @@ -376,6 +376,7 @@ "MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text", "MULTIPLICITY-TABLEVIEW": "View inputs in table", "MULTIPLICITY-ADD-ONE-FIELD": "Add more", + "MULTIPLICITY-ADD-ONE-FIELD-TABLEVIEW": "Add row", "ORDER": "Εντολή", "COMMENT-PLACEHOLDER": "Παρακαλώ προσδιορίστε", "COMMENT-HINT": "Προσθέστε επιπλέον πληροφορίες ή αιτιολόγηση σχετικά με την επιλογή σας", diff --git a/dmp-frontend/src/assets/i18n/hr.json b/dmp-frontend/src/assets/i18n/hr.json index e42b19f7c..d8cf96b04 100644 --- a/dmp-frontend/src/assets/i18n/hr.json +++ b/dmp-frontend/src/assets/i18n/hr.json @@ -376,6 +376,7 @@ "MULTIPLICITY-PLACEHOLDER": "", "MULTIPLICITY-TABLEVIEW": "View inputs in table", "MULTIPLICITY-ADD-ONE-FIELD": "Dodaj polje", + "MULTIPLICITY-ADD-ONE-FIELD-TABLEVIEW": "Add row", "ORDER": "Redoslijed", "COMMENT-PLACEHOLDER": "Navedite", "COMMENT-HINT": "Navedite dodatne informacije ili obrazložite izbor", diff --git a/dmp-frontend/src/assets/i18n/pl.json b/dmp-frontend/src/assets/i18n/pl.json index 2e6d9a053..7da15ad21 100644 --- a/dmp-frontend/src/assets/i18n/pl.json +++ b/dmp-frontend/src/assets/i18n/pl.json @@ -376,6 +376,7 @@ "MULTIPLICITY-PLACEHOLDER": "$Tekst zastępujący wielokrotność$", "MULTIPLICITY-TABLEVIEW": "View inputs in table", "MULTIPLICITY-ADD-ONE-FIELD": "Dodaj więcej", + "MULTIPLICITY-ADD-ONE-FIELD-TABLEVIEW": "Add row", "ORDER": "Kolejność", "COMMENT-PLACEHOLDER": "Proszę doprecyzować", "COMMENT-HINT": "Podaj dodatkowe informacje lub uzasadnienie swojego wyboru", diff --git a/dmp-frontend/src/assets/i18n/pt.json b/dmp-frontend/src/assets/i18n/pt.json index 6fea92d60..4ca2b3594 100644 --- a/dmp-frontend/src/assets/i18n/pt.json +++ b/dmp-frontend/src/assets/i18n/pt.json @@ -376,6 +376,7 @@ "MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text", "MULTIPLICITY-TABLEVIEW": "View inputs in table", "MULTIPLICITY-ADD-ONE-FIELD": "Add more", + "MULTIPLICITY-ADD-ONE-FIELD-TABLEVIEW": "Add row", "ORDER": "Ordem", "COMMENT-PLACEHOLDER": "Por favor especifique", "COMMENT-HINT": "Disponibilize informação ou justificação adicional sobre a sua seleção", diff --git a/dmp-frontend/src/assets/i18n/sk.json b/dmp-frontend/src/assets/i18n/sk.json index 6486d5afa..2ba6af1c0 100644 --- a/dmp-frontend/src/assets/i18n/sk.json +++ b/dmp-frontend/src/assets/i18n/sk.json @@ -376,6 +376,7 @@ "MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text", "MULTIPLICITY-TABLEVIEW": "View inputs in table", "MULTIPLICITY-ADD-ONE-FIELD": "Add more", + "MULTIPLICITY-ADD-ONE-FIELD-TABLEVIEW": "Add row", "ORDER": "Order", "COMMENT-PLACEHOLDER": "Please Specify", "COMMENT-HINT": "Provide additional information or justification about your selection", diff --git a/dmp-frontend/src/assets/i18n/sr.json b/dmp-frontend/src/assets/i18n/sr.json index 914b6694c..8e2bbb956 100644 --- a/dmp-frontend/src/assets/i18n/sr.json +++ b/dmp-frontend/src/assets/i18n/sr.json @@ -376,6 +376,7 @@ "MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text", "MULTIPLICITY-TABLEVIEW": "View inputs in table", "MULTIPLICITY-ADD-ONE-FIELD": "Add more", + "MULTIPLICITY-ADD-ONE-FIELD-TABLEVIEW": "Add row", "ORDER": "Redosled", "COMMENT-PLACEHOLDER": "Navedite", "COMMENT-HINT": "Navedite dodatne informacije ili obrazložite izbor", diff --git a/dmp-frontend/src/assets/i18n/tr.json b/dmp-frontend/src/assets/i18n/tr.json index 81806e879..3e1450b96 100644 --- a/dmp-frontend/src/assets/i18n/tr.json +++ b/dmp-frontend/src/assets/i18n/tr.json @@ -376,6 +376,7 @@ "MULTIPLICITY-PLACEHOLDER": "Multiplicity Placeholder Text", "MULTIPLICITY-TABLEVIEW": "View inputs in table", "MULTIPLICITY-ADD-ONE-FIELD": "Add more", + "MULTIPLICITY-ADD-ONE-FIELD-TABLEVIEW": "Add row", "ORDER": "Düzen", "COMMENT-PLACEHOLDER": "Lütfen Belirtiniz", "COMMENT-HINT": "Seçiminiz hakkında gerekçe veya ek bilgi veriniz",