Update table filter button to be a detail popover

This commit is contained in:
Andrew Kingston 2024-10-28 14:24:16 +00:00
parent 27c1788db2
commit 5156749ac9
No known key found for this signature in database
1 changed files with 41 additions and 41 deletions

View File

@ -1,11 +1,12 @@
<script> <script>
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import { ActionButton, Drawer, DrawerContent, Button } from "@budibase/bbui" import { ActionButton, Button } from "@budibase/bbui"
import FilterBuilder from "components/design/settings/controls/FilterEditor/FilterBuilder.svelte" import FilterBuilder from "components/design/settings/controls/FilterEditor/FilterBuilder.svelte"
import { getUserBindings } from "dataBinding" import { getUserBindings } from "dataBinding"
import { makePropSafe } from "@budibase/string-templates" import { makePropSafe } from "@budibase/string-templates"
import { search } from "@budibase/frontend-core" import { search } from "@budibase/frontend-core"
import { tables } from "stores/builder" import { tables } from "stores/builder"
import DetailPopover from "components/common/DetailPopover.svelte"
export let schema export let schema
export let filters export let filters
@ -14,7 +15,7 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
let drawer let popover
$: localFilters = filters $: localFilters = filters
$: schemaFields = search.getFields( $: schemaFields = search.getFields(
@ -39,39 +40,27 @@
}, },
...getUserBindings(), ...getUserBindings(),
] ]
const openPopover = () => {
localFilters = filters
popover.show()
}
</script> </script>
<ActionButton <DetailPopover bind:this={popover} title="Configure filters" width={800}>
<svelte:fragment slot="anchor" let:open>
<ActionButton
icon="Filter" icon="Filter"
quiet quiet
{disabled} {disabled}
on:click={drawer.show} on:click={openPopover}
selected={filterCount > 0} selected={open || filterCount > 0}
accentColor="#004EA6" accentColor="#004EA6"
>
{filterCount ? `Filter: ${filterCount}` : "Filter"}
</ActionButton>
<Drawer
bind:this={drawer}
title="Filtering"
on:drawerHide
on:drawerShow={() => {
localFilters = filters
}}
forceModal
>
<Button
cta
slot="buttons"
on:click={() => {
dispatch("change", localFilters)
drawer.hide()
}}
> >
Save {filterCount ? `Filter: ${filterCount}` : "Filter"}
</Button> </ActionButton>
<DrawerContent slot="body"> </svelte:fragment>
<FilterBuilder <FilterBuilder
filters={localFilters} filters={localFilters}
{schemaFields} {schemaFields}
@ -79,5 +68,16 @@
on:change={e => (localFilters = e.detail)} on:change={e => (localFilters = e.detail)}
{bindings} {bindings}
/> />
</DrawerContent> <div>
</Drawer> <Button
cta
slot="buttons"
on:click={() => {
dispatch("change", localFilters)
popover.hide()
}}
>
Save
</Button>
</div>
</DetailPopover>