diff --git a/packages/frontend-core/src/components/grid/cells/DataCell.svelte b/packages/frontend-core/src/components/grid/cells/DataCell.svelte
index 19bdf1bd74..daf0a03276 100644
--- a/packages/frontend-core/src/components/grid/cells/DataCell.svelte
+++ b/packages/frontend-core/src/components/grid/cells/DataCell.svelte
@@ -56,7 +56,10 @@
isActive: () => api?.isActive?.() ?? false,
onKeyDown: (...params) => api?.onKeyDown(...params),
isReadonly: () => readonly,
- getType: () => column.schema.type,
+ getType: () => {
+ console.log("getType", column)
+ return column.schema.type
+ },
getValue: () => row[column.name],
setValue: (value, options = { save: true }) => {
validation.actions.setError(cellId, null)
diff --git a/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte b/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte
index c5f1f7896a..a58b4c8fe4 100644
--- a/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte
+++ b/packages/frontend-core/src/components/grid/cells/HeaderCell.svelte
@@ -20,6 +20,8 @@
config,
ui,
columns,
+ definition,
+ datasource,
} = getContext("grid")
const bannedDisplayColumnTypes = [
@@ -118,6 +120,33 @@
open = false
}
+ const duplicateColumn = async () => {
+ open = false
+
+ // Generate new name
+ let newName = `${column.name} copy`
+ let attempts = 2
+ while ($definition.schema[newName]) {
+ newName = `${column.name} copy ${attempts++}`
+ }
+
+ // Save schema with new column
+ const existingColumnDefinition = $definition.schema[column.name]
+ await datasource.actions.saveDefinition({
+ ...$definition,
+ schema: {
+ ...$definition.schema,
+ [newName]: {
+ ...existingColumnDefinition,
+ name: newName,
+ schema: {
+ ...existingColumnDefinition.schema,
+ },
+ },
+ },
+ })
+ }
+
onMount(() => subscribe("close-edit-column", cancelEdit))
@@ -192,6 +221,13 @@
>
Edit column
+