showing correct front end elements for selected database

This commit is contained in:
Martin McKeaveney 2020-03-27 12:38:27 +00:00
parent 72ce6833c0
commit fcce792341
2 changed files with 15 additions and 19 deletions

View File

@ -2,7 +2,7 @@
import ButtonGroup from "../common/ButtonGroup.svelte" import ButtonGroup from "../common/ButtonGroup.svelte"
import Button from "../common/Button.svelte" import Button from "../common/Button.svelte"
import ActionButton from "../common/ActionButton.svelte" import ActionButton from "../common/ActionButton.svelte"
import { store } from "../builderStore" import { store, backendUiStore } from "../builderStore"
import { generateFullPermissions, getNewAccessLevel } from "../common/core" import { generateFullPermissions, getNewAccessLevel } from "../common/core"
import getIcon from "../common/icon" import getIcon from "../common/icon"
import AccessLevelView from "./AccessLevelView.svelte" import AccessLevelView from "./AccessLevelView.svelte"
@ -10,7 +10,12 @@
let editingLevel = null let editingLevel = null
let editingLevelIsNew = false let editingLevelIsNew = false
$: isEditing = editingLevel !== null $: {
if (editingLevel !== null) {
backendUiStore.actions.modals.show("ACCESS_LEVELS")
}
}
$: modalOpen = $backendUiStore.visibleModal === 'ACCESS_LEVELS'
let allPermissions = [] let allPermissions = []
store.subscribe(db => { store.subscribe(db => {
@ -40,6 +45,7 @@
store.saveLevel(level, editingLevelIsNew, editingLevel) store.saveLevel(level, editingLevelIsNew, editingLevel)
} }
editingLevel = null editingLevel = null
backendUiStore.actions.modals.hide()
} }
const getPermissionsString = perms => { const getPermissionsString = perms => {
@ -83,10 +89,9 @@
{:else}(no actions added){/if} {:else}(no actions added){/if}
<Modal <Modal
onClosed={() => (isEditing = false)} onClosed={backendUiStore.actions.modals.hide}
bind:isOpen={isEditing} bind:isOpen={modalOpen}
title={isEditing ? 'Edit Access Level' : 'Create Access Level'}> title={modalOpen ? 'Edit Access Level' : 'Create Access Level'}>
{#if isEditing}
<AccessLevelView <AccessLevelView
level={editingLevel} level={editingLevel}
{allPermissions} {allPermissions}
@ -94,8 +99,8 @@
isNew={editingLevelIsNew} isNew={editingLevelIsNew}
allLevels={$store.accessLevels.levels} allLevels={$store.accessLevels.levels}
hierarchy={$store.hierarchy} hierarchy={$store.hierarchy}
actions={$store.actions} /> actions={$store.actions}
{/if} />
</Modal> </Modal>
</div> </div>
@ -106,13 +111,4 @@
position: relative; position: relative;
padding: 1.5rem; padding: 1.5rem;
} }
.actions-header {
flex: 0 1 auto;
}
.node-view {
overflow-y: auto;
flex: 1 1 auto;
}
</style> </style>

View File

@ -1,5 +1,5 @@
<script> <script>
import { store } from "../builderStore" import { store, backendUiStore } from "../builderStore"
import { map, join } from "lodash/fp" import { map, join } from "lodash/fp"
import { pipe } from "../common/core" import { pipe } from "../common/core"
@ -63,7 +63,7 @@
] ]
} }
}], }],
appRootPath: `/_builder/instance/${$store.appname}/${$store.currentInstanceId}/`, appRootPath: `/_builder/instance/${$store.appname}/${$backendUiStore.selectedDatabase.id}/`,
} }
$: backendDefinition = { $: backendDefinition = {