mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-22 21:50:34 +03:00
Fix list undefined group (#2979)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
ad4394d541
commit
2a11846d6e
@ -132,7 +132,7 @@
|
||||
</script>
|
||||
|
||||
{#each categories as category, i (typeof category === 'object' ? category.name : category)}
|
||||
{@const items = groupByKey === noCategory || category === undefined ? docs : getGroupByValues(groupByDocs, category)}
|
||||
{@const items = groupByKey === noCategory ? docs : getGroupByValues(groupByDocs, category)}
|
||||
<ListCategory
|
||||
{elementByIndex}
|
||||
{indexById}
|
||||
|
@ -506,11 +506,7 @@ export type FixedWidthStore = Record<string, number>
|
||||
|
||||
export const fixedWidthStore = writable<FixedWidthStore>({})
|
||||
|
||||
export function groupBy<T extends Doc> (
|
||||
docs: T[],
|
||||
key: string,
|
||||
categories?: CategoryType[]
|
||||
): { [key: string | number]: T[] } {
|
||||
export function groupBy<T extends Doc> (docs: T[], key: string, categories?: CategoryType[]): Record<any, T[]> {
|
||||
return docs.reduce((storage: { [key: string]: T[] }, item: T) => {
|
||||
let group = getObjectValue(key, item) ?? undefined
|
||||
|
||||
@ -536,16 +532,12 @@ export function groupBy<T extends Doc> (
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function getGroupByValues<T extends Doc> (
|
||||
groupByDocs: Record<string | number, T[]>,
|
||||
category: CategoryType
|
||||
): T[] {
|
||||
export function getGroupByValues<T extends Doc> (groupByDocs: Record<any, T[]>, category: CategoryType): T[] {
|
||||
if (typeof category === 'object') {
|
||||
return groupByDocs[category.name] ?? []
|
||||
} else if (category !== undefined) {
|
||||
return groupByDocs[category] ?? []
|
||||
} else {
|
||||
return groupByDocs[category as any] ?? []
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user