@budibase/frontend-core 2.14.2 → 2.14.3
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 +4 -4
- package/src/utils/utils.js +107 -3
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/frontend-core",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.3",
|
|
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.14.
|
|
10
|
-
"@budibase/shared-core": "2.14.
|
|
9
|
+
"@budibase/bbui": "2.14.3",
|
|
10
|
+
"@budibase/shared-core": "2.14.3",
|
|
11
11
|
"dayjs": "^1.10.8",
|
|
12
12
|
"lodash": "4.17.21",
|
|
13
13
|
"socket.io-client": "^4.6.1",
|
|
14
14
|
"svelte": "^3.49.0"
|
|
15
15
|
},
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "0f5e11730fae0cf2bbe6539d5234bf311eafe5d6"
|
|
17
17
|
}
|
package/src/utils/utils.js
CHANGED
|
@@ -116,7 +116,7 @@ export const domDebounce = callback => {
|
|
|
116
116
|
*
|
|
117
117
|
* @param {any} props
|
|
118
118
|
* */
|
|
119
|
-
export const
|
|
119
|
+
export const buildFormBlockButtonConfig = props => {
|
|
120
120
|
const {
|
|
121
121
|
_id,
|
|
122
122
|
actionType,
|
|
@@ -130,7 +130,6 @@ export const buildDynamicButtonConfig = props => {
|
|
|
130
130
|
} = props || {}
|
|
131
131
|
|
|
132
132
|
if (!_id) {
|
|
133
|
-
console.log("MISSING ID")
|
|
134
133
|
return
|
|
135
134
|
}
|
|
136
135
|
const formId = `${_id}-form`
|
|
@@ -228,7 +227,7 @@ export const buildDynamicButtonConfig = props => {
|
|
|
228
227
|
})
|
|
229
228
|
}
|
|
230
229
|
|
|
231
|
-
if (actionType
|
|
230
|
+
if (actionType === "Update" && showDeleteButton !== false) {
|
|
232
231
|
defaultButtons.push({
|
|
233
232
|
text: deleteText || "Delete",
|
|
234
233
|
_id: Helpers.uuid(),
|
|
@@ -241,3 +240,108 @@ export const buildDynamicButtonConfig = props => {
|
|
|
241
240
|
|
|
242
241
|
return defaultButtons
|
|
243
242
|
}
|
|
243
|
+
|
|
244
|
+
export const buildMultiStepFormBlockDefaultProps = props => {
|
|
245
|
+
const { _id, stepCount, currentStep, actionType, dataSource } = props || {}
|
|
246
|
+
|
|
247
|
+
// Sanity check
|
|
248
|
+
if (!_id || !stepCount) {
|
|
249
|
+
return
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const title = `Step {{ [${_id}-form].[__currentStep] }}`
|
|
253
|
+
const resourceId = dataSource?.resourceId
|
|
254
|
+
const formId = `${_id}-form`
|
|
255
|
+
let buttons = []
|
|
256
|
+
|
|
257
|
+
// Add previous step button if we aren't the first step
|
|
258
|
+
if (currentStep !== 0) {
|
|
259
|
+
buttons.push({
|
|
260
|
+
_id: Helpers.uuid(),
|
|
261
|
+
_component: "@budibase/standard-components/button",
|
|
262
|
+
_instanceName: Helpers.uuid(),
|
|
263
|
+
text: "Back",
|
|
264
|
+
type: "secondary",
|
|
265
|
+
size: "M",
|
|
266
|
+
onClick: [
|
|
267
|
+
{
|
|
268
|
+
parameters: {
|
|
269
|
+
type: "prev",
|
|
270
|
+
componentId: formId,
|
|
271
|
+
},
|
|
272
|
+
"##eventHandlerType": "Change Form Step",
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
})
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Add a next button if we aren't the last step
|
|
279
|
+
if (currentStep !== stepCount - 1) {
|
|
280
|
+
buttons.push({
|
|
281
|
+
_id: Helpers.uuid(),
|
|
282
|
+
_component: "@budibase/standard-components/button",
|
|
283
|
+
_instanceName: Helpers.uuid(),
|
|
284
|
+
text: "Next",
|
|
285
|
+
type: "cta",
|
|
286
|
+
size: "M",
|
|
287
|
+
onClick: [
|
|
288
|
+
{
|
|
289
|
+
"##eventHandlerType": "Validate Form",
|
|
290
|
+
parameters: {
|
|
291
|
+
componentId: formId,
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
parameters: {
|
|
296
|
+
type: "next",
|
|
297
|
+
componentId: formId,
|
|
298
|
+
},
|
|
299
|
+
"##eventHandlerType": "Change Form Step",
|
|
300
|
+
},
|
|
301
|
+
],
|
|
302
|
+
})
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Add save button if we are the last step
|
|
306
|
+
if (actionType !== "View" && currentStep === stepCount - 1) {
|
|
307
|
+
buttons.push({
|
|
308
|
+
_id: Helpers.uuid(),
|
|
309
|
+
_component: "@budibase/standard-components/button",
|
|
310
|
+
_instanceName: Helpers.uuid(),
|
|
311
|
+
text: "Save",
|
|
312
|
+
type: "cta",
|
|
313
|
+
size: "M",
|
|
314
|
+
onClick: [
|
|
315
|
+
{
|
|
316
|
+
"##eventHandlerType": "Validate Form",
|
|
317
|
+
parameters: {
|
|
318
|
+
componentId: formId,
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
"##eventHandlerType": "Save Row",
|
|
323
|
+
parameters: {
|
|
324
|
+
tableId: resourceId,
|
|
325
|
+
providerId: formId,
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
// Clear a create form once submitted
|
|
329
|
+
...(actionType !== "Create"
|
|
330
|
+
? []
|
|
331
|
+
: [
|
|
332
|
+
{
|
|
333
|
+
"##eventHandlerType": "Clear Form",
|
|
334
|
+
parameters: {
|
|
335
|
+
componentId: formId,
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
]),
|
|
339
|
+
],
|
|
340
|
+
})
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return {
|
|
344
|
+
buttons,
|
|
345
|
+
title,
|
|
346
|
+
}
|
|
347
|
+
}
|