Prevent creating, deleting or editing global fields for user in the backend UI of the builder

This commit is contained in:
Andrew Kingston 2021-05-19 18:46:15 +01:00
parent d47c48352c
commit 441fbd37fb
4 changed files with 19 additions and 8 deletions

View File

@ -57,10 +57,12 @@
> >
<CreateColumnButton /> <CreateColumnButton />
{#if schema && Object.keys(schema).length > 0} {#if schema && Object.keys(schema).length > 0}
<CreateRowButton {#if !isUsersTable}
title={isUsersTable ? "Create user" : "Create row"} <CreateRowButton
modalContentComponent={isUsersTable ? CreateEditUser : CreateEditRow} title={"Create row"}
/> modalContentComponent={CreateEditRow}
/>
{/if}
<CreateViewButton /> <CreateViewButton />
<ManageAccessButton resourceId={$tables.selected?._id} /> <ManageAccessButton resourceId={$tables.selected?._id} />
{#if isUsersTable} {#if isUsersTable}

View File

@ -103,7 +103,7 @@
</div> </div>
<div class="popovers"> <div class="popovers">
<slot /> <slot />
{#if selectedRows.length > 0} {#if !isUsersTable && selectedRows.length > 0}
<DeleteRowsButton {selectedRows} {deleteRows} /> <DeleteRowsButton {selectedRows} {deleteRows} />
{/if} {/if}
</div> </div>
@ -116,7 +116,7 @@
{customRenderers} {customRenderers}
{rowCount} {rowCount}
bind:selectedRows bind:selectedRows
allowSelectRows={allowEditing} allowSelectRows={allowEditing && !isUsersTable}
allowEditRows={allowEditing} allowEditRows={allowEditing}
allowEditColumns={allowEditing} allowEditColumns={allowEditing}
showAutoColumns={!hideAutocolumns} showAutoColumns={!hideAutocolumns}

View File

@ -69,7 +69,7 @@
return false return false
} }
notifications.success("User saved successfully.") notifications.success("User saved successfully")
rows.save(rowResponse) rows.save(rowResponse)
} }
</script> </script>
@ -88,10 +88,12 @@
<RowFieldControl <RowFieldControl
meta={{ ...tableSchema.firstName, name: "First Name" }} meta={{ ...tableSchema.firstName, name: "First Name" }}
bind:value={row.firstName} bind:value={row.firstName}
readonly={!creating}
/> />
<RowFieldControl <RowFieldControl
meta={{ ...tableSchema.lastName, name: "Last Name" }} meta={{ ...tableSchema.lastName, name: "Last Name" }}
bind:value={row.lastName} bind:value={row.lastName}
readonly={!creating}
/> />
<!-- Defer rendering this select until roles load, otherwise the initial <!-- Defer rendering this select until roles load, otherwise the initial
selection is always undefined --> selection is always undefined -->

View File

@ -15,7 +15,14 @@ export const AppStatus = {
} }
// fields on the user table that cannot be edited // fields on the user table that cannot be edited
export const UNEDITABLE_USER_FIELDS = ["email", "password", "roleId", "status"] export const UNEDITABLE_USER_FIELDS = [
"email",
"password",
"roleId",
"status",
"firstName",
"lastName",
]
export const LAYOUT_NAMES = { export const LAYOUT_NAMES = {
MASTER: { MASTER: {