mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-15 22:13:02 +00:00
Fixed an issue with place property removal from object that represent metadata section field on rest side
This commit is contained in:
@@ -27,16 +27,16 @@ export function isServerFormValue(obj: any): boolean {
|
||||
&& obj.hasOwnProperty('value')
|
||||
&& obj.hasOwnProperty('language')
|
||||
&& obj.hasOwnProperty('authority')
|
||||
&& obj.hasOwnProperty('confidence')
|
||||
&& obj.hasOwnProperty('place'))
|
||||
&& obj.hasOwnProperty('confidence'))
|
||||
}
|
||||
|
||||
/**
|
||||
* Export a function to normalize sections object of the server response
|
||||
*
|
||||
* @param obj
|
||||
* @param objIndex
|
||||
*/
|
||||
export function normalizeSectionData(obj: any) {
|
||||
export function normalizeSectionData(obj: any, objIndex?: number) {
|
||||
let result: any = obj;
|
||||
if (isNotNull(obj)) {
|
||||
// If is an Instance of FormFieldMetadataValueObject normalize it
|
||||
@@ -49,14 +49,14 @@ export function normalizeSectionData(obj: any) {
|
||||
obj.language,
|
||||
obj.authority,
|
||||
(obj.display || obj.value),
|
||||
obj.place,
|
||||
obj.place || objIndex,
|
||||
obj.confidence,
|
||||
obj.otherInformation
|
||||
);
|
||||
} else if (Array.isArray(obj)) {
|
||||
result = [];
|
||||
obj.forEach((item, index) => {
|
||||
result[index] = normalizeSectionData(item);
|
||||
result[index] = normalizeSectionData(item, index);
|
||||
});
|
||||
} else if (typeof obj === 'object') {
|
||||
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 (Array.isArray(entry)) {
|
||||
normalizedSectionData[metdadataId] = [];
|
||||
entry.forEach((valueItem) => {
|
||||
entry.forEach((valueItem, index) => {
|
||||
// Parse value and normalize it
|
||||
const normValue = normalizeSectionData(valueItem);
|
||||
const normValue = normalizeSectionData(valueItem, index);
|
||||
if (isNotEmpty(normValue)) {
|
||||
normalizedSectionData[metdadataId].push(normValue);
|
||||
}
|
||||
|
Reference in New Issue
Block a user