@budibase/frontend-core 2.10.7 → 2.10.9-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@budibase/frontend-core",
3
- "version": "2.10.7",
3
+ "version": "2.10.9-alpha.0",
4
4
  "description": "Budibase frontend core libraries used in builder and client",
5
5
  "author": "Budibase",
6
6
  "license": "MPL-2.0",
7
7
  "svelte": "src/index.js",
8
8
  "dependencies": {
9
- "@budibase/bbui": "2.10.7",
10
- "@budibase/shared-core": "2.10.7",
9
+ "@budibase/bbui": "2.10.9-alpha.0",
10
+ "@budibase/shared-core": "2.10.9-alpha.0",
11
11
  "dayjs": "^1.11.7",
12
12
  "lodash": "^4.17.21",
13
13
  "socket.io-client": "^4.6.1",
14
14
  "svelte": "^3.46.2"
15
15
  },
16
- "gitHead": "2e6fd02d84cf819c52678d941719926f50faa052"
16
+ "gitHead": "0ff953da1672a51bd006ab218c948c11c5d09eeb"
17
17
  }
@@ -1,5 +1,5 @@
1
1
  <script>
2
- import dayjs from "dayjs"
2
+ import { dayjs } from "dayjs"
3
3
  import { CoreDatePicker, Icon } from "@budibase/bbui"
4
4
  import { onMount } from "svelte"
5
5
 
@@ -20,6 +20,8 @@
20
20
  config,
21
21
  ui,
22
22
  columns,
23
+ definition,
24
+ datasource,
23
25
  } = getContext("grid")
24
26
 
25
27
  const bannedDisplayColumnTypes = [
@@ -118,6 +120,33 @@
118
120
  open = false
119
121
  }
120
122
 
123
+ const duplicateColumn = async () => {
124
+ open = false
125
+
126
+ // Generate new name
127
+ let newName = `${column.name} copy`
128
+ let attempts = 2
129
+ while ($definition.schema[newName]) {
130
+ newName = `${column.name} copy ${attempts++}`
131
+ }
132
+
133
+ // Save schema with new column
134
+ const existingColumnDefinition = $definition.schema[column.name]
135
+ await datasource.actions.saveDefinition({
136
+ ...$definition,
137
+ schema: {
138
+ ...$definition.schema,
139
+ [newName]: {
140
+ ...existingColumnDefinition,
141
+ name: newName,
142
+ schema: {
143
+ ...existingColumnDefinition.schema,
144
+ },
145
+ },
146
+ },
147
+ })
148
+ }
149
+
121
150
  onMount(() => subscribe("close-edit-column", cancelEdit))
122
151
  </script>
123
152
 
@@ -192,6 +221,13 @@
192
221
  >
193
222
  Edit column
194
223
  </MenuItem>
224
+ <MenuItem
225
+ icon="Duplicate"
226
+ on:click={duplicateColumn}
227
+ disabled={!$config.canEditColumns}
228
+ >
229
+ Duplicate column
230
+ </MenuItem>
195
231
  <MenuItem
196
232
  icon="Label"
197
233
  on:click={makeDisplayColumn}