Browse Source

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

pull/7538/head
Igor Kulikov 4 years ago
parent
commit
b96d3d02ac
  1. 16
      ui-ngx/src/app/core/utils.ts

16
ui-ngx/src/app/core/utils.ts

@ -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[] {

Loading…
Cancel
Save