started drilldown
This commit is contained in:
parent
e073d30e44
commit
b26a5ed6a4
|
@ -21,6 +21,7 @@ export const getBackendUiStore = () => {
|
||||||
records: [],
|
records: [],
|
||||||
name: ""
|
name: ""
|
||||||
},
|
},
|
||||||
|
breadcrumbs: [],
|
||||||
selectedRecord: {},
|
selectedRecord: {},
|
||||||
selectedDatabase: {},
|
selectedDatabase: {},
|
||||||
selectedModel: {},
|
selectedModel: {},
|
||||||
|
@ -31,11 +32,19 @@ export const getBackendUiStore = () => {
|
||||||
store.actions = {
|
store.actions = {
|
||||||
navigate: name => store.update(state => ({ ...state, leftNavItem: name })),
|
navigate: name => store.update(state => ({ ...state, leftNavItem: name })),
|
||||||
database: {
|
database: {
|
||||||
select: db => store.update(state => ({ ...state, selectedDatabase: db })),
|
select: db => store.update(state => {
|
||||||
|
state.selectedDatabase = db
|
||||||
|
state.breadcrumbs = [db.name]
|
||||||
|
return state
|
||||||
|
})
|
||||||
},
|
},
|
||||||
records: {
|
records: {
|
||||||
delete: record => store.update(state => {
|
delete: record => store.update(state => {
|
||||||
state.selectedView.records = remove(state.selectedView.records, { id: record.id });
|
state.selectedView.records = state.selectedView.records.filter(({ id }) => id !== record.id)
|
||||||
|
return state
|
||||||
|
}),
|
||||||
|
view: record => store.update(state => {
|
||||||
|
state.breadcrumbs = [state.selectedDatabase.name, record.id]
|
||||||
return state
|
return state
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
|
|
@ -164,6 +164,7 @@ const initialise = (store, initial) => async () => {
|
||||||
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
|
initial.appInstances = pkg.application.instances
|
||||||
|
initial.appId = pkg.application.id
|
||||||
|
|
||||||
if (!!initial.hierarchy && !isEmpty(initial.hierarchy)) {
|
if (!!initial.hierarchy && !isEmpty(initial.hierarchy)) {
|
||||||
initial.hierarchy = constructHierarchy(initial.hierarchy)
|
initial.hierarchy = constructHierarchy(initial.hierarchy)
|
||||||
|
|
|
@ -118,6 +118,7 @@ export const getNewInstance = (appId, name) => {
|
||||||
version: { key: "" },
|
version: { key: "" },
|
||||||
isNew: true,
|
isNew: true,
|
||||||
type: "instance",
|
type: "instance",
|
||||||
|
datastoreconfig: "",
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
$: databaseOpen = $backendUiStore.visibleModal === "DATABASE"
|
$: databaseOpen = $backendUiStore.visibleModal === "DATABASE"
|
||||||
$: deleteRecordOpen = $backendUiStore.visibleModal === "DELETE_RECORD"
|
$: deleteRecordOpen = $backendUiStore.visibleModal === "DELETE_RECORD"
|
||||||
$: userOpen = $backendUiStore.visibleModal === "USER"
|
$: userOpen = $backendUiStore.visibleModal === "USER"
|
||||||
$: breadcrumbs = $store.currentNode
|
$: breadcrumbs = $backendUiStore.breadcrumbs.join(" / ")
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal isOpen={!!$backendUiStore.visibleModal} {onClosed}>
|
<Modal isOpen={!!$backendUiStore.visibleModal} {onClosed}>
|
||||||
|
@ -61,9 +61,7 @@
|
||||||
<div class="node-view">
|
<div class="node-view">
|
||||||
<div class="database-actions">
|
<div class="database-actions">
|
||||||
<div class="budibase__label--big">
|
<div class="budibase__label--big">
|
||||||
{#if $backendUiStore.selectedDatabase.name}
|
{breadcrumbs}
|
||||||
{$backendUiStore.selectedDatabase.name} {breadcrumbs}
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
{#if $backendUiStore.selectedDatabase.id}
|
{#if $backendUiStore.selectedDatabase.id}
|
||||||
<ActionButton
|
<ActionButton
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { store, backendUiStore } from "../../builderStore"
|
import { store, backendUiStore } from "../../builderStore"
|
||||||
|
import { last } from "lodash/fp";
|
||||||
import Select from "../../common/Select.svelte"
|
import Select from "../../common/Select.svelte"
|
||||||
import { getIndexSchema } from "../../common/core"
|
import { getIndexSchema } from "../../common/core"
|
||||||
import ActionButton from "../../common/ActionButton.svelte"
|
import ActionButton from "../../common/ActionButton.svelte"
|
||||||
|
@ -42,6 +43,15 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function drillIntoRecord(record) {
|
||||||
|
backendUiStore.update(state => {
|
||||||
|
state.selectedRecord = record
|
||||||
|
state.breadcrumbs = [state.selectedDatabase.name, record.id]
|
||||||
|
// Update the dropdown with the child indexes for that record
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if (views.length > 0) {
|
if (views.length > 0) {
|
||||||
await fetchRecordsForView(views[0].name, currentAppInfo)
|
await fetchRecordsForView(views[0].name, currentAppInfo)
|
||||||
|
@ -52,7 +62,7 @@
|
||||||
<section>
|
<section>
|
||||||
<div class="table-controls">
|
<div class="table-controls">
|
||||||
<h4 class="budibase__title--3">
|
<h4 class="budibase__title--3">
|
||||||
{$backendUiStore.selectedDatabase.name || ''}
|
{last($backendUiStore.breadcrumbs)}
|
||||||
</h4>
|
</h4>
|
||||||
<Select
|
<Select
|
||||||
icon="ri-eye-line"
|
icon="ri-eye-line"
|
||||||
|
@ -83,7 +93,7 @@
|
||||||
<div uk-dropdown="mode: click">
|
<div uk-dropdown="mode: click">
|
||||||
<ul class="uk-nav uk-dropdown-nav">
|
<ul class="uk-nav uk-dropdown-nav">
|
||||||
<li>
|
<li>
|
||||||
<div on:click={async () => {}}>View</div>
|
<div on:click={() => drillIntoRecord(row)}>View</div>
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
|
@ -101,14 +111,6 @@
|
||||||
Delete
|
Delete
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<div
|
|
||||||
on:click={async () => {
|
|
||||||
const response = await api.saveRecord(row)
|
|
||||||
}}>
|
|
||||||
Duplicate
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import { getNewRecord, getNewInstance } from "../../common/core"
|
import { getNewRecord, getNewInstance } from "../../common/core"
|
||||||
|
|
||||||
export async function createDatabase(appname, instanceName) {
|
export async function createDatabase(appname, instanceName) {
|
||||||
const CREATE_DATABASE_URL = `/_builder/instance/_master/0/api/record`
|
const CREATE_DATABASE_URL = `/_builder/instance/_master/0/api/record/`
|
||||||
const database = getNewInstance(appname, instanceName);
|
const database = getNewInstance(appname, instanceName);
|
||||||
const response = await api.post(CREATE_DATABASE_URL, database);
|
const response = await api.post(CREATE_DATABASE_URL, database);
|
||||||
return await response.json()
|
return await response.json()
|
||||||
|
@ -29,19 +29,6 @@
|
||||||
return await response.json()
|
return await response.json()
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function duplicateRecord(record, { appname, instanceId }) {
|
|
||||||
let recordBase = { ...record }
|
|
||||||
|
|
||||||
delete recordBase.id
|
|
||||||
|
|
||||||
recordBase = getNewRecord(recordBase, recordBase.key)
|
|
||||||
recordBase = overwritePresentProperties(recordBase, record)
|
|
||||||
|
|
||||||
const SAVE_RECORDS_URL = `/_builder/instance/${appname}/${instanceId}/api/record/`
|
|
||||||
const response = await api.post(SAVE_RECORDS_URL, recordBase)
|
|
||||||
return await response.json()
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function fetchDataForView(viewName, { appname, instanceId }) {
|
export async function fetchDataForView(viewName, { appname, instanceId }) {
|
||||||
const FETCH_RECORDS_URL = `/_builder/instance/${appname}/${instanceId}/api/listRecords/${viewName}`;
|
const FETCH_RECORDS_URL = `/_builder/instance/${appname}/${instanceId}/api/listRecords/${viewName}`;
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
let databaseName
|
let databaseName
|
||||||
|
|
||||||
async function createDatabase() {
|
async function createDatabase() {
|
||||||
const response = await api.createDatabase($store.appname, databaseName)
|
const response = await api.createDatabase($store.appId, databaseName)
|
||||||
store.createDatabaseForApp(response)
|
store.createDatabaseForApp(response)
|
||||||
onClosed()
|
onClosed()
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,14 @@
|
||||||
)
|
)
|
||||||
backendUiStore.update(state => {
|
backendUiStore.update(state => {
|
||||||
const idx = findIndex(state.selectedView.records, {
|
const idx = findIndex(state.selectedView.records, {
|
||||||
id: recordResponse.id,
|
id: recordResponse.id
|
||||||
})
|
})
|
||||||
state.selectedView.records.splice(idx, 1, recordResponse)
|
|
||||||
|
if (idx > 0) {
|
||||||
|
state.selectedView.records.splice(idx, 1, recordResponse)
|
||||||
|
} else {
|
||||||
|
state.selectedView.records.push(recordResponse)
|
||||||
|
}
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
onClosed()
|
onClosed()
|
||||||
|
|
|
@ -47,8 +47,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-actions {
|
.modal-actions {
|
||||||
|
padding: 10px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
background: #fafafa;
|
background: #fafafa;
|
||||||
border-top: 1px solid #ccc;
|
border-top: 1px solid #ccc;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
@ -7,17 +7,6 @@
|
||||||
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"
|
||||||
|
|
||||||
const newDatabase = () => {
|
|
||||||
store.update(state => {})
|
|
||||||
}
|
|
||||||
|
|
||||||
const databaseManagementActions = [
|
|
||||||
{
|
|
||||||
label: "New Database",
|
|
||||||
onclick: newDatabase,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="items-root">
|
<div class="items-root">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { store } from "../builderStore/store"
|
import { store } from "../builderStore"
|
||||||
import UIkit from "uikit"
|
import UIkit from "uikit"
|
||||||
import ActionButton from "../common/ActionButton.svelte"
|
import ActionButton from "../common/ActionButton.svelte"
|
||||||
import ButtonGroup from "../common/ButtonGroup.svelte"
|
import ButtonGroup from "../common/ButtonGroup.svelte"
|
||||||
|
|
Loading…
Reference in New Issue