Skip to content

Commit

Permalink
can handle duplicate template names
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexErrant committed Dec 1, 2024
1 parent 47a6e55 commit 67bbef3
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions app/src/components/filtersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const filterGridOptions = {
suppressCount: true,
checkbox: true,
} satisfies IGroupCellRendererParams<FilterNode>,
field: 'name',
},
rowSelection: {
mode: 'multiRow',
Expand All @@ -59,6 +60,7 @@ export const filterGridOptions = {

export interface FilterNode {
searchId: string
name: string
dataPath: string[]
}

Expand Down Expand Up @@ -90,20 +92,22 @@ const FiltersTable: VoidComponent<{
})
const [nodes] = createResource(async () => {
const tags = C.db.getTags().then((tags) =>
tags.map(
(t) =>
({
searchId: t,
dataPath: [TagsNodeName, ...t.split('/')],
}) satisfies FilterNode,
),
tags.map((t) => {
const dataPath = [TagsNodeName, ...t.split('/')]
return {
searchId: t,
dataPath,
name: dataPath.at(-1)!,
} satisfies FilterNode
}),
)
const templates = C.db.getTemplates().then((templates) =>
templates.map(
(t) =>
({
searchId: t.id,
dataPath: [TemplatesNodeName, t.name],
dataPath: [TemplatesNodeName, t.id],
name: t.name,
}) satisfies FilterNode,
),
)
Expand Down

0 comments on commit 67bbef3

Please sign in to comment.