iterate over package app instances

This commit is contained in:
Martin McKeaveney 2020-03-10 16:06:30 +00:00
parent 62176b6b14
commit 8c983192e6
10 changed files with 230 additions and 91 deletions

View File

@ -20,13 +20,13 @@
<BackendNav /> <BackendNav />
</div> </div>
<div class="content"> <div class="content">
{#if activeNav === 'database'} <!-- {#if activeNav === 'database'} -->
<Database /> <Database />
{:else if activeNav === 'actions'} <!-- {:else if activeNav === 'actions'}
<ActionsAndTriggers /> <ActionsAndTriggers />
{:else if activeNav === 'access levels'} {:else if activeNav === 'access levels'}
<AccessLevels /> <AccessLevels />
{/if} {/if} -->
</div> </div>
<div class="nav"> <div class="nav">
<SchemaManagementDrawer /> <SchemaManagementDrawer />
@ -43,9 +43,6 @@
.content { .content {
flex: 1 1 auto; flex: 1 1 auto;
margin: 80px 60px; margin: 80px 60px;
background: #fff;
border-radius: 5px;
box-shadow: 0 0px 6px rgba(0, 0, 0, 0.05);
} }
.nav { .nav {

View File

@ -6,6 +6,13 @@
import { fade } from "svelte/transition" import { fade } from "svelte/transition"
import { SettingsIcon, PreviewIcon, HelpIcon } from "./common/Icons/" import { SettingsIcon, PreviewIcon, HelpIcon } from "./common/Icons/"
const TABS = {
BACKEND: "backend",
FRONTEND: "frontend",
}
let selectedTab = TABS.BACKEND
</script> </script>
<div class="root"> <div class="root">
@ -19,37 +26,37 @@
color="var(--slate)" color="var(--slate)"
hoverColor="var(--secondary75)"/> --> hoverColor="var(--secondary75)"/> -->
<span <span
class:active={$store.isBackend} class:active={selectedTab === TABS.BACKEND}
class="topnavitem" class="topnavitem"
on:click={store.showBackend}> on:click={() => selectedTab = TABS.BACKEND}>
Backend Backend
</span> </span>
<span <span
class:active={!$store.isBackend} class:active={selectedTab === TABS.FRONTEND}
class="topnavitem" class="topnavitem"
on:click={store.showFrontend}> on:click={() => selectedTab = TABS.FRONTEND}>
Frontend Frontend
</span> </span>
</div> </div>
<div class="toprightnav"> <div class="toprightnav">
<span <span
class:active={!$store.isBackend} class:active={selectedTab === TABS.FRONTEND}
class="topnavitemright" class="topnavitemright"
on:click={store.showFrontend}> on:click={() => selectedTab === TABS.FRONTEND}>
<SettingsIcon /> <SettingsIcon />
</span> </span>
<span <span
class:active={!$store.isBackend} class:active={selectedTab === TABS.FRONTEND}
class="topnavitemright" class="topnavitemright"
on:click={store.showFrontend}> on:click={() => selectedTab === TABS.FRONTEND}>
<PreviewIcon /> <PreviewIcon />
</span> </span>
</div> </div>
</div> </div>
<div class="content"> <div class="content">
{#if $store.isBackend} {#if selectedTab === TABS.BACKEND}
<div in:fade out:fade> <div in:fade out:fade>
<BackendRoot /> <BackendRoot />
</div> </div>

View File

@ -55,7 +55,6 @@ export const getStore = () => {
currentComponentProps: null, currentComponentProps: null,
currentNodeIsNew: false, currentNodeIsNew: false,
errors: [], errors: [],
isBackend: true,
hasAppPackage: false, hasAppPackage: false,
accessLevels: { version: 0, levels: [] }, accessLevels: { version: 0, levels: [] },
currentNode: null, currentNode: null,
@ -66,6 +65,61 @@ export const getStore = () => {
const store = writable(initial) const store = writable(initial)
// store.api = {
// appDefinition: {
// create: () => {},
// },
// records: {
// create: () => {},
// update: () => {},
// delete: () => {},
// },
// indexes: {
// create: () => {},
// update: () => {},
// delete: () => {},
// },
// pages: {
// create: () => {},
// update: () => {},
// delete: () => {},
// },
// screens: {
// create: () => {},
// select: () => {},
// rename: () => {}
// },
// accessLevels: {
// create: () => {},
// update: () => {},
// delete: () => {},
// },
// users: {
// create: () => {},
// update: () => {},
// delete: () => {},
// },
// actions: {
// update: () => {},
// delete: () => {}
// },
// triggers: {
// create: () => {},
// update: () => {},
// delete: () => {},
// },
// stylesheets: {
// create: () => {},
// update: () => {},
// delete: () => {},
// },
// components: {
// create: () => {},
// update: () => {},
// delete: () => {},
// }
// }
store.initialise = initialise(store, initial) store.initialise = initialise(store, initial)
store.newChildRecord = newRecord(store, false) store.newChildRecord = newRecord(store, false)
store.newRootRecord = newRecord(store, true) store.newRootRecord = newRecord(store, true)
@ -94,8 +148,8 @@ export const getStore = () => {
store.addStylesheet = addStylesheet(store) store.addStylesheet = addStylesheet(store)
store.removeStylesheet = removeStylesheet(store) store.removeStylesheet = removeStylesheet(store)
store.savePage = savePage(store) store.savePage = savePage(store)
store.showFrontend = showFrontend(store) // store.showFrontend = showFrontend(store)
store.showBackend = showBackend(store) // store.showBackend = showBackend(store)
store.showSettings = showSettings(store) store.showSettings = showSettings(store)
store.useAnalytics = useAnalytics(store) store.useAnalytics = useAnalytics(store)
store.createGeneratedComponents = createGeneratedComponents(store) store.createGeneratedComponents = createGeneratedComponents(store)
@ -172,6 +226,7 @@ const initialise = (store, initial) => async () => {
initial.builtins = [getBuiltin("##builtin/screenslot")] initial.builtins = [getBuiltin("##builtin/screenslot")]
initial.actions = values(pkg.appDefinition.actions) initial.actions = values(pkg.appDefinition.actions)
initial.triggers = pkg.appDefinition.triggers initial.triggers = pkg.appDefinition.triggers
initial.appInstances = pkg.application.instances
if (!!initial.hierarchy && !isEmpty(initial.hierarchy)) { if (!!initial.hierarchy && !isEmpty(initial.hierarchy)) {
initial.hierarchy = constructHierarchy(initial.hierarchy) initial.hierarchy = constructHierarchy(initial.hierarchy)
@ -185,9 +240,9 @@ const initialise = (store, initial) => async () => {
} }
const showSettings = store => () => { const showSettings = store => () => {
store.update(s => { store.update(state => {
s.showSettings = !s.showSettings state.showSettings = !state.showSettings
return s return state
}) })
} }
@ -198,20 +253,6 @@ const useAnalytics = store => () => {
}) })
} }
const showBackend = store => () => {
store.update(s => {
s.isBackend = true
return s
})
}
const showFrontend = store => () => {
store.update(s => {
s.isBackend = false
return s
})
}
const newRecord = (store, useRoot) => () => { const newRecord = (store, useRoot) => () => {
store.update(s => { store.update(s => {
s.currentNodeIsNew = true s.currentNodeIsNew = true
@ -377,10 +418,10 @@ const saveAction = store => (newAction, isNew, oldAction = null) => {
} }
const deleteAction = store => action => { const deleteAction = store => action => {
store.update(s => { store.update(state => {
s.actions = filter(a => a.name !== action.name)(s.actions) state.actions = state.actions.filter(a => a.name !== action.name);
saveBackend(s) saveBackend(state);
return s return state;
}) })
} }

View File

@ -14,12 +14,12 @@
<style> <style>
.select-container { .select-container {
padding-bottom: 10px;
font-size: 0.9rem; font-size: 0.9rem;
color: var(--secondary50); color: var(--secondary50);
font-weight: bold; font-weight: bold;
position: relative; position: relative;
max-width: 300px; max-width: 300px;
min-width: 200px;
} }
select { select {
@ -43,7 +43,6 @@
.arrow { .arrow {
position: absolute; position: absolute;
right: 10px; right: 10px;
top: 0;
bottom: 0; bottom: 0;
margin: auto; margin: auto;
width: 30px; width: 30px;

View File

@ -1,52 +1,60 @@
<script> <script>
import Select from "../../common/Select.svelte"
import ActionButton from "../../common/ActionButton.svelte"
let pages = [1, 2, 3] let pages = [1, 2, 3]
export let data = [] export let data = [
{ name: "Joe", inStock: true },
{ name: "Mike", inStock: false },
{ name: "Martin", inStock: true },
]
export let headers = ["name", "inStock"]
export let pageSize = 10 export let pageSize = 10
</script> </script>
<section> <section>
<h4 class="budibase__title--3">Shoe database</h4>
<div class="table-controls">
<Select />
<ActionButton primary>Create new record</ActionButton>
</div>
<table class="uk-table"> <table class="uk-table">
<caption>Shoe Database</caption>
<thead> <thead>
<tr> <tr>
<th>Table Heading</th> <th>Edit</th>
<th>Table Heading</th> {#each headers as header}
<th>Table Heading</th> <th>{header}</th>
{/each}
</tr> </tr>
</thead> </thead>
<tfoot>
<tr>
<td>Table Footer</td>
<td>Table Footer</td>
<td>Table Footer</td>
</tr>
</tfoot>
<tbody> <tbody>
{#each data as row}
<tr> <tr>
<td>Table Data</td> <td>
<td>Table Data</td> <i class="ri-more-line" />
<td>Table Data</td> </td>
</tr> {#each headers as header}
<tr> <td>{row[header]}</td>
<td>Table Data</td> {/each}
<td>Table Data</td>
<td>Table Data</td>
</tr> </tr>
{/each}
</tbody> </tbody>
</table> </table>
<div class="pagination"> <div class="pagination">
<button>Previous</button> <button>Previous</button>
<button>Next</button> <button>Next</button>
{#each data as page} <!-- {#each data as page}
<button>{page}</button> <button>{page}</button>
{/each} {/each} -->
</div> </div>
</section> </section>
<style> <style>
table { table {
border: 1px solid #ccc; border: 1px solid #ccc;
background: #fff;
border-radius: 2px;
} }
thead { thead {
@ -56,8 +64,16 @@
thead th { thead th {
color: var(--button-text); color: var(--button-text);
text-transform: capitalize; text-transform: capitalize;
font-weight: 500;
} }
tr { tr {
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
} }
.table-controls {
display: flex;
justify-content: space-between;
align-items: center;
}
</style> </style>

View File

@ -3,7 +3,7 @@
import { store } from "../builderStore" import { store } from "../builderStore"
import HierarchyRow from "./HierarchyRow.svelte" import HierarchyRow from "./HierarchyRow.svelte"
import DatabasesList from "./DatabasesList.svelte" import DatabasesList from "./DatabasesList.svelte"
import DropdownButton from "../common/DropdownButton.svelte" import UsersList from "./UsersList.svelte"
import { hierarchy as hierarchyFunctions } from "../../../core/src" import { hierarchy as hierarchyFunctions } from "../../../core/src"
import NavItem from "./NavItem.svelte" import NavItem from "./NavItem.svelte"
import getIcon from "../common/icon" import getIcon from "../common/icon"
@ -68,7 +68,7 @@
<div class="components-list-container"> <div class="components-list-container">
<div class="nav-group-header"> <div class="nav-group-header">
<div class="hierarchy-title">Databases</div> <div class="hierarchy-title">Databases</div>
<DropdownButton iconName="plus" actions={databaseManagementActions} /> <i class="ri-add-line" />
</div> </div>
</div> </div>
@ -89,11 +89,12 @@
<div class="components-list-container"> <div class="components-list-container">
<div class="nav-group-header"> <div class="nav-group-header">
<div class="hierarchy-title">Users</div> <div class="hierarchy-title">Users</div>
<DropdownButton iconName="plus" actions={userManagementActions} /> <i class="ri-add-line" />
</div> </div>
</div> </div>
<div class="hierarchy-items-container"> <div class="hierarchy-items-container">
<UsersList />
<!-- {#each $store.hierarchy.children as record} <!-- {#each $store.hierarchy.children as record}
<HierarchyRow node={record} type="record" /> <HierarchyRow node={record} type="record" />
{/each} --> {/each} -->

View File

@ -3,30 +3,12 @@
import getIcon from "../common/icon" import getIcon from "../common/icon"
import { CheckIcon } from "../common/Icons" import { CheckIcon } from "../common/Icons"
const getPage = (s, name) => { $: instances = $store.appInstances
const props = s.pages[name]
return { name, props }
}
$: databases = $store.app
const pages = [
{
title: "Main",
id: "main",
},
{
title: "Login",
id: "unauthenticated",
},
]
store.setCurrentPage("main")
</script> </script>
<div class="root"> <div class="root">
<ul> <ul>
{#each pages as { title, id }} {#each $store.appInstances as { id, name }}
<li> <li>
<span class="icon"> <span class="icon">
{#if id === $store.currentPageName} {#if id === $store.currentPageName}
@ -37,7 +19,7 @@
<button <button
class:active={id === $store.currentPageName} class:active={id === $store.currentPageName}
on:click={() => store.setCurrentPage(id)}> on:click={() => store.setCurrentPage(id)}>
{title} {name}
</button> </button>
</li> </li>
{/each} {/each}

View File

@ -25,7 +25,8 @@
<div> <div>
<div <div
on:click={() => store.selectExistingNode(node.nodeId)} on:click={() => store.selectExistingNode(node.nodeId)}
class="budibase__nav-item" class="budibase__nav-item hierarchy-item"
class:capitalized={type === "record"}
style="padding-left: {20 + level * 20}px" style="padding-left: {20 + level * 20}px"
class:selected={navActive}> class:selected={navActive}>
<i class={ICON_MAP[type]} /> <i class={ICON_MAP[type]} />
@ -42,3 +43,14 @@
{/each} {/each}
{/if} {/if}
</div> </div>
<style>
.hierarchy-item {
font-size: 14px;
font-weight: 400;
}
.capitalized {
text-transform: capitalize;
}
</style>

View File

@ -98,6 +98,7 @@
.nav-group-header { .nav-group-header {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center;
padding: 2rem 1rem 1rem 1rem; padding: 2rem 1rem 1rem 1rem;
} }

View File

@ -0,0 +1,83 @@
<script>
import { store } from "../builderStore"
import getIcon from "../common/icon"
import { CheckIcon } from "../common/Icons"
const getPage = (s, name) => {
const props = s.pages[name]
return { name, props }
}
const pages = [
{
title: "Joe",
id: "joe",
},
{
title: "Mike",
id: "mike",
},
{
title: "Martin",
id: "martin",
},
]
store.setCurrentPage("main")
</script>
<div class="root">
<ul>
{#each pages as { title, id }}
<li>
<i class="ri-user-4-line" />
<button
class:active={id === $store.currentPageName}
on:click={() => store.setCurrentPage(id)}>
{title}
</button>
</li>
{/each}
</ul>
</div>
<style>
.root {
padding-bottom: 10px;
font-size: 0.9rem;
color: var(--secondary50);
font-weight: bold;
position: relative;
padding-left: 1.8rem;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
li {
margin: 0.5rem 0;
}
button {
margin: 0 0 0 6px;
padding: 0;
border: none;
font-family: Roboto;
font-size: 0.8rem;
outline: none;
cursor: pointer;
}
.active {
font-weight: 500;
}
.icon {
display: inline-block;
width: 14px;
color: #333;
}
</style>