From 3651b16b2c9b1d1879a9503477ab33e0cf231de7 Mon Sep 17 00:00:00 2001
From: Giuseppe Digilio <giuseppe.digilio@4science.it>
Date: Wed, 21 Aug 2019 09:52:38 +0200
Subject: [PATCH] Fixed issue with form value init within relation fields

---
 .../dynamic-relation-group.components.ts           | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.components.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.components.ts
index 1485993375..62b6b4effa 100644
--- a/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.components.ts
+++ b/src/app/shared/form/builder/ds-dynamic-form-ui/models/relation-group/dynamic-relation-group.components.ts
@@ -129,11 +129,11 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
           || this.selectedChipItem.item[model.name].value === PLACEHOLDER_PARENT_METADATA)
           ? null
           : this.selectedChipItem.item[model.name];
-        if (isNotNull(value)) {
-          const nextValue = (this.formBuilderService.isInputModel(model) && (typeof value !== 'string')) ?
-            value.value : value;
-          model.valueUpdates.next(nextValue);
-        }
+
+        const nextValue = (this.formBuilderService.isInputModel(model) && isNotNull(value) && (typeof value !== 'string')) ?
+          value.value : value;
+        model.valueUpdates.next(nextValue);
+
       });
     });
 
@@ -231,7 +231,7 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
         flatMap((valueModel) => {
           const returnList: Array<Observable<any>> = [];
           valueModel.forEach((valueObj) => {
-            const returnObj =  Object.keys(valueObj).map((fieldName) => {
+            const returnObj = Object.keys(valueObj).map((fieldName) => {
               let return$: Observable<any>;
               if (isObject(valueObj[fieldName]) && valueObj[fieldName].hasAuthority() && isNotEmpty(valueObj[fieldName].authority)) {
                 const fieldId = fieldName.replace(/\./g, '_');
@@ -255,7 +255,7 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
               } else {
                 return$ = observableOf(valueObj[fieldName]);
               }
-              return return$.pipe(map((entry) => ({[fieldName]: entry})));
+              return return$.pipe(map((entry) => ({ [fieldName]: entry })));
             });
 
             returnList.push(combineLatest(returnObj));
-- 
GitLab