Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,6 @@ export class SummaryCardComponent
}

// update card list and scroll behavior according to the card items display

this.cards = newCards;
if (
this.settings.widgetDisplay?.usePagination ||
Expand Down Expand Up @@ -635,12 +634,15 @@ export class SummaryCardComponent
this.cachedCards.splice(
start,
items.length,
...((items || []).map((x: any, index: number) => ({
...this.settings.card,
rawValue: x,
index,
metadata,
})) as CardT[])
...((items || []).map((x: any, index: number) => {
this.fixDiferenteType(metadata, x);
return {
...this.settings.card,
rawValue: x,
index,
metadata,
};
}) as CardT[])
);

const isPaginated = !!strategy && !!pageInfo;
Expand Down Expand Up @@ -710,6 +712,33 @@ export class SummaryCardComponent
this.loading = false;
}

/**
* Fix the diference between the type of the metadata and the type of the data received
*
* @param metadata metadata
* @param x data
*/
fixDiferenteType(metadata: any[], x: any) {
for (const meta of metadata) {
if (meta.type === 'boolean' && typeof x[meta.label] != 'boolean') {
x[meta.label] = this.toBool(x[meta.label]);
}
}
}

/**
* convert any type to boolean
*
* @param value value to convert
* @returns boolean value
*/
toBool(value: any) {
if (typeof value === 'string') {
return value.toLowerCase() === 'true';
}
return Boolean(value);
}

/**
* Set the pagination info
*
Expand Down