mirror of https://github.com/Budibase/budibase.git
6 changed files with 84 additions and 147 deletions
@ -1,20 +1,21 @@ |
|||||
<script> |
<script> |
||||
import { Popover, Button } from "@budibase/bbui" |
import { Modal, Button } from "@budibase/bbui" |
||||
import CalculatePopover from "../popovers/CalculatePopover.svelte" |
import CalculateModal from "../modals/CalculateModal.svelte" |
||||
|
|
||||
export let view = {} |
export let view = {} |
||||
|
|
||||
let anchor |
let modal |
||||
let dropdown |
|
||||
</script> |
</script> |
||||
|
|
||||
<div bind:this={anchor}> |
<Button |
||||
<Button icon="Calculator" primary size="S" quiet |
icon="Calculator" |
||||
on:click={dropdown.show} |
primary |
||||
active={view.field && view.calculation}> |
size="S" |
||||
Calculate |
quiet |
||||
</Button> |
on:click={modal.show} |
||||
</div> |
active={view.field && view.calculation}> |
||||
<Popover bind:this={dropdown} {anchor} align="left"> |
Calculate |
||||
<CalculatePopover {view} onClosed={dropdown.hide} /> |
</Button> |
||||
</Popover> |
<Modal bind:this={modal}> |
||||
|
<CalculateModal {view} /> |
||||
|
</Modal> |
||||
|
|||||
@ -1,18 +1,21 @@ |
|||||
<script> |
<script> |
||||
import { Popover, Button } from "@budibase/bbui" |
import { Modal, Button } from "@budibase/bbui" |
||||
import GroupByPopover from "../popovers/GroupByPopover.svelte" |
import GroupByModal from "../modals/GroupByModal.svelte" |
||||
|
|
||||
export let view = {} |
export let view = {} |
||||
|
|
||||
let anchor |
let modal |
||||
let dropdown |
|
||||
</script> |
</script> |
||||
|
|
||||
<div bind:this={anchor}> |
<Button |
||||
<Button icon="Group" primary size="S" quiet active={!!view.groupBy} on:click={dropdown.show}> |
icon="Group" |
||||
Group By |
primary |
||||
</Button> |
size="S" |
||||
</div> |
quiet |
||||
<Popover bind:this={dropdown} {anchor} align="left"> |
active={!!view.groupBy} |
||||
<GroupByPopover {view} onClosed={dropdown.hide} /> |
on:click={modal.show}> |
||||
</Popover> |
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