implements new modal component for access level modal and create database modal
This commit is contained in:
parent
d09f16a147
commit
1f4e5339e4
|
@ -1,4 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
|
import Modal from "svelte-simple-modal"
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { Router } from "@sveltech/routify"
|
import { Router } from "@sveltech/routify"
|
||||||
import { routes } from "@sveltech/routify/tmp/routes"
|
import { routes } from "@sveltech/routify/tmp/routes"
|
||||||
|
@ -23,4 +24,6 @@
|
||||||
|
|
||||||
<AppNotification />
|
<AppNotification />
|
||||||
|
|
||||||
<Router {routes} />
|
<Modal>
|
||||||
|
<Router {routes} />
|
||||||
|
</Modal>
|
||||||
|
|
|
@ -302,7 +302,7 @@ export const deleteLevel = store => level => {
|
||||||
state.accessLevels.levels = state.accessLevels.levels.filter(
|
state.accessLevels.levels = state.accessLevels.levels.filter(
|
||||||
t => t.name !== level.name
|
t => t.name !== level.name
|
||||||
)
|
)
|
||||||
incrementAccessLevelsVersion(s)
|
incrementAccessLevelsVersion(state)
|
||||||
saveBackend(state)
|
saveBackend(state)
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
export let allLevels
|
export let allLevels
|
||||||
export let hierarchy
|
export let hierarchy
|
||||||
export let actions
|
export let actions
|
||||||
|
export let close
|
||||||
|
export let title
|
||||||
|
|
||||||
let errors = []
|
let errors = []
|
||||||
let clonedLevel = cloneDeep(level)
|
let clonedLevel = cloneDeep(level)
|
||||||
|
@ -38,9 +40,9 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
const getPermissionName = perm =>
|
const getPermissionName = perm =>
|
||||||
perm.nodeKey
|
perm.nodeKey
|
||||||
? `${perm.type} - ${nodeNameFromNodeKey(hierarchy, perm.nodeKey)}`
|
? `${perm.type} - ${nodeNameFromNodeKey(hierarchy, perm.nodeKey)}`
|
||||||
: perm.type
|
: perm.type
|
||||||
|
|
||||||
const save = () => {
|
const save = () => {
|
||||||
const newLevels = isNew
|
const newLevels = isNew
|
||||||
|
@ -52,6 +54,7 @@
|
||||||
if (errors.length > 0) return
|
if (errors.length > 0) return
|
||||||
|
|
||||||
onFinished(clonedLevel)
|
onFinished(clonedLevel)
|
||||||
|
close()
|
||||||
}
|
}
|
||||||
|
|
||||||
const permissionChanged = perm => ev => {
|
const permissionChanged = perm => ev => {
|
||||||
|
@ -70,6 +73,10 @@
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
|
<div class="uk-modal-header">
|
||||||
|
<h4 class="budibase__title--4">{title}</h4>
|
||||||
|
</div>
|
||||||
|
|
||||||
<ErrorsBox {errors} />
|
<ErrorsBox {errors} />
|
||||||
|
|
||||||
<form class="uk-form-horizontal">
|
<form class="uk-form-horizontal">
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
|
import Modal from "components/common/Modal.svelte"
|
||||||
import ActionButton from "components/common/ActionButton.svelte"
|
import ActionButton from "components/common/ActionButton.svelte"
|
||||||
import * as api from "../api"
|
import * as api from "../api"
|
||||||
|
|
||||||
|
@ -14,24 +15,25 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<div>
|
||||||
Database Name
|
<section>
|
||||||
<input class="uk-input" type="text" bind:value={databaseName} />
|
Database Name
|
||||||
|
<input class="uk-input" type="text" bind:value={databaseName} />
|
||||||
|
</section>
|
||||||
<footer>
|
<footer>
|
||||||
<ActionButton alert on:click={onClosed}>Cancel</ActionButton>
|
<ActionButton alert on:click={onClosed}>Cancel</ActionButton>
|
||||||
<ActionButton disabled={!databaseName} on:click={createDatabase}>
|
<ActionButton disabled={!databaseName} on:click={createDatabase}>
|
||||||
Save
|
Save
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
</footer>
|
</footer>
|
||||||
</section>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
section {
|
||||||
|
padding: 30px;
|
||||||
|
}
|
||||||
footer {
|
footer {
|
||||||
position: absolute;
|
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
width: 100%;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
background: #fafafa;
|
background: #fafafa;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -6,6 +6,18 @@
|
||||||
import UsersList from "./UsersList.svelte"
|
import UsersList from "./UsersList.svelte"
|
||||||
import NavItem from "./NavItem.svelte"
|
import NavItem from "./NavItem.svelte"
|
||||||
import getIcon from "components/common/icon"
|
import getIcon from "components/common/icon"
|
||||||
|
import { CreateDatabaseModal } from "components/database/ModelDataTable/modals"
|
||||||
|
const { open, close } = getContext("simple-modal")
|
||||||
|
|
||||||
|
const openDatabaseCreator = () => {
|
||||||
|
open(
|
||||||
|
CreateDatabaseModal,
|
||||||
|
{
|
||||||
|
onClosed: close,
|
||||||
|
},
|
||||||
|
{ styleContent: { padding: "0" } }
|
||||||
|
)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="items-root">
|
<div class="items-root">
|
||||||
|
@ -13,9 +25,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>
|
||||||
<i
|
<i class="ri-add-line hoverable" on:click={openDatabaseCreator} />
|
||||||
class="ri-add-line hoverable"
|
|
||||||
on:click={() => backendUiStore.actions.modals.show('DATABASE')} />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { getContext } from "svelte"
|
||||||
import { store, backendUiStore } from "builderStore"
|
import { store, backendUiStore } from "builderStore"
|
||||||
import * as api from "components/database/ModelDataTable/api"
|
import * as api from "components/database/ModelDataTable/api"
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@
|
||||||
$: userOpen = $backendUiStore.visibleModal === "USER"
|
$: userOpen = $backendUiStore.visibleModal === "USER"
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal isOpen={!!$backendUiStore.visibleModal} {onClosed}>
|
<!-- <Modal isOpen={!!$backendUiStore.visibleModal} {onClosed}>
|
||||||
{#if recordOpen}
|
{#if recordOpen}
|
||||||
<CreateEditRecordModal record={selectedRecord} {onClosed} />
|
<CreateEditRecordModal record={selectedRecord} {onClosed} />
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -54,7 +55,7 @@
|
||||||
{#if userOpen}
|
{#if userOpen}
|
||||||
<CreateUserModal {onClosed} />
|
<CreateUserModal {onClosed} />
|
||||||
{/if}
|
{/if}
|
||||||
</Modal>
|
</Modal> -->
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
<div class="nav">
|
<div class="nav">
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { getContext } from "svelte"
|
||||||
|
const { open, close } = getContext("simple-modal")
|
||||||
|
|
||||||
import ButtonGroup from "components/common/ButtonGroup.svelte"
|
import ButtonGroup from "components/common/ButtonGroup.svelte"
|
||||||
import Button from "components/common/Button.svelte"
|
import Button from "components/common/Button.svelte"
|
||||||
import ActionButton from "components/common/ActionButton.svelte"
|
import ActionButton from "components/common/ActionButton.svelte"
|
||||||
|
@ -9,38 +12,33 @@
|
||||||
} from "components/common/core"
|
} from "components/common/core"
|
||||||
import getIcon from "components/common/icon"
|
import getIcon from "components/common/icon"
|
||||||
import AccessLevelView from "components/accessLevels/AccessLevelView.svelte"
|
import AccessLevelView from "components/accessLevels/AccessLevelView.svelte"
|
||||||
import Modal from "components/common/Modal.svelte"
|
|
||||||
|
|
||||||
let editingLevel = null
|
let editingLevel = null
|
||||||
let editingLevelIsNew = false
|
let editingLevelIsNew = false
|
||||||
$: {
|
|
||||||
if (editingLevel !== null) {
|
|
||||||
backendUiStore.actions.modals.show("ACCESS_LEVELS")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$: modalOpen = $backendUiStore.visibleModal === "ACCESS_LEVELS"
|
|
||||||
|
|
||||||
let allPermissions = []
|
let allPermissions = []
|
||||||
store.subscribe(db => {
|
store.subscribe(db => {
|
||||||
allPermissions = generateFullPermissions(db.hierarchy, db.actions)
|
allPermissions = generateFullPermissions(db.hierarchy, db.actions)
|
||||||
})
|
})
|
||||||
|
|
||||||
let onLevelEdit = level => {
|
const openModal = (level, newLevel) => {
|
||||||
editingLevel = level
|
editingLevel = level
|
||||||
editingLevelIsNew = false
|
editingLevelIsNew = newLevel
|
||||||
|
open(AccessLevelView, {
|
||||||
|
level: editingLevel,
|
||||||
|
allPermissions,
|
||||||
|
onFinished: onEditingFinished,
|
||||||
|
isNew: editingLevelIsNew,
|
||||||
|
allLevels: $store.accessLevels.levels,
|
||||||
|
hierarchy: $store.hierarchy,
|
||||||
|
actions: $store.actions,
|
||||||
|
close: close,
|
||||||
|
title: "Access Level",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
let onLevelCancel = () => {
|
let cancel = () => {
|
||||||
editingAction = null
|
editingAction = null
|
||||||
}
|
close()
|
||||||
|
|
||||||
let onLevelDelete = level => {
|
|
||||||
store.deleteLevel(level)
|
|
||||||
}
|
|
||||||
|
|
||||||
let createNewLevel = () => {
|
|
||||||
editingLevelIsNew = true
|
|
||||||
editingLevel = getNewAccessLevel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let onEditingFinished = level => {
|
let onEditingFinished = level => {
|
||||||
|
@ -48,7 +46,7 @@
|
||||||
store.saveLevel(level, editingLevelIsNew, editingLevel)
|
store.saveLevel(level, editingLevelIsNew, editingLevel)
|
||||||
}
|
}
|
||||||
editingLevel = null
|
editingLevel = null
|
||||||
backendUiStore.actions.modals.hide()
|
close()
|
||||||
}
|
}
|
||||||
|
|
||||||
const getPermissionsString = perms => {
|
const getPermissionsString = perms => {
|
||||||
|
@ -58,7 +56,7 @@
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
<ButtonGroup>
|
<ButtonGroup>
|
||||||
<ActionButton primary on:click={createNewLevel}>
|
<ActionButton primary on:click={() => openModal(getNewAccessLevel(), true)}>
|
||||||
Create New Access Level
|
Create New Access Level
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
|
@ -78,10 +76,10 @@
|
||||||
<td>{level.name}</td>
|
<td>{level.name}</td>
|
||||||
<td>{getPermissionsString(level.permissions)}</td>
|
<td>{getPermissionsString(level.permissions)}</td>
|
||||||
<td class="edit-button">
|
<td class="edit-button">
|
||||||
<span on:click={() => onLevelEdit(level)}>
|
<span on:click={() => openModal(level, false)}>
|
||||||
{@html getIcon('edit')}
|
{@html getIcon('edit')}
|
||||||
</span>
|
</span>
|
||||||
<span on:click={() => onLevelDelete(level)}>
|
<span on:click={() => store.deleteLevel(level)}>
|
||||||
{@html getIcon('trash')}
|
{@html getIcon('trash')}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
|
@ -91,20 +89,6 @@
|
||||||
</table>
|
</table>
|
||||||
{:else}(no actions added){/if}
|
{:else}(no actions added){/if}
|
||||||
|
|
||||||
<Modal
|
|
||||||
onClosed={backendUiStore.actions.modals.hide}
|
|
||||||
bind:isOpen={modalOpen}
|
|
||||||
title={modalOpen ? 'Edit Access Level' : 'Create Access Level'}>
|
|
||||||
<AccessLevelView
|
|
||||||
level={editingLevel}
|
|
||||||
{allPermissions}
|
|
||||||
onFinished={onEditingFinished}
|
|
||||||
isNew={editingLevelIsNew}
|
|
||||||
allLevels={$store.accessLevels.levels}
|
|
||||||
hierarchy={$store.hierarchy}
|
|
||||||
actions={$store.actions} />
|
|
||||||
</Modal>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
Loading…
Reference in New Issue