Fixed merge issue

This commit is contained in:
Giuseppe Digilio
2018-06-11 11:55:02 +02:00
parent b17cb180bb
commit 98f79a7f67
4 changed files with 55 additions and 4 deletions

View File

@@ -81,7 +81,7 @@ export class DsDynamicGroupComponent implements OnDestroy, OnInit {
this.formId = this.formService.getUniqueId(this.model.id);
this.formModel = this.formBuilderService.modelFromConfiguration(config, this.model.scopeUUID, {});
this.chips = new Chips(this.model.value, 'value', this.model.mandatoryField, this.EnvConfig.submission.metadata.icons);
this.chips = new Chips(this.model.value, 'value', this.model.mandatoryField);
this.subs.push(
this.chips.chipsItems
.subscribe((subItems: any[]) => {

View File

@@ -1,4 +1,4 @@
import { isNotEmpty } from '../../../empty.util';
import { isNotEmpty, isNotNull } from '../../../empty.util';
export class FormFieldMetadataValueObject {
metadata?: string;

View File

@@ -2,6 +2,5 @@ export enum NotificationType {
Success = 'alert-success',
Error = 'alert-danger',
Info = 'alert-info',
Warning = 'alert-warning',
// Bare = 'bare'
Warning = 'alert-warning'
}

View File

@@ -0,0 +1,52 @@
import { isNotEmpty } from './empty.util';
import { isEqual, isObject, transform } from 'lodash';
/**
* Returns passed object without specified property
*/
export function deleteProperty(object, key): object {
const {[key]: deletedKey, ...otherKeys} = object;
return otherKeys;
}
/**
* Returns true if the passed value is null or undefined.
* hasNoValue(); // true
* hasNoValue(null); // true
* hasNoValue(undefined); // true
* hasNoValue(''); // false
* hasNoValue({}); // false
* hasNoValue([]); // false
* hasNoValue(function() {}); // false
*/
export function isObjectEmpty(obj: any): boolean {
const objectType = typeof obj;
if (objectType === 'object') {
if (Object.keys(obj).length === 0) {
return true;
} else {
let result = true;
for (const key in obj) {
if (isNotEmpty(obj[key])) {
result = false;
break;
}
}
return result;
}
}
}
export function difference(object, base) {
const changes = (o, b) => {
return transform(o, (result, value, key) => {
if (!isEqual(value, b[key]) && isNotEmpty(value)) {
const resultValue = (isObject(value) && isObject(b[key])) ? changes(value, b[key]) : value;
if (!isObjectEmpty(resultValue)) {
result[key] = resultValue;
}
}
});
};
return changes(object, base);
}