Update data page to use new styles

This commit is contained in:
Andrew Kingston 2020-10-23 12:25:22 +01:00
parent ea94694038
commit 14b13c7c52
4 changed files with 124 additions and 115 deletions

View File

@ -51,20 +51,18 @@
} }
</script> </script>
<section> <div class="table-container">
<div class="table-controls"> <div class="title">
<h2 class="title"> <h1>{title}</h1>
<span>{title}</span>
{#if loading} {#if loading}
<div transition:fade> <div transition:fade>
<Spinner size="10" /> <Spinner size="10" />
</div> </div>
{/if} {/if}
</h2> </div>
<div class="popovers"> <div class="popovers">
<slot /> <slot />
</div> </div>
</div>
<table class="bb-table"> <table class="bb-table">
<thead> <thead>
<tr> <tr>
@ -125,20 +123,44 @@
bind:currentPage bind:currentPage
pageItemCount={paginatedData.length} pageItemCount={paginatedData.length}
{ITEMS_PER_PAGE} /> {ITEMS_PER_PAGE} />
</section> </div>
<style> <style>
.table-container {
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
gap: var(--spacing-l);
}
.title { .title {
font-size: 24px; height: 24px;
font-weight: 600;
text-rendering: optimizeLegibility;
margin-top: 0;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
} }
.title > span { .title h1 {
font-size: var(--font-size-m);
font-weight: 500;
margin: 0;
}
.title > div {
margin-left: var(--spacing-xs);
}
.popovers {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
gap: var(--spacing-l);
}
.popovers :global(button) {
font-weight: 500;
}
.popovers :global(button svg) {
margin-right: var(--spacing-xs); margin-right: var(--spacing-xs);
} }
@ -200,19 +222,6 @@
background: var(--grey-1); background: var(--grey-1);
} }
.table-controls {
width: 100%;
}
.popovers {
display: flex;
}
:global(.popovers > div) {
margin-right: var(--spacing-m);
margin-bottom: var(--spacing-xl);
}
.edit-header { .edit-header {
width: 60px; width: 60px;
} }

View File

