convert edit modal to use new modal
This commit is contained in:
parent
0887648221
commit
b0275f5bf6
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { onMount } from "svelte"
|
import { onMount, getContext } from "svelte"
|
||||||
import { store, backendUiStore } from "builderStore"
|
import { store, backendUiStore } from "builderStore"
|
||||||
import {
|
import {
|
||||||
tap,
|
tap,
|
||||||
|
@ -17,10 +17,28 @@
|
||||||
import { getIndexSchema } from "components/common/core"
|
import { getIndexSchema } from "components/common/core"
|
||||||
import ActionButton from "components/common/ActionButton.svelte"
|
import ActionButton from "components/common/ActionButton.svelte"
|
||||||
import TablePagination from "./TablePagination.svelte"
|
import TablePagination from "./TablePagination.svelte"
|
||||||
import { DeleteRecordModal } from "./modals"
|
import { DeleteRecordModal, CreateEditRecordModal } from "./modals"
|
||||||
import * as api from "./api"
|
import * as api from "./api"
|
||||||
|
|
||||||
export let selectRecord
|
const { open, close } = getContext("simple-modal")
|
||||||
|
|
||||||
|
const editRecord = async row => {
|
||||||
|
open(
|
||||||
|
CreateEditRecordModal,
|
||||||
|
{
|
||||||
|
onClosed: close,
|
||||||
|
record: await selectRecord(row),
|
||||||
|
},
|
||||||
|
{ styleContent: { padding: "0" } }
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function selectRecord(record) {
|
||||||
|
return await api.loadRecord(record.key, {
|
||||||
|
appname: $store.appname,
|
||||||
|
instanceId: $backendUiStore.selectedDatabase.id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const ITEMS_PER_PAGE = 10
|
const ITEMS_PER_PAGE = 10
|
||||||
// Internal headers we want to hide from the user
|
// Internal headers we want to hide from the user
|
||||||
|
@ -56,11 +74,7 @@
|
||||||
|
|
||||||
const getSchema = getIndexSchema($store.hierarchy)
|
const getSchema = getIndexSchema($store.hierarchy)
|
||||||
|
|
||||||
const childViewsForRecord = compose(
|
const childViewsForRecord = compose(flatten, map("indexes"), get("children"))
|
||||||
flatten,
|
|
||||||
map("indexes"),
|
|
||||||
get("children")
|
|
||||||
)
|
|
||||||
|
|
||||||
const hideInternalHeaders = compose(
|
const hideInternalHeaders = compose(
|
||||||
remove(headerName => INTERNAL_HEADERS.includes(headerName)),
|
remove(headerName => INTERNAL_HEADERS.includes(headerName)),
|
||||||
|
@ -133,8 +147,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li
|
<li
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
selectRecord(row)
|
editRecord(row)
|
||||||
backendUiStore.actions.modals.show('RECORD')
|
|
||||||
}}>
|
}}>
|
||||||
<div>Edit</div>
|
<div>Edit</div>
|
||||||
</li>
|
</li>
|
||||||
|
@ -166,7 +179,6 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
|
@ -194,7 +206,7 @@
|
||||||
color: var(--button-text);
|
color: var(--button-text);
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
letter-spacing: 1px;
|
letter-spacing: 1px;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue