diff --git a/packages/standard-components/rollup.config.js b/packages/standard-components/rollup.config.js
index 2b5aa7ce3d..202adde702 100644
--- a/packages/standard-components/rollup.config.js
+++ b/packages/standard-components/rollup.config.js
@@ -4,6 +4,7 @@ import commonjs from "@rollup/plugin-commonjs"
import postcss from "rollup-plugin-postcss"
import { terser } from "rollup-plugin-terser"
+const production = !process.env.ROLLUP_WATCH
const lodash_fp_exports = ["isEmpty"]
export default {
@@ -17,7 +18,8 @@ export default {
},
],
plugins: [
- terser(),
+ // Only run terser in production environments
+ production && terser(),
postcss({
plugins: [],
}),
diff --git a/packages/standard-components/src/DataGrid/Component.svelte b/packages/standard-components/src/DataGrid/Component.svelte
index 471d02cc68..050c4eae42 100644
--- a/packages/standard-components/src/DataGrid/Component.svelte
+++ b/packages/standard-components/src/DataGrid/Component.svelte
@@ -68,7 +68,7 @@
field: key,
hide: shouldHideField(key),
sortable: true,
- editable: canEdit,
+ editable: canEdit && schema[key].type !== "link",
cellRenderer: getRenderer(schema[key], canEdit),
autoHeight: true,
}
diff --git a/packages/standard-components/src/DataGrid/Relationship/RelationshipDisplay.svelte b/packages/standard-components/src/DataGrid/Relationship/RelationshipDisplay.svelte
new file mode 100644
index 0000000000..219b7f761f
--- /dev/null
+++ b/packages/standard-components/src/DataGrid/Relationship/RelationshipDisplay.svelte
@@ -0,0 +1,69 @@
+
+
+
+ {#if linkedRows && linkedRows.length && displayColumn}
+ {#each linkedRows as linkedRow}
+ {#if linkedRow[displayColumn] != null && linkedRow[displayColumn] !== ''}
+
{linkedRow[displayColumn]}
+ {/if}
+ {/each}
+ {:else}{count} related row(s){/if}
+
+
+
diff --git a/packages/standard-components/src/DataGrid/Relationship/tableCache.js b/packages/standard-components/src/DataGrid/Relationship/tableCache.js
new file mode 100644
index 0000000000..850bdd212a
--- /dev/null
+++ b/packages/standard-components/src/DataGrid/Relationship/tableCache.js
@@ -0,0 +1,20 @@
+import api from "../../api"
+
+let cache = {}
+
+async function fetchTable(id) {
+ const FETCH_TABLE_URL = `/api/tables/${id}`
+ const response = await api.get(FETCH_TABLE_URL)
+ return await response.json()
+}
+
+export async function getTable(tableId) {
+ if (!tableId) {
+ return null
+ }
+ if (!cache[tableId]) {
+ cache[tableId] = fetchTable(tableId)
+ cache[tableId] = await cache[tableId]
+ }
+ return await cache[tableId]
+}
diff --git a/packages/standard-components/src/DataGrid/customRenderer.js b/packages/standard-components/src/DataGrid/customRenderer.js
index e3f07eda47..7ed81d694b 100644
--- a/packages/standard-components/src/DataGrid/customRenderer.js
+++ b/packages/standard-components/src/DataGrid/customRenderer.js
@@ -4,6 +4,7 @@
import AttachmentCell from "./AttachmentCell/Button.svelte"
import Select from "./Select/Wrapper.svelte"
import DatePicker from "./DateTime/Wrapper.svelte"
+import RelationshipDisplay from "./Relationship/RelationshipDisplay.svelte"
const renderers = new Map([
["boolean", booleanRenderer],
@@ -110,7 +111,13 @@ function linkedRowRenderer(constraints, editable) {
container.style.placeItems = "center"
container.style.height = "100%"
- container.innerText = params.value ? params.value.length : 0
+ new RelationshipDisplay({
+ target: container,
+ props: {
+ row: params.data,
+ columnName: params.column.colId,
+ },
+ })
return container
}