Fixed an issue with place property removal from object that represent metadata section field on rest side

This commit is contained in:
Giuseppe Digilio
2019-04-04 12:43:17 +02:00
parent bbc27febdd
commit 71c0c1b52c
2 changed files with 8 additions and 8 deletions

View File

@@ -27,16 +27,16 @@ export function isServerFormValue(obj: any): boolean {
&& obj.hasOwnProperty('value') && obj.hasOwnProperty('value')
&& obj.hasOwnProperty('language') && obj.hasOwnProperty('language')
&& obj.hasOwnProperty('authority') && obj.hasOwnProperty('authority')
&& obj.hasOwnProperty('confidence') && obj.hasOwnProperty('confidence'))
&& obj.hasOwnProperty('place'))
} }
/** /**
* Export a function to normalize sections object of the server response * Export a function to normalize sections object of the server response
* *
* @param obj * @param obj
* @param objIndex
*/ */
export function normalizeSectionData(obj: any) { export function normalizeSectionData(obj: any, objIndex?: number) {
let result: any = obj; let result: any = obj;
if (isNotNull(obj)) { if (isNotNull(obj)) {
// If is an Instance of FormFieldMetadataValueObject normalize it // If is an Instance of FormFieldMetadataValueObject normalize it
@@ -49,14 +49,14 @@ export function normalizeSectionData(obj: any) {
obj.language, obj.language,
obj.authority, obj.authority,
(obj.display || obj.value), (obj.display || obj.value),
obj.place, obj.place || objIndex,
obj.confidence, obj.confidence,
obj.otherInformation obj.otherInformation
); );
} else if (Array.isArray(obj)) { } else if (Array.isArray(obj)) {
result = []; result = [];
obj.forEach((item, index) => { obj.forEach((item, index) => {
result[index] = normalizeSectionData(item); result[index] = normalizeSectionData(item, index);
}); });
} else if (typeof obj === 'object') { } else if (typeof obj === 'object') {
result = Object.create({}); result = Object.create({});
@@ -141,9 +141,9 @@ export class SubmissionResponseParsingService extends BaseResponseParsingService
// If entry is not an array, for sure is not a section of type form // If entry is not an array, for sure is not a section of type form
if (Array.isArray(entry)) { if (Array.isArray(entry)) {
normalizedSectionData[metdadataId] = []; normalizedSectionData[metdadataId] = [];
entry.forEach((valueItem) => { entry.forEach((valueItem, index) => {
// Parse value and normalize it // Parse value and normalize it
const normValue = normalizeSectionData(valueItem); const normValue = normalizeSectionData(valueItem, index);
if (isNotEmpty(normValue)) { if (isNotEmpty(normValue)) {
normalizedSectionData[metdadataId].push(normValue); normalizedSectionData[metdadataId].push(normValue);
} }

View File

@@ -168,7 +168,7 @@ export class DsDynamicTagComponent extends DynamicFormControlComponent implement
} }
private addTagsToChips() { private addTagsToChips() {
if (!this.hasAuthority || !this.model.authorityOptions.closed) { if (hasValue(this.currentValue) && (!this.hasAuthority || !this.model.authorityOptions.closed)) {
let res: string[] = []; let res: string[] = [];
res = this.currentValue.split(','); res = this.currentValue.split(',');