forked from tsai/budibase
6 changed files with 84 additions and 147 deletions
@ -1,20 +1,21 @@ |
|||
<script> |
|||
import { Popover, Button } from "@budibase/bbui" |
|||
import CalculatePopover from "../popovers/CalculatePopover.svelte" |
|||
import { Modal, Button } from "@budibase/bbui" |
|||
import CalculateModal from "../modals/CalculateModal.svelte" |
|||
|
|||
export let view = {} |
|||
|
|||
let anchor |
|||
let dropdown |
|||
let modal |
|||
</script> |
|||
|
|||
<div bind:this={anchor}> |
|||
<Button icon="Calculator" primary size="S" quiet |
|||
on:click={dropdown.show} |
|||
active={view.field && view.calculation}> |
|||
Calculate |
|||
</Button> |
|||
</div> |
|||
<Popover bind:this={dropdown} {anchor} align="left"> |
|||
<CalculatePopover {view} onClosed={dropdown.hide} /> |
|||
</Popover> |
|||
<Button |
|||
icon="Calculator" |
|||
primary |
|||
size="S" |
|||
quiet |
|||
on:click={modal.show} |
|||
active={view.field && view.calculation}> |
|||
Calculate |
|||
</Button> |
|||
<Modal bind:this={modal}> |
|||
<CalculateModal {view} /> |
|||
</Modal> |
|||
|
|||
@ -1,18 +1,21 @@ |
|||
<script> |
|||
import { Popover, Button } from "@budibase/bbui" |
|||
import GroupByPopover from "../popovers/GroupByPopover.svelte" |
|||
import { Modal, Button } from "@budibase/bbui" |
|||
import GroupByModal from "../modals/GroupByModal.svelte" |
|||
|
|||
export let view = {} |
|||
|
|||
let anchor |
|||
let dropdown |
|||
let modal |
|||
</script> |
|||
|
|||
<div bind:this={anchor}> |
|||
<Button icon="Group" primary size="S" quiet active={!!view.groupBy} on:click={dropdown.show}> |
|||
Group By |
|||
</Button> |
|||
</div> |
|||
<Popover bind:this={dropdown} {anchor} align="left"> |
|||
<GroupByPopover {view} onClosed={dropdown.hide} /> |
|||
</Popover> |
|||
<Button |
|||
icon="Group" |
|||
primary |
|||
size="S" |
|||
quiet |
|||
active={!!view.groupBy} |
|||
on:click={modal.show}> |
|||
Group By |
|||
</Button> |
|||
<Modal bind:this={modal}> |
|||
<GroupByModal {view} /> |
|||
</Modal> |
|||
|
|||
@ -0,0 +1,24 @@ |
|||
<script> |
|||
import { Button, Select, ModalContent, notifications } from "@budibase/bbui" |
|||
import { tables, views } from "stores/backend" |
|||
import { FIELDS } from "constants/backend" |
|||
|
|||
export let view = {} |
|||
export let onClosed |
|||
|
|||
$: viewTable = $tables.list.find(({ _id }) => _id === $views.selected.tableId) |
|||
$: fields = |
|||
viewTable && |
|||
Object.entries(viewTable.schema) |
|||
.filter(entry => entry[1].type !== FIELDS.LINK.type) |
|||
.map(([key]) => key) |
|||
|
|||
function saveView() { |
|||
views.save(view) |
|||
notifications.success(`View ${view.name} saved.`) |
|||
} |
|||
</script> |
|||
|
|||
<ModalContent title="Group By" confirmText="Save" onConfirm={saveView}> |
|||
<Select bind:value={view.groupBy} options={fields} /> |
|||
</ModalContent> |
|||
@ -1,63 +0,0 @@ |
|||
<script> |
|||
import { Button, Select } from "@budibase/bbui" |
|||
import { tables, views } from "stores/backend" |
|||
import { notifications } from "@budibase/bbui" |
|||
import { FIELDS } from "constants/backend" |
|||
|
|||
export let view = {} |
|||
export let onClosed |
|||
|
|||
$: viewTable = $tables.list.find(({ _id }) => _id === $views.selected.tableId) |
|||
$: fields = |
|||
viewTable && |
|||
Object.entries(viewTable.schema) |
|||
.filter(entry => entry[1].type !== FIELDS.LINK.type) |
|||
.map(([key]) => key) |
|||
|
|||
function saveView() { |
|||
views.save(view) |
|||
notifications.success(`View ${view.name} saved.`) |
|||
onClosed() |
|||
} |
|||
</script> |
|||
|
|||
<div class="actions"> |
|||
<h5>Group By</h5> |
|||
<Select bind:value={view.groupBy} options={fields} /> |
|||
<div class="footer"> |
|||
<Button secondary on:click={onClosed}>Cancel</Button> |
|||
<Button cta on:click={saveView}>Save</Button> |
|||
</div> |
|||
</div> |
|||
|
|||
<style> |
|||
.actions { |
|||
display: grid; |
|||
width: 200px; |
|||
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 { |
|||
display: grid; |
|||
grid-template-columns: 20px 1fr; |
|||
gap: var(--spacing-s); |
|||
align-items: center; |
|||
} |
|||
|
|||
p { |
|||
margin: 0; |
|||
font-size: var(--font-size-xs); |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue