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",