use native groupBy

This commit is contained in:
Mads Rasmussen
2023-11-06 20:16:17 +01:00
parent 56327ed5b0
commit 1d1bba7938

View File

@@ -139,12 +139,16 @@ export class UmbDataTypePickerFlowModalElement extends UmbLitElement {
}
private _performFiltering() {
if (this.#currentFilterQuery) {
this._groupedDataTypes = groupBy(
this.#dataTypes.filter((dataType) => {
return dataType.name?.toLowerCase().includes(this.#currentFilterQuery);
}),
'meta.group',
const filteredDataTypes = this.#dataTypes.filter(
(dataType) => dataType.name?.toLowerCase().includes(this.#currentFilterQuery),
);
/* TODO: data type items doesn't have a group property. We will need a reference to the property editor UI to get the group.
this is a temp solution to group them as uncategorized. The same result as with the lodash groupBy.
*/
this._groupedDataTypes = {
undefined: filteredDataTypes,
};
} else {
this._groupedDataTypes = undefined;
}
@@ -158,7 +162,13 @@ export class UmbDataTypePickerFlowModalElement extends UmbLitElement {
);
});
this._groupedPropertyEditorUIs = groupBy(filteredUIs, 'meta.group');
// TODO: groupBy is not known by TS yet
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
this._groupedPropertyEditorUIs = Object.groupBy(
filteredUIs,
(propertyEditorUI: ManifestPropertyEditorUi) => propertyEditorUI.meta.group,
);
}
private _close() {