-
- {#each fields as field}
-
- {#if !(schema[field].type === 'boolean' && !wide)}
-
- {/if}
- {#if schema[field].type === 'options'}
-
- {:else if schema[field].type === 'datetime'}
-
- {:else if schema[field].type === 'boolean'}
-
- {:else if schema[field].type === 'number'}
-
- {:else if schema[field].type === 'string'}
-
- {:else if schema[field].type === 'attachment'}
-
- {:else if schema[field].type === 'link'}
-
- {/if}
-
- {/each}
-
diff --git a/packages/standard-components/src/NewRow.svelte b/packages/standard-components/src/NewRow.svelte
new file mode 100644
index 0000000000..817e07e0d0
--- /dev/null
+++ b/packages/standard-components/src/NewRow.svelte
@@ -0,0 +1,37 @@
+
+
+
diff --git a/packages/standard-components/src/RowDetail.svelte b/packages/standard-components/src/RowDetail.svelte
index d20a6e706a..51df6d4b9f 100644
--- a/packages/standard-components/src/RowDetail.svelte
+++ b/packages/standard-components/src/RowDetail.svelte
@@ -20,6 +20,7 @@
if (response.status === 200) {
const allRows = await response.json()
if (allRows.length > 0) return allRows[0]
+ return { tableId: table }
}
}
@@ -29,31 +30,35 @@
let row
// if srcdoc, then we assume this is the builder preview
if (pathParts.length === 0 || pathParts[0] === "srcdoc") {
- row = await fetchFirstRow()
- } else {
- const id = pathParts[pathParts.length - 1]
- const GET_ROW_URL = `/api/${table}/rows/${id}`
+ if (table) row = await fetchFirstRow()
+ } else if (_bb.routeParams().id) {
+ const GET_ROW_URL = `/api/${table}/rows/${_bb.routeParams().id}`
const response = await _bb.api.get(GET_ROW_URL)
if (response.status === 200) {
row = await response.json()
+ } else {
+ throw new Error("Failed to fetch row.", response)
}
+ } else {
+ throw new Exception("Row ID was not supplied to RowDetail")
}
if (row) {
// Fetch table schema so we can check for linked rows
- const table = await fetchTable(row.tableId)
- for (let key of Object.keys(table.schema)) {
- if (table.schema[key].type === "link") {
+ const tableObj = await fetchTable(row.tableId)
+ for (let key of Object.keys(tableObj.schema)) {
+ if (tableObj.schema[key].type === "link") {
row[key] = Array.isArray(row[key]) ? row[key].length : 0
}
}
+ row._table = tableObj
+
_bb.attachChildren(target, {
- hydrate: false,
context: row,
})
} else {
- throw new Error("Failed to fetch row.", response)
+ _bb.attachChildren(target)
}
}
diff --git a/packages/standard-components/src/index.js b/packages/standard-components/src/index.js
index 369a01bfcd..f4bfd0e280 100644
--- a/packages/standard-components/src/index.js
+++ b/packages/standard-components/src/index.js
@@ -27,6 +27,7 @@ export { default as stackedlist } from "./StackedList.svelte"
export { default as card } from "./Card.svelte"
export { default as cardhorizontal } from "./CardHorizontal.svelte"
export { default as rowdetail } from "./RowDetail.svelte"
+export { default as newrow } from "./NewRow.svelte"
export { default as datepicker } from "./DatePicker.svelte"
export * from "./Chart"
export { default as icon } from "./Icon.svelte"