Update filter popover to modal

This commit is contained in:
Andrew Kingston 2021-04-26 16:14:16 +01:00
parent 37d1004d8d
commit 17bf73706a
3 changed files with 22 additions and 41 deletions

View File

@ -3,7 +3,7 @@
</script> </script>
<label <label
class={`spectrum-FieldLabel spectrum-FieldLabel--sizeM spectrum-Form-itemLabel`}> class={`spectrum-FieldLabel spectrum-FieldLabel--sizeL spectrum-Form-itemLabel`}>
<slot /> <slot />
</label> </label>

View File

@ -1,20 +1,21 @@
<script> <script>
import { Popover, Button, Icon } from "@budibase/bbui" import { Button, Modal } from "@budibase/bbui"
import FilterPopover from "../popovers/FilterPopover.svelte" import FilterPopover from "../popovers/FilterPopover.svelte"
export let view = {} export let view = {}
let anchor let modal
let dropdown
</script> </script>
<div bind:this={anchor}> <Button
<Button icon="Filter" primary size="S" quiet icon="Filter"
on:click={dropdown.show} primary
active={view.filters && view.filters.length}> size="S"
quiet
on:click={modal.show}
active={view.filters?.length}>
Filter Filter
</Button> </Button>
</div> <Modal bind:this={modal}>
<Popover bind:this={dropdown} {anchor} align="left"> <FilterPopover {view} />
<FilterPopover {view} onClosed={dropdown.hide} /> </Modal>
</Popover>

View File

@ -1,5 +1,5 @@
<script> <script>
import { Button, Select, Label, notifications } from "@budibase/bbui" import { Select, Label, notifications, ModalContent } from "@budibase/bbui"
import { tables, views } from "stores/backend" import { tables, views } from "stores/backend"
import analytics from "analytics" import analytics from "analytics"
@ -35,13 +35,15 @@
function saveView() { function saveView() {
views.save(view) views.save(view)
notifications.success(`View ${view.name} saved.`) notifications.success(`View ${view.name} saved.`)
onClosed()
analytics.captureEvent("Added View Calculate", { field: view.field }) analytics.captureEvent("Added View Calculate", { field: view.field })
} }
</script> </script>
<div class="actions"> <ModalContent
<h5>Calculate</h5> title="Calculate"
confirmText="Save"
onConfirm={saveView}
disabled={!view.field}>
<div class="input-group-row"> <div class="input-group-row">
<Label>The</Label> <Label>The</Label>
<Select <Select
@ -54,31 +56,9 @@
<Select bind:value={view.field} options={fields} /> <Select bind:value={view.field} options={fields} />
{/if} {/if}
</div> </div>
<div class="footer"> </ModalContent>
<Button secondary on:click={onClosed}>Cancel</Button>
<Button cta on:click={saveView} disabled={!view.field}>Save</Button>
</div>
</div>
<style> <style>
.actions {
width: 200px;
display: grid;
grid-gap: var(--spacing-xl);
padding: var(--spacing-xl);
}
h5 {
margin: 0;
font-weight: 500;
}
.footer {
display: flex;
justify-content: flex-end;
gap: var(--spacing-m);
}
.input-group-row { .input-group-row {
display: grid; display: grid;
grid-template-columns: auto 1fr; grid-template-columns: auto 1fr;