Added a check to null value

This commit is contained in:
Giuseppe Digilio
2019-02-07 19:08:53 +01:00
parent f934a6aa71
commit dc6709c2b5

View File

@@ -29,7 +29,7 @@ import { SubmissionFormsModel } from '../../../../../../core/config/models/confi
import { FormService } from '../../../../form.service'; import { FormService } from '../../../../form.service';
import { FormComponent } from '../../../../form.component'; import { FormComponent } from '../../../../form.component';
import { Chips } from '../../../../../chips/models/chips.model'; import { Chips } from '../../../../../chips/models/chips.model';
import { hasValue, isEmpty, isNotEmpty } from '../../../../../empty.util'; import { hasValue, isEmpty, isNotEmpty, isNotNull } from '../../../../../empty.util';
import { shrinkInOut } from '../../../../../animations/shrink'; import { shrinkInOut } from '../../../../../animations/shrink';
import { ChipsItem } from '../../../../../chips/models/chips-item.model'; import { ChipsItem } from '../../../../../chips/models/chips-item.model';
import { GlobalConfig } from '../../../../../../../config/global-config.interface'; import { GlobalConfig } from '../../../../../../../config/global-config.interface';
@@ -129,7 +129,9 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
|| this.selectedChipItem.item[model.name].value === PLACEHOLDER_PARENT_METADATA) || this.selectedChipItem.item[model.name].value === PLACEHOLDER_PARENT_METADATA)
? null ? null
: this.selectedChipItem.item[model.name]; : this.selectedChipItem.item[model.name];
model.valueUpdates.next(this.formBuilderService.isInputModel(model) ? value.value : value); if (isNotNull(value)) {
model.valueUpdates.next(this.formBuilderService.isInputModel(model) ? value.value : value);
}
}); });
}); });
@@ -227,8 +229,7 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
flatMap((valueModel) => { flatMap((valueModel) => {
const returnList: Array<Observable<any>> = []; const returnList: Array<Observable<any>> = [];
valueModel.forEach((valueObj) => { valueModel.forEach((valueObj) => {
let returnObj = Object.create({}); const returnObj = Object.keys(valueObj).map((fieldName) => {
returnObj = Object.keys(valueObj).map((fieldName) => {
let return$: Observable<any>; let return$: Observable<any>;
if (isObject(valueObj[fieldName]) && valueObj[fieldName].hasAuthority() && isNotEmpty(valueObj[fieldName].authority)) { if (isObject(valueObj[fieldName]) && valueObj[fieldName].hasAuthority() && isNotEmpty(valueObj[fieldName].authority)) {
const fieldId = fieldName.replace(/\./g, '_'); const fieldId = fieldName.replace(/\./g, '_');
@@ -294,7 +295,7 @@ export class DsDynamicRelationGroupComponent extends DynamicFormControlComponent
this.EnvConfig.submission.icons.metadata); this.EnvConfig.submission.icons.metadata);
this.subs.push( this.subs.push(
this.chips.chipsItems this.chips.chipsItems
.subscribe((subItems: any[]) => { .subscribe(() => {
const items = this.chips.getChipsItems(); const items = this.chips.getChipsItems();
// Does not emit change if model value is equal to the current value // Does not emit change if model value is equal to the current value
if (!isEqual(items, this.model.value)) { if (!isEqual(items, this.model.value)) {