Merge branch 'spectrum-bbui' of github.com:Budibase/budibase into spectrum-bbui
This commit is contained in:
commit
03eb8603bd
|
@ -23,15 +23,13 @@
|
|||
class:active
|
||||
class="spectrum-Button spectrum-Button--size{size.toUpperCase()}"
|
||||
{disabled}
|
||||
on:click|preventDefault
|
||||
>
|
||||
on:click|preventDefault>
|
||||
{#if icon}
|
||||
<svg
|
||||
class="spectrum-Icon spectrum-Icon--size{size.toUpperCase()}"
|
||||
focusable="false"
|
||||
aria-hidden="true"
|
||||
aria-label={icon}
|
||||
>
|
||||
aria-label={icon}>
|
||||
<use xlink:href="#spectrum-icon-18-{icon}" />
|
||||
</svg>
|
||||
{/if}
|
||||
|
@ -46,4 +44,7 @@
|
|||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.active {
|
||||
color: var(--spectrum-global-color-blue-600) !important;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
</script>
|
||||
|
||||
<label
|
||||
class={`spectrum-FieldLabel spectrum-FieldLabel--sizeM spectrum-Form-itemLabel`}>
|
||||
class={`spectrum-FieldLabel spectrum-FieldLabel--sizeL spectrum-Form-itemLabel`}>
|
||||
<slot />
|
||||
</label>
|
||||
|
||||
|
|
|
@ -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}
|
||||
<Button
|
||||
icon="Calculator"
|
||||
primary
|
||||
size="S"
|
||||
quiet
|
||||
on:click={modal.show}
|
||||
active={view.field && view.calculation}>
|
||||
Calculate
|
||||
</Button>
|
||||
</div>
|
||||
<Popover bind:this={dropdown} {anchor} align="left">
|
||||
<CalculatePopover {view} onClosed={dropdown.hide} />
|
||||
</Popover>
|
||||
<Modal bind:this={modal}>
|
||||
<CalculateModal {view} />
|
||||
</Modal>
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
<script>
|
||||
import { Popover, Button } from "@budibase/bbui"
|
||||
import CreateViewPopover from "../popovers/CreateViewPopover.svelte"
|
||||
import { Modal, Button } from "@budibase/bbui"
|
||||
import CreateViewModal from "../modals/CreateViewModal.svelte"
|
||||
|
||||
let anchor
|
||||
let dropdown
|
||||
let modal
|
||||
</script>
|
||||
|
||||
<div bind:this={anchor}>
|
||||
<Button icon="CollectionAdd" primary size="S" quiet on:click={dropdown.show}>
|
||||
<Button icon="CollectionAdd" primary size="S" quiet on:click={modal.show}>
|
||||
Create New View
|
||||
</Button>
|
||||
</div>
|
||||
<Popover bind:this={dropdown} {anchor} align="left">
|
||||
<CreateViewPopover onClosed={dropdown.hide} />
|
||||
</Popover>
|
||||
<Modal bind:this={modal}>
|
||||
<CreateViewModal />
|
||||
</Modal>
|
||||
|
|
|
@ -1,18 +1,15 @@
|
|||
<script>
|
||||
import { Button, Icon, Popover } from "@budibase/bbui"
|
||||
import ExportPopover from "../popovers/ExportPopover.svelte"
|
||||
import { Button, Modal } from "@budibase/bbui"
|
||||
import ExportModal from "../modals/ExportModal.svelte"
|
||||
|
||||
export let view
|
||||
|
||||
let anchor
|
||||
let dropdown
|
||||
let modal
|
||||
</script>
|
||||
|
||||
<div bind:this={anchor}>
|
||||
<Button icon="Download" primary size="S" quiet on:click={dropdown.show}>
|
||||
<Button icon="Download" primary size="S" quiet on:click={modal.show}>
|
||||
Export
|
||||
</Button>
|
||||
</div>
|
||||
<Popover bind:this={dropdown} {anchor} align="left">
|
||||
<ExportPopover {view} onClosed={dropdown.hide} />
|
||||
</Popover>
|
||||
<Modal bind:this={modal}>
|
||||
<ExportModal {view} />
|
||||
</Modal>
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
<script>
|
||||
import { Popover, Button, Icon } from "@budibase/bbui"
|
||||
import FilterPopover from "../popovers/FilterPopover.svelte"
|
||||
import { Button, Modal } from "@budibase/bbui"
|
||||
import FilterModal from "../modals/FilterModal.svelte"
|
||||
|
||||
export let view = {}
|
||||
|
||||
let anchor
|
||||
let dropdown
|
||||
let modal
|
||||
</script>
|
||||
|
||||
<div bind:this={anchor}>
|
||||
<Button icon="Filter" primary size="S" quiet
|
||||
on:click={dropdown.show}
|
||||
active={view.filters && view.filters.length}>
|
||||
<Button
|
||||
icon="Filter"
|
||||
primary
|
||||
size="S"
|
||||
quiet
|
||||
on:click={modal.show}
|
||||
active={view.filters?.length}>
|
||||
Filter
|
||||
</Button>
|
||||
</div>
|
||||
<Popover bind:this={dropdown} {anchor} align="left">
|
||||
<FilterPopover {view} onClosed={dropdown.hide} />
|
||||
</Popover>
|
||||
<Modal bind:this={modal}>
|
||||
<FilterModal {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}>
|
||||
<Button
|
||||
icon="Group"
|
||||
primary
|
||||
size="S"
|
||||
quiet
|
||||
active={!!view.groupBy}
|
||||
on:click={modal.show}>
|
||||
Group By
|
||||
</Button>
|
||||
</div>
|
||||
<Popover bind:this={dropdown} {anchor} align="left">
|
||||
<GroupByPopover {view} onClosed={dropdown.hide} />
|
||||
</Popover>
|
||||
<Modal bind:this={modal}>
|
||||
<GroupByModal {view} />
|
||||
</Modal>
|
||||
|
|
|
@ -1,29 +1,25 @@
|
|||
<script>
|
||||
import { Button, Popover } from "@budibase/bbui"
|
||||
import { Button, Modal } from "@budibase/bbui"
|
||||
import { permissions } from "stores/backend"
|
||||
import ManageAccessPopover from "../popovers/ManageAccessPopover.svelte"
|
||||
import ManageAccessModal from "../modals/ManageAccessModal.svelte"
|
||||
|
||||
export let resourceId
|
||||
|
||||
let anchor
|
||||
let dropdown
|
||||
let modal
|
||||
let resourcePermissions
|
||||
|
||||
async function openDropdown() {
|
||||
resourcePermissions = await permissions.forResource(resourceId)
|
||||
dropdown.show()
|
||||
modal.show()
|
||||
}
|
||||
</script>
|
||||
|
||||
<div bind:this={anchor}>
|
||||
<Button icon="LockClosed" primary size="S" quiet on:click={openDropdown}>
|
||||
Manage Access
|
||||
</Button>
|
||||
</div>
|
||||
<Popover bind:this={dropdown} {anchor} align="left">
|
||||
<ManageAccessPopover
|
||||
<Modal bind:this={modal}>
|
||||
<ManageAccessModal
|
||||
{resourceId}
|
||||
levels={$permissions}
|
||||
permissions={resourcePermissions}
|
||||
onClosed={dropdown.hide} />
|
||||
</Popover>
|
||||
permissions={resourcePermissions} />
|
||||
</Modal>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import { Button, Select, Label, notifications } from "@budibase/bbui"
|
||||
import { Select, Label, notifications, ModalContent } from "@budibase/bbui"
|
||||
import { tables, views } from "stores/backend"
|
||||
import analytics from "analytics"
|
||||
|
||||
|
@ -35,13 +35,15 @@
|
|||
function saveView() {
|
||||
views.save(view)
|
||||
notifications.success(`View ${view.name} saved.`)
|
||||
onClosed()
|
||||
analytics.captureEvent("Added View Calculate", { field: view.field })
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="actions">
|
||||
<h5>Calculate</h5>
|
||||
<ModalContent
|
||||
title="Calculate"
|
||||
confirmText="Save"
|
||||
onConfirm={saveView}
|
||||
disabled={!view.field}>
|
||||
<div class="input-group-row">
|
||||
<Label>The</Label>
|
||||
<Select
|
||||
|
@ -54,31 +56,9 @@
|
|||
<Select bind:value={view.field} options={fields} />
|
||||
{/if}
|
||||
</div>
|
||||
<div class="footer">
|
||||
<Button secondary on:click={onClosed}>Cancel</Button>
|
||||
<Button cta on:click={saveView} disabled={!view.field}>Save</Button>
|
||||
</div>
|
||||
</div>
|
||||
</ModalContent>
|
||||
|
||||
<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 {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import { Button, Input, notifications, Heading } from "@budibase/bbui"
|
||||
import { Input, notifications, ModalContent } from "@budibase/bbui"
|
||||
import { goto } from "@roxi/routify"
|
||||
import { views as viewsStore } from "stores/backend"
|
||||
import { tables } from "stores/backend"
|
||||
|
@ -23,37 +23,14 @@
|
|||
field,
|
||||
})
|
||||
notifications.success(`View ${name} created`)
|
||||
onClosed()
|
||||
analytics.captureEvent("View Created", { name })
|
||||
$goto(`../../view/${name}`)
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="actions">
|
||||
<Heading s>Create View</Heading>
|
||||
<ModalContent
|
||||
title="Create View"
|
||||
confirmText="Create View"
|
||||
onConfirm={saveView}>
|
||||
<Input label="View Name" thin bind:value={name} />
|
||||
<div class="footer">
|
||||
<Button secondary on:click={onClosed}>Cancel</Button>
|
||||
<Button cta on:click={saveView}>Save View</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
h5 {
|
||||
margin: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.actions {
|
||||
display: grid;
|
||||
grid-gap: var(--spacing-xl);
|
||||
padding: var(--spacing-xl);
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--spacing-m);
|
||||
}
|
||||
</style>
|
||||
</ModalContent>
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
// Changes the selected role
|
||||
const changeRole = event => {
|
||||
const id = event?.target?.value
|
||||
const id = event?.detail
|
||||
const role = $roles.find(role => role._id === id)
|
||||
if (role) {
|
||||
selectedRole = {
|
||||
|
@ -94,42 +94,34 @@
|
|||
secondary
|
||||
label="Role"
|
||||
value={selectedRoleId}
|
||||
on:change={changeRole}>
|
||||
<option value="">Create new role</option>
|
||||
{#each $roles as role}
|
||||
<option value={role._id}>{role.name}</option>
|
||||
{/each}
|
||||
</Select>
|
||||
on:change={changeRole}
|
||||
options={$roles}
|
||||
placeholder="Create new role"
|
||||
getOptionValue={role => role._id}
|
||||
getOptionLabel={role => role.name} />
|
||||
{#if selectedRole}
|
||||
<Input
|
||||
label="Name"
|
||||
bind:value={selectedRole.name}
|
||||
thin
|
||||
disabled={builtInRoles.includes(selectedRole.name)} />
|
||||
<Select
|
||||
thin
|
||||
secondary
|
||||
label="Inherits Role"
|
||||
bind:value={selectedRole.inherits}>
|
||||
<option value="">None</option>
|
||||
{#each otherRoles as role}
|
||||
<option value={role._id}>{role.name}</option>
|
||||
{/each}
|
||||
</Select>
|
||||
bind:value={selectedRole.inherits}
|
||||
options={otherRoles}
|
||||
getOptionValue={role => role._id}
|
||||
getOptionLabel={role => role.name}
|
||||
placeholder="None" />
|
||||
<Select
|
||||
thin
|
||||
secondary
|
||||
label="Base Permissions"
|
||||
bind:value={selectedRole.permissionId}>
|
||||
<option value="">Choose permissions</option>
|
||||
{#each basePermissions as basePerm}
|
||||
<option value={basePerm._id}>{basePerm.name}</option>
|
||||
{/each}
|
||||
</Select>
|
||||
bind:value={selectedRole.permissionId}
|
||||
options={basePermissions}
|
||||
getOptionValue={x => x._id}
|
||||
getOptionLabel={x => x.name}
|
||||
placeholder="Choose permissions" />
|
||||
{/if}
|
||||
<div slot="footer">
|
||||
{#if !isCreating}
|
||||
<Button red on:click={deleteRole}>Delete</Button>
|
||||
<Button warning on:click={deleteRole}>Delete</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</ModalContent>
|
||||
|
|
|
@ -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>
|
|
@ -1,7 +1,16 @@
|
|||
<script>
|
||||
import { Button, Input, Select, DatePicker } from "@budibase/bbui"
|
||||
import {
|
||||
Button,
|
||||
Input,
|
||||
Body,
|
||||
Select,
|
||||
DatePicker,
|
||||
ModalContent,
|
||||
Label,
|
||||
notifications,
|
||||
Icon,
|
||||
} from "@budibase/bbui"
|
||||
import { tables, views } from "stores/backend"
|
||||
import { notifications } from "@budibase/bbui"
|
||||
import analytics from "analytics"
|
||||
|
||||
const CONDITIONS = [
|
||||
|
@ -55,7 +64,6 @@
|
|||
function saveView() {
|
||||
views.save(view)
|
||||
notifications.success(`View ${view.name} saved.`)
|
||||
onClosed()
|
||||
analytics.captureEvent("Added View Filter", {
|
||||
filters: JSON.stringify(view.filters),
|
||||
})
|
||||
|
@ -67,7 +75,7 @@
|
|||
}
|
||||
|
||||
function addFilter() {
|
||||
view.filters.push({})
|
||||
view.filters.push({ conjunction: "AND" })
|
||||
view.filters = view.filters
|
||||
}
|
||||
|
||||
|
@ -98,9 +106,8 @@
|
|||
// reset if type changed
|
||||
if (
|
||||
filter.key &&
|
||||
ev.target.value &&
|
||||
viewTable.schema[filter.key].type !==
|
||||
viewTable.schema[ev.target.value].type
|
||||
ev.detail &&
|
||||
viewTable.schema[filter.key].type !== viewTable.schema[ev.detail].type
|
||||
) {
|
||||
filter.value = ""
|
||||
}
|
||||
|
@ -110,17 +117,21 @@
|
|||
const getOptionValue = x => x.key
|
||||
</script>
|
||||
|
||||
<div class="actions">
|
||||
<h5>Filter</h5>
|
||||
<ModalContent
|
||||
title="Filter"
|
||||
confirmText="Save"
|
||||
onConfirm={saveView}
|
||||
size="large">
|
||||
{#if view.filters.length}
|
||||
<div class="input-group-row">
|
||||
{#each view.filters as filter, idx}
|
||||
{#if idx === 0}
|
||||
<p>Where</p>
|
||||
<Label>Where</Label>
|
||||
{:else}
|
||||
<Select
|
||||
bind:value={filter.conjunction}
|
||||
options={CONJUNCTIONS}
|
||||
placeholder={null}
|
||||
{getOptionLabel}
|
||||
{getOptionValue} />
|
||||
{/if}
|
||||
|
@ -152,61 +163,22 @@
|
|||
placeholder={filter.key || fields[0]}
|
||||
bind:value={filter.value} />
|
||||
{/if}
|
||||
<i class="ri-close-circle-fill" on:click={() => removeFilter(idx)} />
|
||||
<Icon hoverable name="Close" on:click={() => removeFilter(idx)} />
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<Body s>Add a filter to get started.</Body>
|
||||
{/if}
|
||||
<div class="footer">
|
||||
<div class="add-filter">
|
||||
<Button text on:click={addFilter}>Add Filter</Button>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<Button secondary on:click={onClosed}>Cancel</Button>
|
||||
<Button cta on:click={saveView}>Save</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div slot="footer">
|
||||
<Button secondary on:click={addFilter}>Add Filter</Button>
|
||||
</div>
|
||||
</ModalContent>
|
||||
|
||||
<style>
|
||||
.actions {
|
||||
display: grid;
|
||||
grid-gap: var(--spacing-xl);
|
||||
padding: var(--spacing-xl);
|
||||
}
|
||||
|
||||
h5 {
|
||||
margin: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.footer {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
.buttons {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--spacing-m);
|
||||
}
|
||||
|
||||
.ri-close-circle-fill {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.input-group-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(50px, auto) 1fr 1fr 1fr 15px;
|
||||
grid-template-columns: minmax(70px, auto) 1fr 1fr 1fr 15px;
|
||||
gap: var(--spacing-s);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-size: var(--font-size-xs);
|
||||
}
|
||||
|
||||
.add-filter {
|
||||
margin-right: 16px;
|
||||
}
|
||||
</style>
|
|
@ -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,14 +1,13 @@
|
|||
<script>
|
||||
import { roles, permissions as permissionsStore } from "stores/backend"
|
||||
import {
|
||||
Button,
|
||||
Label,
|
||||
Input,
|
||||
Select,
|
||||
Spacer,
|
||||
notifications,
|
||||
Heading,
|
||||
Body,
|
||||
ModalContent,
|
||||
} from "@budibase/bbui"
|
||||
import { capitalise } from "../../../../helpers"
|
||||
|
||||
|
@ -31,12 +30,8 @@
|
|||
}
|
||||
</script>
|
||||
|
||||
<div class="popover">
|
||||
<Heading s>Who Can Access This Data?</Heading>
|
||||
<div class="note">
|
||||
<ModalContent title="Manage Access" showCancelButton={false} confirmText="Done">
|
||||
<Body s>Specify the minimum access level role for this data.</Body>
|
||||
</div>
|
||||
<Spacer large />
|
||||
<div class="row">
|
||||
<Label extraSmall grey>Level</Label>
|
||||
<Label extraSmall grey>Role</Label>
|
||||
|
@ -50,41 +45,12 @@
|
|||
getOptionValue={x => x._id} />
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<Spacer large />
|
||||
|
||||
<div class="footer">
|
||||
<Button secondary on:click={onClosed}>Cancel</Button>
|
||||
</div>
|
||||
</div>
|
||||
</ModalContent>
|
||||
|
||||
<style>
|
||||
.popover {
|
||||
display: grid;
|
||||
width: 400px;
|
||||
padding: var(--spacing-xl);
|
||||
}
|
||||
|
||||
h5 {
|
||||
margin: 0;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: var(--spacing-m);
|
||||
margin-top: var(--spacing-l);
|
||||
}
|
||||
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
grid-gap: var(--spacing-s);
|
||||
}
|
||||
|
||||
.note {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
|
@ -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