Use unique user edit modal for editing users in sheets
This commit is contained in:
parent
91ee5be7c5
commit
a06f584e7d
|
@ -6,7 +6,8 @@
|
||||||
import { API } from "api"
|
import { API } from "api"
|
||||||
|
|
||||||
import SheetAddColumnModal from "components/backend/DataTable/modals/sheet/SheetCreateColumnModal.svelte"
|
import SheetAddColumnModal from "components/backend/DataTable/modals/sheet/SheetCreateColumnModal.svelte"
|
||||||
import SheetAddRowModal from "components/backend/DataTable/modals/sheet/SheetCreateRowModal.svelte"
|
import SheetCreateEditRowModal from "components/backend/DataTable/modals/sheet/SheetCreateEditRowModal.svelte"
|
||||||
|
import SheetEditUserModal from "components/backend/DataTable/modals/sheet/SheetEditUserModal.svelte"
|
||||||
import SheetCreateViewButton from "components/backend/DataTable/buttons/sheet/SheetCreateViewButton.svelte"
|
import SheetCreateViewButton from "components/backend/DataTable/buttons/sheet/SheetCreateViewButton.svelte"
|
||||||
import SheetImportButton from "components/backend/DataTable/buttons/sheet/SheetImportButton.svelte"
|
import SheetImportButton from "components/backend/DataTable/buttons/sheet/SheetImportButton.svelte"
|
||||||
import SheetExportButton from "components/backend/DataTable/buttons/sheet/SheetExportButton.svelte"
|
import SheetExportButton from "components/backend/DataTable/buttons/sheet/SheetExportButton.svelte"
|
||||||
|
@ -44,7 +45,11 @@
|
||||||
<SheetFilterButton />
|
<SheetFilterButton />
|
||||||
<SheetAddColumnModal />
|
<SheetAddColumnModal />
|
||||||
<SheetEditColumnModal />
|
<SheetEditColumnModal />
|
||||||
<SheetAddRowModal />
|
{#if isUsersTable}
|
||||||
|
<SheetEditUserModal />
|
||||||
|
{:else}
|
||||||
|
<SheetCreateEditRowModal />
|
||||||
|
{/if}
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</Sheet>
|
</Sheet>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -55,9 +55,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await API.saveRow({ ...row, tableId: table._id })
|
const res = await API.saveRow({ ...row, tableId: table._id })
|
||||||
notifications.success("User saved successfully")
|
notifications.success("User saved successfully")
|
||||||
dispatch("updaterows")
|
dispatch("updaterows", res.id)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.handled) {
|
if (error.handled) {
|
||||||
const response = error.json
|
const response = error.json
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<script>
|
||||||
|
import CreateEditUser from "../../modals/CreateEditUser.svelte"
|
||||||
|
import { getContext, onMount } from "svelte"
|
||||||
|
import { Modal } from "@budibase/bbui"
|
||||||
|
import { cloneDeep } from "lodash/fp"
|
||||||
|
|
||||||
|
const { subscribe, rows } = getContext("sheet")
|
||||||
|
|
||||||
|
let modal
|
||||||
|
let row
|
||||||
|
|
||||||
|
onMount(() =>
|
||||||
|
subscribe("edit-row", rowToEdit => {
|
||||||
|
row = cloneDeep(rowToEdit)
|
||||||
|
modal.show()
|
||||||
|
})
|
||||||
|
)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Modal bind:this={modal}>
|
||||||
|
<CreateEditUser
|
||||||
|
{row}
|
||||||
|
on:updaterows={e => rows.actions.refreshRow(e.detail)}
|
||||||
|
/>
|
||||||
|
</Modal>
|
|
@ -28,7 +28,10 @@
|
||||||
$: error = getErrorStore(rowFocused, cellId)
|
$: error = getErrorStore(rowFocused, cellId)
|
||||||
|
|
||||||
// Determine if the cell is editable
|
// Determine if the cell is editable
|
||||||
$: readonly = column.schema.autocolumn || (!$config.allowEditRows && row._id)
|
$: readonly =
|
||||||
|
column.schema.autocolumn ||
|
||||||
|
column.schema.readonly ||
|
||||||
|
(!$config.allowEditRows && row._id)
|
||||||
|
|
||||||
// Register this cell API if the row is focused
|
// Register this cell API if the row is focused
|
||||||
$: {
|
$: {
|
||||||
|
|
|
@ -142,7 +142,7 @@ export const initialise = context => {
|
||||||
columns.set(
|
columns.set(
|
||||||
fields
|
fields
|
||||||
.map(field => ({
|
.map(field => ({
|
||||||
name: field,
|
name: schema[field].name || field,
|
||||||
schema: schema[field],
|
schema: schema[field],
|
||||||
width: schema[field].width || DefaultColumnWidth,
|
width: schema[field].width || DefaultColumnWidth,
|
||||||
visible: schema[field].visible ?? true,
|
visible: schema[field].visible ?? true,
|
||||||
|
|
Loading…
Reference in New Issue