forked from tsai/budibase
17 changed files with 203 additions and 385 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,16 +1,13 @@ |
|||||
<script> |
<script> |
||||
import { Popover, Button } from "@budibase/bbui" |
import { Modal, Button } from "@budibase/bbui" |
||||
import CreateViewPopover from "../popovers/CreateViewPopover.svelte" |
import CreateViewModal from "../modals/CreateViewModal.svelte" |
||||
|
|
||||
let anchor |
let modal |
||||
let dropdown |
|
||||
</script> |
</script> |
||||
|
|
||||
<div bind:this={anchor}> |
<Button icon="CollectionAdd" primary size="S" quiet on:click={modal.show}> |
||||
<Button icon="CollectionAdd" primary size="S" quiet on:click={dropdown.show}> |
Create New View |
||||
Create New View |
</Button> |
||||
</Button> |
<Modal bind:this={modal}> |
||||
</div> |
<CreateViewModal /> |
||||
<Popover bind:this={dropdown} {anchor} align="left"> |
</Modal> |
||||
<CreateViewPopover onClosed={dropdown.hide} /> |
|
||||
</Popover> |
|
||||
|
|||||
@ -1,18 +1,15 @@ |
|||||
<script> |
<script> |
||||
import { Button, Icon, Popover } from "@budibase/bbui" |
import { Button, Modal } from "@budibase/bbui" |
||||
import ExportPopover from "../popovers/ExportPopover.svelte" |
import ExportModal from "../modals/ExportModal.svelte" |
||||
|
|
||||
export let view |
export let view |
||||
|
|
||||
let anchor |
let modal |
||||
let dropdown |
|
||||
</script> |
</script> |
||||
|
|
||||
<div bind:this={anchor}> |
<Button icon="Download" primary size="S" quiet on:click={modal.show}> |
||||
<Button icon="Download" primary size="S" quiet on:click={dropdown.show}> |
Export |
||||
Export |
</Button> |
||||
</Button> |
<Modal bind:this={modal}> |
||||
</div> |
<ExportModal {view} /> |
||||
<Popover bind:this={dropdown} {anchor} align="left"> |
</Modal> |
||||
<ExportPopover {view} onClosed={dropdown.hide} /> |
|
||||
</Popover> |
|
||||
|
|||||
@ -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 FilterModal from "../modals/FilterModal.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" |
||||
Filter |
quiet |
||||
</Button> |
on:click={modal.show} |
||||
</div> |
active={view.filters?.length}> |
||||
<Popover bind:this={dropdown} {anchor} align="left"> |
Filter |
||||
<FilterPopover {view} onClosed={dropdown.hide} /> |
</Button> |
||||
</Popover> |
<Modal bind:this={modal}> |
||||
|
<FilterModal {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> |
||||
|
|||||
@ -1,29 +1,25 @@ |
|||||
<script> |
<script> |
||||
import { Button, Popover } from "@budibase/bbui" |
import { Button, Modal } from "@budibase/bbui" |
||||
import { permissions } from "stores/backend" |
import { permissions } from "stores/backend" |
||||
import ManageAccessPopover from "../popovers/ManageAccessPopover.svelte" |
import ManageAccessModal from "../modals/ManageAccessModal.svelte" |
||||
|
|
||||
export let resourceId |
export let resourceId |
||||
|
|
||||
let anchor |
let modal |
||||
let dropdown |
|
||||
let resourcePermissions |
let resourcePermissions |
||||
|
|
||||
async function openDropdown() { |
async function openDropdown() { |
||||
resourcePermissions = await permissions.forResource(resourceId) |
resourcePermissions = await permissions.forResource(resourceId) |
||||
dropdown.show() |
modal.show() |
||||
} |
} |
||||
</script> |
</script> |
||||
|
|
||||
<div bind:this={anchor}> |
<Button icon="LockClosed" primary size="S" quiet on:click={openDropdown}> |
||||
<Button icon="LockClosed" primary size="S" quiet on:click={openDropdown}> |
Manage Access |
||||
Manage Access |
</Button> |
||||
</Button> |
<Modal bind:this={modal}> |
||||
</div> |
<ManageAccessModal |
||||
<Popover bind:this={dropdown} {anchor} align="left"> |
|
||||
<ManageAccessPopover |
|
||||
{resourceId} |
{resourceId} |
||||
levels={$permissions} |
levels={$permissions} |
||||
permissions={resourcePermissions} |
permissions={resourcePermissions} /> |
||||
onClosed={dropdown.hide} /> |
</Modal> |
||||
</Popover> |
|
||||
|
|||||
@ -0,0 +1,37 @@ |
|||||
|
<script> |
||||
|
import { Select, ModalContent } from "@budibase/bbui" |
||||
|
import download from "downloadjs" |
||||
|
|
||||
|
const FORMATS = [ |
||||
|
{ |
||||
|
name: "CSV", |
||||
|
key: "csv", |
||||
|
}, |
||||
|
{ |
||||
|
name: "JSON", |
||||
|
key: "json", |
||||
|
}, |
||||
|
] |
||||
|
|
||||
|
export let view |
||||
|
|
||||
|
let exportFormat = FORMATS[0].key |
||||
|
|
||||
|
async function exportView() { |
||||
|
download( |
||||
|
`/api/views/export?view=${encodeURIComponent( |
||||
|
view.name |
||||
|
)}&format=${exportFormat}` |
||||
|
) |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<ModalContent title="Export Data" confirmText="Export" onConfirm={exportView}> |
||||
|
<Select |
||||
|
label="Format" |
||||
|
bind:value={exportFormat} |
||||
|
options={FORMATS} |
||||
|
placeholder={null} |
||||
|
getOptionLabel={x => x.name} |
||||
|
getOptionValue={x => x.key} /> |
||||
|
</ModalContent> |
||||
@ -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, Heading } from "@budibase/bbui" |
|
||||
import download from "downloadjs" |
|
||||
|
|
||||
const FORMATS = [ |
|
||||
{ |
|
||||
name: "CSV", |
|
||||
key: "csv", |
|
||||
}, |
|
||||
{ |
|
||||
name: "JSON", |
|
||||
key: "json", |
|
||||
}, |
|
||||
] |
|
||||
|
|
||||
export let view |
|
||||
export let onClosed |
|
||||
|
|
||||
let exportFormat = FORMATS[0].key |
|
||||
|
|
||||
async function exportView() { |
|
||||
download( |
|
||||
`/api/views/export?view=${encodeURIComponent( |
|
||||
view.name |
|
||||
)}&format=${exportFormat}` |
|
||||
) |
|
||||
onClosed() |
|
||||
} |
|
||||
</script> |
|
||||
|
|
||||
<div class="popover"> |
|
||||
<Heading s>Export Data</Heading> |
|
||||
<Select |
|
||||
label="Format" |
|
||||
bind:value={exportFormat} |
|
||||
options={FORMATS} |
|
||||
getOptionLabel={x => x.name} |
|
||||
getOptionValue={x => x.key} /> |
|
||||
<div class="footer"> |
|
||||
<Button secondary on:click={onClosed}>Cancel</Button> |
|
||||
<Button cta on:click={exportView}>Export</Button> |
|
||||
</div> |
|
||||
</div> |
|
||||
|
|
||||
<style> |
|
||||
.popover { |
|
||||
display: grid; |
|
||||
grid-gap: var(--spacing-xl); |
|
||||
padding: var(--spacing-xl); |
|
||||
width: 240px; |
|
||||
} |
|
||||
|
|
||||
h5 { |
|
||||
margin: 0; |
|
||||
font-weight: 500; |
|
||||
} |
|
||||
|
|
||||
.footer { |
|
||||
display: flex; |
|
||||
justify-content: flex-end; |
|
||||
gap: var(--spacing-m); |
|
||||
} |
|
||||
</style> |
|
||||
@ -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