@ -5,9 +5,10 @@
import CreateTableModal from "./modals/CreateTableModal.svelte" import CreateTableModal from "./modals/CreateTableModal.svelte"
import EditTablePopover from "./popovers/EditTablePopover.svelte" import EditTablePopover from "./popovers/EditTablePopover.svelte"
import EditViewPopover from "./popovers/EditViewPopover.svelte" import EditViewPopover from "./popovers/EditViewPopover.svelte"
import { Heading } from "@budibase/bbui" import { Modal } from "@budibase/bbui"
import { Spacer } from "@budibase/bbui" import NavItem from "components/common/NavItem.svelte"
let modal
$: selectedView = $: selectedView =
$backendUiStore.selectedView && $backendUiStore.selectedView.name $backendUiStore.selectedView && $backendUiStore.selectedView.name
@ -20,67 +21,77 @@
backendUiStore.actions.views.select(view) backendUiStore.actions.views.select(view)
$goto(`./view/${view.name}`) $goto(`./view/${view.name}`)
} }
function onClickView(table, viewName) {
if (selectedView === viewName) {
return
}
selectView({
name: viewName,
...table.views[viewName],
})
}
</script> </script>
<div class="items-root"> <div class="items-root">
{#if $backendUiStore.selectedDatabase && $backendUiStore.selectedDatabase._id} {#if $backendUiStore.selectedDatabase && $backendUiStore.selectedDatabase._id}
<div class="hierarchy"> <div class="title">
<div class="components-list-container"> <h1>Tables</h1>
<Heading small>Tables</Heading> <i on:click={modal.show} class="ri-add-circle-fill" />
<Spacer medium /> </div>
<CreateTableModal />
<div class="hierarchy-items-container"> <div class="hierarchy-items-container">
{#each $backendUiStore.tables as table} {#each $backendUiStore.tables as table}
<ListItem <NavItem
icon="ri-table-line"
text={table.name}
selected={selectedView === `all_${table._id}`} selected={selectedView === `all_${table._id}`}
title={table.name}
icon="ri-table-fill"
on:click={() => selectTable(table)}> on:click={() => selectTable(table)}>
<EditTablePopover {table} /> <EditTablePopover {table} />
</ListItem> </NavItem>
{#each Object.keys(table.views || {}) as viewName} {#each Object.keys(table.views || {}) as viewName}
<ListItem <NavItem
indented indentLevel={1}
selected={selectedView === viewName}
title={viewName}
icon="ri-eye-line" icon="ri-eye-line"
on:click={() => (selectedView === viewName ? {} : selectView({ text={viewName}
name: viewName, selected={selectedView === viewName}
...table.views[viewName], on:click={() => onClickView(table, viewName)}>
}))}>
<EditViewPopover <EditViewPopover
view={{ name: viewName, ...table.views[viewName] }} /> view={{ name: viewName, ...table.views[viewName] }} />
</ListItem> </NavItem>
{/each} {/each}
{/each} {/each}
</div> </div>
</div>
</div>
{/if} {/if}
</div> </div>
<Modal bind:this={modal}>
<CreateTableModal />
</Modal>
<style> <style>
h5 {
font-size: 18px;
font-weight: 600;
margin-top: 0;
margin-bottom: var(--spacing-xl);
}
.items-root { .items-root {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-start; justify-content: flex-start;
align-items: stretch; align-items: stretch;
gap: var(--spacing-l);
} }
.hierarchy { .title {
display: flex; display: flex;
flex-direction: column; flex-direction: row;
justify-content: space-between;
align-items: center;
} }
.title h1 {
.hierarchy-items-container { font-size: var(--font-size-m);
margin-top: var(--spacing-xl); font-weight: 500;
flex: 1 1 auto; margin: 0;
}
.title i {
font-size: 20px;
}
.title i:hover {
cursor: pointer;
color: var(--blue);
} }
</style> </style>

View File

@ -2,8 +2,7 @@
import { goto } from "@sveltech/routify" import { goto } from "@sveltech/routify"
import { backendUiStore, store } from "builderStore" import { backendUiStore, store } from "builderStore"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import { Button, Input, Label, ModalContent, Modal } from "@budibase/bbui" import { Input, Label, ModalContent } from "@budibase/bbui"
import Spinner from "components/common/Spinner.svelte"
import TableDataImport from "../TableDataImport.svelte" import TableDataImport from "../TableDataImport.svelte"
import analytics from "analytics" import analytics from "analytics"
import screenTemplates from "builderStore/store/screenTemplates" import screenTemplates from "builderStore/store/screenTemplates"
@ -22,15 +21,9 @@
let dataImport let dataImport
let error = "" let error = ""
function resetState() {
name = ""
dataImport = undefined
error = ""
}
function checkValid(evt) { function checkValid(evt) {
const tableName = evt.target.value const tableName = evt.target.value
if ($backendUiStore.models?.some(model => model.name === tableName)) { if ($backendUiStore.models?.some((model) => model.name === tableName)) {
error = `Table with name ${tableName} already exists. Please choose another name.` error = `Table with name ${tableName} already exists. Please choose another name.`
return return
} }
@ -56,8 +49,8 @@
// Create auto screens // Create auto screens
const screens = screenTemplates($store, [table]) const screens = screenTemplates($store, [table])
.filter(template => defaultScreens.includes(template.id)) .filter((template) => defaultScreens.includes(template.id))
.map(template => template.create()) .map((template) => template.create())
for (let screen of screens) { for (let screen of screens) {
// Record the table that created this screen so we can link it later // Record the table that created this screen so we can link it later
screen.autoTableId = table._id screen.autoTableId = table._id
@ -74,7 +67,7 @@
} }
// Create autolink to newly created list page // Create autolink to newly created list page
const listPage = screens.find(screen => const listPage = screens.find((screen) =>
screen.props._instanceName.endsWith("List") screen.props._instanceName.endsWith("List")
) )
await store.createLink(listPage.route, table.name) await store.createLink(listPage.route, table.name)
@ -84,9 +77,7 @@
} }
</script> </script>
<Button primary wide on:click={modal.show}>Create New Table</Button> <ModalContent
<Modal bind:this={modal} on:hide={resetState}>
<ModalContent
title="Create Table" title="Create Table"
confirmText="Create" confirmText="Create"
onConfirm={saveTable} onConfirm={saveTable}
@ -102,5 +93,4 @@
<Label grey extraSmall>Create Table from CSV (Optional)</Label> <Label grey extraSmall>Create Table from CSV (Optional)</Label>
<TableDataImport bind:dataImport /> <TableDataImport bind:dataImport />
</div> </div>
</ModalContent> </ModalContent>
</Modal>

View File

@ -18,18 +18,17 @@
.root { .root {
height: calc(100vh - 60px); height: calc(100vh - 60px);
display: grid; display: grid;
grid-template-columns: 300px minmax(0, 1fr); grid-template-columns: 260px minmax(0, 1fr);
background: var(--grey-1); background: var(--grey-2);
line-height: 1;
} }
.content { .content {
flex: 1 1 auto; flex: 1 1 auto;
padding: var(--spacing-xl) 40px; padding: var(--spacing-l) 40px;
overflow-y: auto; overflow-y: auto;
} }
.nav { .nav {
overflow-y: auto; overflow-y: auto;
background: var(--white); background: var(--white);
padding: var(--spacing-xl); padding: var(--spacing-l) var(--spacing-xl);
} }
</style> </style>