fixes for replacing/moving

This commit is contained in:
lotte
2020-02-19 17:04:37 +01:00
parent 1a6f67d12e
commit c98a4a1c3f
7 changed files with 107 additions and 47 deletions

View File

@@ -7,7 +7,7 @@ import {
} from '../json-patch-operations.actions';
import { JsonPatchOperationPathObject } from './json-patch-operation-path-combiner';
import { Injectable } from '@angular/core';
import { isEmpty, isNotEmpty } from '../../../shared/empty.util';
import { hasNoValue, isEmpty, isNotEmpty } from '../../../shared/empty.util';
import { dateToISOFormat } from '../../../shared/date.util';
import { AuthorityValue } from '../../integration/models/authority.value';
import { FormFieldMetadataValueObject } from '../../../shared/form/builder/models/form-field-metadata-value.model';
@@ -53,12 +53,16 @@ export class JsonPatchOperationsBuilder {
* a boolean representing if the value to be added is a plain text value
*/
replace(path: JsonPatchOperationPathObject, value, plain = false) {
this.store.dispatch(
new NewPatchReplaceOperationAction(
path.rootElement,
path.subRootElement,
path.path,
this.prepareValue(value, plain, false)));
if (hasNoValue(value) || (typeof value === 'object' && hasNoValue(value.value))) {
this.remove(path);
} else {
this.store.dispatch(
new NewPatchReplaceOperationAction(
path.rootElement,
path.subRootElement,
path.path,
this.prepareValue(value, plain, false)));
}
}
move(path: JsonPatchOperationPathObject, prevPath: string) {