diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte
index 2869b82e70..5ff7925c5f 100644
--- a/packages/builder/src/components/backend/DataTable/DataTable.svelte
+++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte
@@ -8,10 +8,13 @@
import * as api from "./api"
import Table from "./Table.svelte"
import { TableNames } from "constants"
+ import CreateEditUser from "./modals/CreateEditUser.svelte"
+ import CreateEditRow from "./modals/CreateEditRow.svelte"
let data = []
let loading = false
+ $: isUsersTable = $backendUiStore.selectedTable?._id === TableNames.USERS
$: title = $backendUiStore.selectedTable.name
$: schema = $backendUiStore.selectedTable.schema
$: tableView = {
@@ -31,14 +34,21 @@
}
-
+
{#if schema && Object.keys(schema).length > 0}
-
+
{/if}
- {#if $backendUiStore.selectedTable?._id === TableNames.USERS}
+ {#if isUsersTable}
{/if}
diff --git a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte
index 8b1c2e18e6..bddb66e4c9 100644
--- a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte
+++ b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte
@@ -7,20 +7,16 @@
Toggle,
RichText,
} from "@budibase/bbui"
- import { backendUiStore } from "builderStore"
- import { TableNames } from "constants"
import Dropzone from "components/common/Dropzone.svelte"
import { capitalise } from "../../../helpers"
import LinkedRowSelector from "components/common/LinkedRowSelector.svelte"
export let meta
- export let creating
export let value = meta.type === "boolean" ? false : ""
+ export let readonly
$: type = meta.type
$: label = capitalise(meta.name)
- $: editingUser =
- !creating && $backendUiStore.selectedTable?._id === TableNames.USERS
{#if type === 'options'}
@@ -53,5 +49,5 @@
data-cy="{meta.name}-input"
{type}
bind:value
- disabled={editingUser} />
+ disabled={readonly} />
{/if}
diff --git a/packages/builder/src/components/backend/DataTable/Table.svelte b/packages/builder/src/components/backend/DataTable/Table.svelte
index 2599e4f8b0..67fc417191 100644
--- a/packages/builder/src/components/backend/DataTable/Table.svelte
+++ b/packages/builder/src/components/backend/DataTable/Table.svelte
@@ -7,10 +7,15 @@
import { notifier } from "builderStore/store/notifications"
import Spinner from "components/common/Spinner.svelte"
import DeleteRowsButton from "./buttons/DeleteRowsButton.svelte"
- import { getRenderer, editRowRenderer } from "./cells/cellRenderers"
+ import {
+ getRenderer,
+ editRowRenderer,
+ userRowRenderer,
+ } from "./cells/cellRenderers"
import TableLoadingOverlay from "./TableLoadingOverlay"
import TableHeader from "./TableHeader"
import "@budibase/svelte-ag-grid/dist/index.css"
+ import { TableNames } from "constants"
export let schema = {}
export let data = []
@@ -42,6 +47,14 @@
animateRows: true,
}
+ $: isUsersTable = tableId === TableNames.USERS
+ $: {
+ if (isUsersTable) {
+ schema.username.displayFieldName = "Username"
+ schema.roleId.displayFieldName = "Role"
+ }
+ }
+
$: {
let result = []
if (allowEditing) {
@@ -57,12 +70,12 @@
suppressMenu: true,
minWidth: 114,
width: 114,
- cellRenderer: editRowRenderer,
+ cellRenderer: isUsersTable ? userRowRenderer : editRowRenderer,
},
]
}
- Object.keys(schema || {}).forEach((key, idx) => {
+ Object.entries(schema || {}).forEach(([key, value]) => {
result.push({
headerCheckboxSelection: false,
headerComponent: TableHeader,
@@ -70,7 +83,7 @@
field: schema[key],
editable: allowEditing,
},
- headerName: key,
+ headerName: value.displayFieldName || key,
field: key,
sortable: true,
cellRenderer: getRenderer(schema[key], true),
diff --git a/packages/builder/src/components/backend/DataTable/buttons/CreateRowButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/CreateRowButton.svelte
index 3c0444881f..dfd8e6f4ac 100644
--- a/packages/builder/src/components/backend/DataTable/buttons/CreateRowButton.svelte
+++ b/packages/builder/src/components/backend/DataTable/buttons/CreateRowButton.svelte
@@ -1,6 +1,8 @@
@@ -12,5 +14,5 @@
-
+
diff --git a/packages/builder/src/components/backend/DataTable/cells/cellRenderers.js b/packages/builder/src/components/backend/DataTable/cells/cellRenderers.js
index 209f23119f..f3a7b86740 100644
--- a/packages/builder/src/components/backend/DataTable/cells/cellRenderers.js
+++ b/packages/builder/src/components/backend/DataTable/cells/cellRenderers.js
@@ -1,5 +1,6 @@
import AttachmentList from "./AttachmentCell.svelte"
import EditRow from "../modals/EditRow.svelte"
+import CreateEditUser from "../modals/CreateEditUser.svelte"
import DeleteRow from "../modals/DeleteRow.svelte"
import RelationshipDisplay from "./RelationshipCell.svelte"
@@ -45,6 +46,23 @@ export function editRowRenderer(params) {
return container
}
+export function userRowRenderer(params) {
+ const container = document.createElement("div")
+ container.style.height = "100%"
+ container.style.display = "flex"
+ container.style.alignItems = "center"
+
+ new EditRow({
+ target: container,
+ props: {
+ row: params.data,
+ modalContentComponent: CreateEditUser,
+ },
+ })
+
+ return container
+}
+
/* eslint-disable no-unused-vars */
function attachmentRenderer(options, constraints, editable) {
return params => {
diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditRowModal.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte
similarity index 81%
rename from packages/builder/src/components/backend/DataTable/modals/CreateEditRowModal.svelte
rename to packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte
index e99c5762d8..050c7ce200 100644
--- a/packages/builder/src/components/backend/DataTable/modals/CreateEditRowModal.svelte
+++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte
@@ -1,6 +1,5 @@
+
+
+
+
+ {#if creating}
+
+ {/if}
+
+ {#if rolesLoaded}
+
+ {/if}
+ {#each customSchemaKeys as [key, meta]}
+
+ {/each}
+
diff --git a/packages/builder/src/components/backend/DataTable/modals/EditRow.svelte b/packages/builder/src/components/backend/DataTable/modals/EditRow.svelte
index a4d2a74fc2..5d858a50f4 100644
--- a/packages/builder/src/components/backend/DataTable/modals/EditRow.svelte
+++ b/packages/builder/src/components/backend/DataTable/modals/EditRow.svelte
@@ -1,8 +1,9 @@