further tidy up
This commit is contained in:
parent
1c329cac60
commit
e772283914
|
@ -14,6 +14,7 @@
|
||||||
CreateEditViewModal,
|
CreateEditViewModal,
|
||||||
CreateDatabaseModal,
|
CreateDatabaseModal,
|
||||||
DeleteRecordModal,
|
DeleteRecordModal,
|
||||||
|
CreateUserModal
|
||||||
} from "./ModelDataTable/modals"
|
} from "./ModelDataTable/modals"
|
||||||
|
|
||||||
let selectedRecord
|
let selectedRecord
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
$: viewOpen = $backendUiStore.visibleModal === "VIEW"
|
$: viewOpen = $backendUiStore.visibleModal === "VIEW"
|
||||||
$: databaseOpen = $backendUiStore.visibleModal === "DATABASE"
|
$: databaseOpen = $backendUiStore.visibleModal === "DATABASE"
|
||||||
$: deleteRecordOpen = $backendUiStore.visibleModal === "DELETE_RECORD"
|
$: deleteRecordOpen = $backendUiStore.visibleModal === "DELETE_RECORD"
|
||||||
|
$: userOpen = $backendUiStore.visibleModal === "USER"
|
||||||
$: breadcrumbs = $store.currentNode
|
$: breadcrumbs = $store.currentNode
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -50,6 +52,9 @@
|
||||||
{#if deleteRecordOpen}
|
{#if deleteRecordOpen}
|
||||||
<DeleteRecordModal record={selectedRecord} {onClosed} />
|
<DeleteRecordModal record={selectedRecord} {onClosed} />
|
||||||
{/if}
|
{/if}
|
||||||
|
{#if userOpen}
|
||||||
|
<CreateUserModal {onClosed} />
|
||||||
|
{/if}
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
<script>
|
|
||||||
import Modal from "../../common/Modal.svelte"
|
|
||||||
import ActionButton from "../../common/ActionButton.svelte"
|
|
||||||
import * as api from "./api"
|
|
||||||
|
|
||||||
export let modalOpen = false
|
|
||||||
|
|
||||||
let recordInfo = {}
|
|
||||||
|
|
||||||
const onClosed = () => (modalOpen = false)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Modal {onClosed} isOpen={modalOpen}>
|
|
||||||
|
|
||||||
<div class="actions">
|
|
||||||
<ActionButton alert on:click={onClosed}>Cancel</ActionButton>
|
|
||||||
<ActionButton
|
|
||||||
disabled={false}
|
|
||||||
on:click={() => api.createNewRecord(recordInfo)}>
|
|
||||||
Save
|
|
||||||
</ActionButton>
|
|
||||||
</div>
|
|
||||||
</Modal>
|
|
|
@ -15,13 +15,28 @@
|
||||||
|
|
||||||
$: currentAppInfo = {
|
$: currentAppInfo = {
|
||||||
appname: $store.appname,
|
appname: $store.appname,
|
||||||
instanceId: $backendUiStore.selectedDatabase.id
|
instanceId: $backendUiStore.selectedDatabase.id,
|
||||||
}
|
}
|
||||||
$: recordFields = record ? Object.keys(record) : []
|
$: recordFields = record ? Object.keys(record) : []
|
||||||
$: models = $store.hierarchy.children
|
$: models = $store.hierarchy.children
|
||||||
$: modelFields = selectedModel
|
$: modelFields = selectedModel
|
||||||
? selectedModel.fields.map(({ name }) => name)
|
? selectedModel.fields.map(({ name }) => name)
|
||||||
: []
|
: []
|
||||||
|
|
||||||
|
async function saveRecord() {
|
||||||
|
const recordResponse = await api.saveRecord(
|
||||||
|
record || selectedModel,
|
||||||
|
currentAppInfo
|
||||||
|
)
|
||||||
|
backendUiStore.update(state => {
|
||||||
|
const idx = findIndex(state.selectedView.records, {
|
||||||
|
id: recordResponse.id,
|
||||||
|
})
|
||||||
|
state.selectedView.records.splice(idx, 1, recordResponse)
|
||||||
|
return state
|
||||||
|
})
|
||||||
|
onClosed()
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -66,17 +81,7 @@
|
||||||
<footer>
|
<footer>
|
||||||
<ActionButton alert on:click={onClosed}>Cancel</ActionButton>
|
<ActionButton alert on:click={onClosed}>Cancel</ActionButton>
|
||||||
<ActionButton
|
<ActionButton
|
||||||
on:click={async () => {
|
on:click={saveRecord}>
|
||||||
const recordResponse = await api.saveRecord(record || selectedModel, currentAppInfo)
|
|
||||||
backendUiStore.update(state => {
|
|
||||||
const idx = findIndex(state.selectedView.records, {
|
|
||||||
id: recordResponse.id
|
|
||||||
})
|
|
||||||
state.selectedView.records.splice(idx, 1, recordResponse)
|
|
||||||
return state
|
|
||||||
})
|
|
||||||
onClosed()
|
|
||||||
}}>
|
|
||||||
Save
|
Save
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
</footer>
|
</footer>
|
||||||
|
@ -92,4 +97,4 @@
|
||||||
left: 0;
|
left: 0;
|
||||||
background: #fafafa;
|
background: #fafafa;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,12 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import Modal from "../../../common/Modal.svelte"
|
|
||||||
import ActionButton from "../../../common/ActionButton.svelte"
|
|
||||||
import IndexView from "../../IndexView.svelte"
|
import IndexView from "../../IndexView.svelte"
|
||||||
import ActionsHeader from "../../ActionsHeader.svelte"
|
import ActionsHeader from "../../ActionsHeader.svelte"
|
||||||
import * as api from "../api"
|
import * as api from "../api"
|
||||||
|
|
||||||
let recordInfo = {}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
|
|
@ -4,12 +4,10 @@
|
||||||
import ActionButton from "../../../common/ActionButton.svelte"
|
import ActionButton from "../../../common/ActionButton.svelte"
|
||||||
import * as api from "../api"
|
import * as api from "../api"
|
||||||
|
|
||||||
export let modalOpen = false
|
export let onClosed
|
||||||
|
|
||||||
let userName
|
let userName
|
||||||
|
|
||||||
const onClosed = () => (modalOpen = false)
|
|
||||||
|
|
||||||
async function createUser() {
|
async function createUser() {
|
||||||
const response = await api.createUser($store.appname, userName)
|
const response = await api.createUser($store.appname, userName)
|
||||||
store.createUserForInstance(response)
|
store.createUserForInstance(response)
|
||||||
|
@ -17,11 +15,24 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Modal {onClosed} isOpen={modalOpen}>
|
<section>
|
||||||
CREATE A NEW user FROM HERE
|
User Name
|
||||||
<input type="text" bind:value={userName} />
|
<input class="uk-input" type="text" bind:value={userName} />
|
||||||
<div class="actions">
|
<footer>
|
||||||
<ActionButton alert on:click={onClosed}>Cancel</ActionButton>
|
<ActionButton alert on:click={onClosed}>Cancel</ActionButton>
|
||||||
<ActionButton disabled={!userName} on:click={createUser}>Save</ActionButton>
|
<ActionButton disabled={!userName} on:click={createUser}>
|
||||||
</div>
|
Save
|
||||||
</Modal>
|
</ActionButton>
|
||||||
|
</footer>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
footer {
|
||||||
|
position: absolute;
|
||||||
|
padding: 20px;
|
||||||
|
width: 100%;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
background: #fafafa;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
|
@ -2,4 +2,5 @@ export { default as DeleteRecordModal } from "./DeleteRecord.svelte";
|
||||||
export { default as CreateEditRecordModal } from "./CreateEditRecord.svelte";
|
export { default as CreateEditRecordModal } from "./CreateEditRecord.svelte";
|
||||||
export { default as CreateEditModelModal } from "./CreateEditModel.svelte";
|
export { default as CreateEditModelModal } from "./CreateEditModel.svelte";
|
||||||
export { default as CreateEditViewModal } from "./CreateEditView.svelte";
|
export { default as CreateEditViewModal } from "./CreateEditView.svelte";
|
||||||
export { default as CreateDatabaseModal } from "./CreateDatabase.svelte";
|
export { default as CreateDatabaseModal } from "./CreateDatabase.svelte";
|
||||||
|
export { default as CreateUserModal } from "./CreateUser.svelte";
|
|
@ -237,7 +237,6 @@ module.exports = (config, app) => {
|
||||||
} else {
|
} else {
|
||||||
ctx.response.status = StatusCodes.UNAUTHORIZED
|
ctx.response.status = StatusCodes.UNAUTHORIZED
|
||||||
}
|
}
|
||||||
next()
|
|
||||||
})
|
})
|
||||||
.post("/:appname/api/changeMyPassword", routeHandlers.changeMyPassword)
|
.post("/:appname/api/changeMyPassword", routeHandlers.changeMyPassword)
|
||||||
.post(
|
.post(
|
||||||
|
|
Loading…
Reference in New Issue