UI: Fixed flatDataWithoutOverride - create empty object when data array is empty.

This commit is contained in:
Igor Kulikov 2022-11-03 09:47:02 +02:00
parent e03994c2ea
commit b96d3d02ac

View File

@ -478,16 +478,16 @@ export function flatFormattedData(input: FormattedData[]): FormattedData {
return result; return result;
} }
export function flatDataWithoutOverride(data: FormattedData[]): FormattedData { export function flatDataWithoutOverride(input: FormattedData[]): FormattedData {
const processingKeyValue = data[0]; const result: FormattedData = {} as FormattedData;
for (let i = 1; i < data.length; i++) { input.forEach((data) => {
Object.keys(data[i]).forEach((key) => { Object.keys(data).forEach((key) => {
if (!isDefinedAndNotNull(processingKeyValue[key]) || isEmptyStr(processingKeyValue[key])) { if (!isDefinedAndNotNull(result[key]) || isEmptyStr(result[key])) {
processingKeyValue[key] = data[i][key]; result[key] = data[key];
} }
}); });
} });
return processingKeyValue; return result;
} }
export function mergeFormattedData(first: FormattedData[], second: FormattedData[]): FormattedData[] { export function mergeFormattedData(first: FormattedData[], second: FormattedData[]): FormattedData[] {