@saltcorn/data 1.1.0-beta.2 → 1.1.0-beta.21
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/dist/base-plugin/actions.d.ts +135 -10
- package/dist/base-plugin/actions.d.ts.map +1 -1
- package/dist/base-plugin/actions.js +266 -45
- package/dist/base-plugin/actions.js.map +1 -1
- package/dist/base-plugin/index.d.ts +126 -123
- package/dist/base-plugin/index.d.ts.map +1 -1
- package/dist/base-plugin/types.d.ts.map +1 -1
- package/dist/base-plugin/types.js +14 -9
- package/dist/base-plugin/types.js.map +1 -1
- package/dist/base-plugin/viewtemplates/edit.d.ts +7 -4
- package/dist/base-plugin/viewtemplates/edit.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/edit.js +72 -10
- package/dist/base-plugin/viewtemplates/edit.js.map +1 -1
- package/dist/base-plugin/viewtemplates/room.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/room.js +7 -2
- package/dist/base-plugin/viewtemplates/room.js.map +1 -1
- package/dist/base-plugin/viewtemplates/show.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/show.js +7 -4
- package/dist/base-plugin/viewtemplates/show.js.map +1 -1
- package/dist/base-plugin/viewtemplates/viewable_fields.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/viewable_fields.js +10 -11
- package/dist/base-plugin/viewtemplates/viewable_fields.js.map +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/state.d.ts +16 -0
- package/dist/db/state.d.ts.map +1 -1
- package/dist/db/state.js +55 -3
- package/dist/db/state.js.map +1 -1
- package/dist/migrations/202412051957.d.ts +3 -0
- package/dist/migrations/202412051957.d.ts.map +1 -0
- package/dist/migrations/202412051957.js +48 -0
- package/dist/migrations/202412051957.js.map +1 -0
- package/dist/migrations/202412111526.d.ts +3 -0
- package/dist/migrations/202412111526.d.ts.map +1 -0
- package/dist/migrations/202412111526.js +38 -0
- package/dist/migrations/202412111526.js.map +1 -0
- package/dist/models/config.d.ts +0 -2
- package/dist/models/config.d.ts.map +1 -1
- package/dist/models/config.js +44 -34
- package/dist/models/config.js.map +1 -1
- package/dist/models/email.d.ts +1 -1
- package/dist/models/expression.d.ts.map +1 -1
- package/dist/models/expression.js +16 -2
- package/dist/models/expression.js.map +1 -1
- package/dist/models/field.d.ts.map +1 -1
- package/dist/models/field.js +22 -4
- package/dist/models/field.js.map +1 -1
- package/dist/models/file.d.ts +5 -2
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/file.js +3 -3
- package/dist/models/file.js.map +1 -1
- package/dist/models/form.d.ts.map +1 -1
- package/dist/models/form.js +5 -1
- package/dist/models/form.js.map +1 -1
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -1
- package/dist/models/index.js.map +1 -1
- package/dist/models/page.d.ts.map +1 -1
- package/dist/models/page.js +3 -1
- package/dist/models/page.js.map +1 -1
- package/dist/models/page_group.d.ts.map +1 -1
- package/dist/models/page_group.js +7 -1
- package/dist/models/page_group.js.map +1 -1
- package/dist/models/scheduler.d.ts.map +1 -1
- package/dist/models/scheduler.js +4 -0
- package/dist/models/scheduler.js.map +1 -1
- package/dist/models/table.d.ts +1 -0
- package/dist/models/table.d.ts.map +1 -1
- package/dist/models/table.js +34 -3
- package/dist/models/table.js.map +1 -1
- package/dist/models/trigger.d.ts +5 -1
- package/dist/models/trigger.d.ts.map +1 -1
- package/dist/models/trigger.js +38 -7
- package/dist/models/trigger.js.map +1 -1
- package/dist/models/view.js +3 -3
- package/dist/models/workflow_run.d.ts +77 -0
- package/dist/models/workflow_run.d.ts.map +1 -0
- package/dist/models/workflow_run.js +394 -0
- package/dist/models/workflow_run.js.map +1 -0
- package/dist/models/workflow_step.d.ts +58 -0
- package/dist/models/workflow_step.d.ts.map +1 -0
- package/dist/models/workflow_step.js +144 -0
- package/dist/models/workflow_step.js.map +1 -0
- package/dist/models/workflow_trace.d.ts +57 -0
- package/dist/models/workflow_trace.d.ts.map +1 -0
- package/dist/models/workflow_trace.js +90 -0
- package/dist/models/workflow_trace.js.map +1 -0
- package/dist/plugin-helper.d.ts +1 -0
- package/dist/plugin-helper.d.ts.map +1 -1
- package/dist/plugin-helper.js +8 -9
- package/dist/plugin-helper.js.map +1 -1
- package/dist/tests/actions.test.js +5 -2
- package/dist/tests/actions.test.js.map +1 -1
- package/dist/tests/auxtest.test.js +6 -3
- package/dist/tests/auxtest.test.js.map +1 -1
- package/dist/tests/config.test.js +2 -2
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/field.test.js +47 -0
- package/dist/tests/field.test.js.map +1 -1
- package/dist/tests/mocks.d.ts +1 -1
- package/dist/tests/mocks.js +1 -1
- package/dist/tests/mocks.js.map +1 -1
- package/dist/tests/workflow.test.js +9 -0
- package/dist/tests/workflow.test.js.map +1 -1
- package/dist/tests/workflow_run.test.d.ts +2 -0
- package/dist/tests/workflow_run.test.d.ts.map +1 -0
- package/dist/tests/workflow_run.test.js +109 -0
- package/dist/tests/workflow_run.test.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +15 -0
- package/dist/utils.js.map +1 -1
- package/package.json +10 -9
|
@@ -143,6 +143,7 @@ module.exports = {
|
|
|
143
143
|
blocks: {
|
|
144
144
|
disableInBuilder: true,
|
|
145
145
|
disableInList: true,
|
|
146
|
+
disableInWorkflow: true,
|
|
146
147
|
description: "Build action with drag and drop steps similar to Scratch",
|
|
147
148
|
configFields: [
|
|
148
149
|
{
|
|
@@ -212,34 +213,114 @@ module.exports = {
|
|
|
212
213
|
*/
|
|
213
214
|
webhook: {
|
|
214
215
|
description: "Make an outbound HTTP POST request",
|
|
215
|
-
configFields:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
216
|
+
configFields: async ({ table, mode }) => {
|
|
217
|
+
let field_opts = [];
|
|
218
|
+
if (table) {
|
|
219
|
+
field_opts = table.fields
|
|
220
|
+
.filter((f) => f.type && ["String", "HTML", "JSON"].includes(f.type.name))
|
|
221
|
+
.map((f) => f.name);
|
|
222
|
+
}
|
|
223
|
+
return [
|
|
224
|
+
{
|
|
225
|
+
name: "url",
|
|
226
|
+
label: "URL",
|
|
227
|
+
type: "String",
|
|
228
|
+
sublabel: "Trigger will call specified URL",
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
name: "method",
|
|
232
|
+
label: "HTTP Method",
|
|
233
|
+
type: "String",
|
|
234
|
+
required: true,
|
|
235
|
+
attributes: { options: "POST,GET,PUT,DELETE,PATCH" },
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: "body",
|
|
239
|
+
label: "JSON body",
|
|
240
|
+
sublabel: "Leave blank to use row from table",
|
|
241
|
+
type: "String",
|
|
242
|
+
fieldview: "textarea",
|
|
243
|
+
showIf: { method: ["POST", "PUT", "DELETE", "PATCH"] },
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
name: "authorization",
|
|
247
|
+
label: "Authorization header",
|
|
248
|
+
type: "String",
|
|
249
|
+
sublabel: "For example <code>Bearer xxxx</code>",
|
|
250
|
+
},
|
|
251
|
+
...(field_opts.length
|
|
252
|
+
? [
|
|
253
|
+
{
|
|
254
|
+
name: "response_field",
|
|
255
|
+
label: "Response into field",
|
|
256
|
+
type: "String",
|
|
257
|
+
attributes: { options: field_opts },
|
|
258
|
+
},
|
|
259
|
+
]
|
|
260
|
+
: []),
|
|
261
|
+
...(mode === "workflow"
|
|
262
|
+
? [
|
|
263
|
+
{
|
|
264
|
+
name: "response_var",
|
|
265
|
+
label: "Response variable",
|
|
266
|
+
sublabel: "Variable in the context to fill with the response",
|
|
267
|
+
type: "String",
|
|
268
|
+
},
|
|
269
|
+
]
|
|
270
|
+
: []),
|
|
271
|
+
];
|
|
272
|
+
},
|
|
230
273
|
/**
|
|
231
274
|
* @param {object} opts
|
|
232
275
|
* @param {string} opts.url
|
|
233
276
|
* @param {object} opts.body
|
|
234
277
|
* @returns {Promise<object>}
|
|
235
278
|
*/
|
|
236
|
-
run: async ({ row, user, configuration: { url, body } }) => {
|
|
279
|
+
run: async ({ row, user, table, configuration: { url, body, authorization, response_field, response_var, method, }, }) => {
|
|
237
280
|
let url1 = interpolate(url, row, user);
|
|
238
|
-
|
|
239
|
-
method: "post",
|
|
240
|
-
body: body || JSON.stringify(row),
|
|
281
|
+
const fetchOpts = {
|
|
282
|
+
method: (method || "post").toLowerCase(),
|
|
241
283
|
headers: { "Content-Type": "application/json" },
|
|
242
|
-
}
|
|
284
|
+
};
|
|
285
|
+
if (method !== "GET") {
|
|
286
|
+
let postBody;
|
|
287
|
+
if (body && table) {
|
|
288
|
+
const f = get_async_expression_function(body, table.fields, {
|
|
289
|
+
row: row || {},
|
|
290
|
+
user,
|
|
291
|
+
});
|
|
292
|
+
postBody = JSON.stringify(await f(row, user));
|
|
293
|
+
}
|
|
294
|
+
else if (body)
|
|
295
|
+
postBody = body;
|
|
296
|
+
else
|
|
297
|
+
postBody = JSON.stringify(row);
|
|
298
|
+
fetchOpts.body = postBody;
|
|
299
|
+
}
|
|
300
|
+
if (authorization)
|
|
301
|
+
fetchOpts.headers.Authorization = interpolate(authorization, row, user);
|
|
302
|
+
const response = await fetch(url1, fetchOpts);
|
|
303
|
+
const contentType = response.headers.get("content-type");
|
|
304
|
+
const isJSON = contentType && contentType.indexOf("application/json") !== -1;
|
|
305
|
+
if (response_var) {
|
|
306
|
+
const parsedResponse = isJSON
|
|
307
|
+
? await response.json()
|
|
308
|
+
: await response.text();
|
|
309
|
+
return { [response_var]: parsedResponse };
|
|
310
|
+
}
|
|
311
|
+
else if (table && row && response_field) {
|
|
312
|
+
const field = table.getField(response_field);
|
|
313
|
+
const parsedResponse = isJSON
|
|
314
|
+
? await response.json()
|
|
315
|
+
: await response.text();
|
|
316
|
+
const saveResponse = isJSON &&
|
|
317
|
+
(field?.type?.name === "String" || field?.type?.sql_name === "text")
|
|
318
|
+
? JSON.stringify(parsedResponse)
|
|
319
|
+
: parsedResponse;
|
|
320
|
+
await table.updateRow({ [response_field]: saveResponse }, row[table.pk_name]);
|
|
321
|
+
}
|
|
322
|
+
else
|
|
323
|
+
return;
|
|
243
324
|
},
|
|
244
325
|
},
|
|
245
326
|
/**
|
|
@@ -317,7 +398,50 @@ module.exports = {
|
|
|
317
398
|
* @returns {Promise<object[]>}
|
|
318
399
|
*/
|
|
319
400
|
description: "Send an email, based on a chosen view for this table",
|
|
320
|
-
configFields: async ({ table }) => {
|
|
401
|
+
configFields: async ({ table, mode }) => {
|
|
402
|
+
if (mode === "workflow") {
|
|
403
|
+
return [
|
|
404
|
+
{
|
|
405
|
+
name: "to_email",
|
|
406
|
+
label: "To",
|
|
407
|
+
sublabel: "To addresses, comma separated, <code>{{ }}</code> interpolations usable",
|
|
408
|
+
type: "String",
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
name: "cc_email",
|
|
412
|
+
label: "cc",
|
|
413
|
+
sublabel: "cc addresses, comma separated, <code>{{ }}</code> interpolations usable",
|
|
414
|
+
type: "String",
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: "subject",
|
|
418
|
+
label: "Subject",
|
|
419
|
+
sublabel: "Subject of email, <code>{{ }}</code> interpolations usable",
|
|
420
|
+
type: "String",
|
|
421
|
+
required: true,
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
name: "body",
|
|
425
|
+
label: "Body",
|
|
426
|
+
type: "String",
|
|
427
|
+
fieldview: "textarea",
|
|
428
|
+
required: true,
|
|
429
|
+
},
|
|
430
|
+
/* {
|
|
431
|
+
name: "attachment_paths",
|
|
432
|
+
label: "Attachments",
|
|
433
|
+
sublabel:
|
|
434
|
+
"Comma-separated list of files to attach. <code>{{ }}</code> interpolations usable",
|
|
435
|
+
type: "String",
|
|
436
|
+
},*/
|
|
437
|
+
{
|
|
438
|
+
name: "confirm_field",
|
|
439
|
+
label: "Send confirmation variable",
|
|
440
|
+
type: "String",
|
|
441
|
+
sublabel: "Bool variable set in context indicate successful sending of email message",
|
|
442
|
+
},
|
|
443
|
+
];
|
|
444
|
+
}
|
|
321
445
|
if (!table)
|
|
322
446
|
return [];
|
|
323
447
|
const views = await View.find_table_views_where(table, ({ viewtemplate }) => viewtemplate?.runMany || viewtemplate?.renderRows);
|
|
@@ -448,7 +572,24 @@ module.exports = {
|
|
|
448
572
|
* @param {object} opts.user
|
|
449
573
|
* @returns {Promise<object>}
|
|
450
574
|
*/
|
|
451
|
-
run: async ({ row, table, configuration: { body_type, body_field, viewname, subject, subject_formula, to_email, to_email_field, to_email_fixed, cc_email, only_if, attachment_path, disable_notify, confirm_field, }, user, }) => {
|
|
575
|
+
run: async ({ row, table, configuration: { body_type, body_field, viewname, subject, subject_formula, to_email, to_email_field, to_email_fixed, cc_email, only_if, attachment_path, disable_notify, confirm_field, body, }, user, mode, }) => {
|
|
576
|
+
const from = getState().getConfig("email_from");
|
|
577
|
+
if (mode === "workflow") {
|
|
578
|
+
const email = {
|
|
579
|
+
from,
|
|
580
|
+
to: interpolate(to_email, row, user),
|
|
581
|
+
cc: interpolate(cc_email, row, user),
|
|
582
|
+
subject: interpolate(subject, row, user),
|
|
583
|
+
html: interpolate(body, row, user),
|
|
584
|
+
// attachments,
|
|
585
|
+
};
|
|
586
|
+
const sendres = await getMailTransport().sendMail(email);
|
|
587
|
+
getState().log(5, `send_email result: ${JSON.stringify(sendres)}`);
|
|
588
|
+
if (confirm_field)
|
|
589
|
+
return { [confirm_field]: sendres.accepted.length > 0 };
|
|
590
|
+
else
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
452
593
|
let to_addr;
|
|
453
594
|
let useRow = row;
|
|
454
595
|
const fvs = [
|
|
@@ -510,7 +651,6 @@ module.exports = {
|
|
|
510
651
|
const view = await View.findOne({ name: viewname });
|
|
511
652
|
setBody.html = await viewToEmailHtml(view, { id: row[table.pk_name] });
|
|
512
653
|
}
|
|
513
|
-
const from = getState().getConfig("email_from");
|
|
514
654
|
const attachments = await loadAttachments(attachment_path, row, user ? user : { role_id: 100 });
|
|
515
655
|
const the_subject = subject_formula
|
|
516
656
|
? eval_expression(subject, useRow, user, "send_email subject formula")
|
|
@@ -577,6 +717,7 @@ module.exports = {
|
|
|
577
717
|
},
|
|
578
718
|
];
|
|
579
719
|
},
|
|
720
|
+
disableInWorkflow: true,
|
|
580
721
|
requireRow: true,
|
|
581
722
|
/**
|
|
582
723
|
* @param {object} opts
|
|
@@ -617,6 +758,7 @@ module.exports = {
|
|
|
617
758
|
*/
|
|
618
759
|
description: "Duplicate the current row",
|
|
619
760
|
configFields: () => [],
|
|
761
|
+
disableInWorkflow: true,
|
|
620
762
|
requireRow: true,
|
|
621
763
|
/**
|
|
622
764
|
* @param {object} opts
|
|
@@ -709,7 +851,7 @@ module.exports = {
|
|
|
709
851
|
* @returns {Promise<object[]>}
|
|
710
852
|
*/
|
|
711
853
|
description: "insert a row into any table, using a formula expression",
|
|
712
|
-
configFields: async ({
|
|
854
|
+
configFields: async ({ mode }) => {
|
|
713
855
|
const tables = await Table.find({}, { cached: true });
|
|
714
856
|
return [
|
|
715
857
|
{
|
|
@@ -726,6 +868,16 @@ module.exports = {
|
|
|
726
868
|
type: "String",
|
|
727
869
|
fieldview: "textarea",
|
|
728
870
|
},
|
|
871
|
+
...(mode === "workflow"
|
|
872
|
+
? [
|
|
873
|
+
{
|
|
874
|
+
name: "id_variable",
|
|
875
|
+
label: "ID variable",
|
|
876
|
+
sublabel: "Variable in the context to fill with the created ID value",
|
|
877
|
+
type: "String",
|
|
878
|
+
},
|
|
879
|
+
]
|
|
880
|
+
: []),
|
|
729
881
|
];
|
|
730
882
|
},
|
|
731
883
|
/**
|
|
@@ -739,7 +891,7 @@ module.exports = {
|
|
|
739
891
|
*/
|
|
740
892
|
run: async ({ row, table, configuration, user, referrer, ...rest }) => {
|
|
741
893
|
const state = urlStringToObject(referrer);
|
|
742
|
-
const f = get_async_expression_function(configuration.row_expr, table?.fields ||
|
|
894
|
+
const f = get_async_expression_function(configuration.row_expr, table?.fields || Object.keys(row).map((k) => ({ name: k })), {
|
|
743
895
|
user,
|
|
744
896
|
console,
|
|
745
897
|
session_id: rest.req && getSessionId(rest.req),
|
|
@@ -750,6 +902,8 @@ module.exports = {
|
|
|
750
902
|
const res = await table_for_insert.tryInsertRow(calcrow, user);
|
|
751
903
|
if (res.error)
|
|
752
904
|
return res;
|
|
905
|
+
else if (configuration.id_variable)
|
|
906
|
+
return { [configuration.id_variable]: res.success };
|
|
753
907
|
else
|
|
754
908
|
return true;
|
|
755
909
|
},
|
|
@@ -761,11 +915,6 @@ module.exports = {
|
|
|
761
915
|
* @subcategory actions
|
|
762
916
|
*/
|
|
763
917
|
modify_row: {
|
|
764
|
-
/**
|
|
765
|
-
* @param {object} opts
|
|
766
|
-
* @param {*} opts.table
|
|
767
|
-
* @returns {Promise<object[]>}
|
|
768
|
-
*/
|
|
769
918
|
description: "Modify the triggering row",
|
|
770
919
|
configFields: async ({ mode, when_trigger }) => {
|
|
771
920
|
return [
|
|
@@ -776,7 +925,10 @@ module.exports = {
|
|
|
776
925
|
input_type: "code",
|
|
777
926
|
attributes: { mode: "application/javascript" },
|
|
778
927
|
},
|
|
779
|
-
...(mode === "edit" ||
|
|
928
|
+
...(mode === "edit" ||
|
|
929
|
+
mode === "filter" ||
|
|
930
|
+
when_trigger === "Validate" ||
|
|
931
|
+
mode === "workflow"
|
|
780
932
|
? [
|
|
781
933
|
{
|
|
782
934
|
name: "where",
|
|
@@ -788,22 +940,59 @@ module.exports = {
|
|
|
788
940
|
? ["Row"]
|
|
789
941
|
: mode === "filter"
|
|
790
942
|
? ["Filter state"]
|
|
791
|
-
:
|
|
943
|
+
: mode === "workflow"
|
|
944
|
+
? ["Database", "Active edit view"]
|
|
945
|
+
: ["Form", "Database"],
|
|
792
946
|
},
|
|
793
947
|
},
|
|
794
948
|
]
|
|
795
949
|
: []),
|
|
950
|
+
...(mode === "workflow"
|
|
951
|
+
? [
|
|
952
|
+
{
|
|
953
|
+
name: "select_table",
|
|
954
|
+
label: "Table",
|
|
955
|
+
type: "String",
|
|
956
|
+
required: true,
|
|
957
|
+
attributes: {
|
|
958
|
+
options: (await Table.find()).map((t) => t.name),
|
|
959
|
+
showIf: { where: "Database" },
|
|
960
|
+
},
|
|
961
|
+
},
|
|
962
|
+
{
|
|
963
|
+
name: "query",
|
|
964
|
+
label: "Query object",
|
|
965
|
+
type: "String",
|
|
966
|
+
required: true,
|
|
967
|
+
showIf: { where: "Database" },
|
|
968
|
+
},
|
|
969
|
+
]
|
|
970
|
+
: []),
|
|
796
971
|
];
|
|
797
972
|
},
|
|
798
973
|
requireRow: true,
|
|
799
|
-
run: async ({ row, table, configuration: { row_expr, where }, user, ...rest }) => {
|
|
800
|
-
const f = get_async_expression_function(row_expr, table.
|
|
974
|
+
run: async ({ row, table, configuration: { row_expr, where, select_table, query }, user, ...rest }) => {
|
|
975
|
+
const f = get_async_expression_function(row_expr, table?.fields || Object.keys(row).map((k) => ({ name: k })), {
|
|
801
976
|
row: row || {},
|
|
802
977
|
user,
|
|
803
978
|
});
|
|
804
979
|
const calcrow = await f(row, user);
|
|
805
|
-
if (where === "Form" ||
|
|
980
|
+
if (where === "Form" ||
|
|
981
|
+
where === "Filter state" ||
|
|
982
|
+
where === "Row" ||
|
|
983
|
+
where === "Active edit view")
|
|
806
984
|
return { set_fields: calcrow };
|
|
985
|
+
if (select_table && query) {
|
|
986
|
+
//get table
|
|
987
|
+
const table = Table.findOne(select_table);
|
|
988
|
+
// evaluate query
|
|
989
|
+
const q = eval_expression(query, row, user, "Query expression in modify_row step");
|
|
990
|
+
const rows = await table.getRows(q);
|
|
991
|
+
for (const row of rows) {
|
|
992
|
+
await table.updateRow(calcrow, row[table.pk_name]);
|
|
993
|
+
}
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
807
996
|
const res = await table.tryUpdateRow(calcrow, row[table.pk_name], user);
|
|
808
997
|
if (res.error)
|
|
809
998
|
return res;
|
|
@@ -822,11 +1011,15 @@ module.exports = {
|
|
|
822
1011
|
configFields: async ({ mode, when_trigger }) => {
|
|
823
1012
|
const tables = await Table.find({}, { cached: true });
|
|
824
1013
|
return [
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
1014
|
+
...(mode === "workflow"
|
|
1015
|
+
? []
|
|
1016
|
+
: [
|
|
1017
|
+
{
|
|
1018
|
+
name: "delete_triggering_row",
|
|
1019
|
+
label: "Delete triggering row",
|
|
1020
|
+
type: "Bool",
|
|
1021
|
+
},
|
|
1022
|
+
]),
|
|
830
1023
|
{
|
|
831
1024
|
name: "table_name",
|
|
832
1025
|
label: "Table",
|
|
@@ -905,7 +1098,11 @@ module.exports = {
|
|
|
905
1098
|
case "Popup modal":
|
|
906
1099
|
return { popup: url1 };
|
|
907
1100
|
case "Back":
|
|
908
|
-
return {
|
|
1101
|
+
return {
|
|
1102
|
+
eval_js: isWeb(req)
|
|
1103
|
+
? "history.back()"
|
|
1104
|
+
: "parent.saltcorn.mobileApp.navigation.goBack()",
|
|
1105
|
+
};
|
|
909
1106
|
case "Close tab":
|
|
910
1107
|
return { eval_js: "window.close()" };
|
|
911
1108
|
case "Close modal":
|
|
@@ -925,6 +1122,7 @@ module.exports = {
|
|
|
925
1122
|
* @returns {Promise<object[]>}
|
|
926
1123
|
*/
|
|
927
1124
|
description: "Step control flow",
|
|
1125
|
+
disableInWorkflow: true,
|
|
928
1126
|
configFields: [
|
|
929
1127
|
{
|
|
930
1128
|
name: "control_action",
|
|
@@ -1115,6 +1313,7 @@ module.exports = {
|
|
|
1115
1313
|
topic: "JavaScript action code",
|
|
1116
1314
|
},
|
|
1117
1315
|
showIf: { run_where: "Server" },
|
|
1316
|
+
attributes: { secondColHoriz: true },
|
|
1118
1317
|
},
|
|
1119
1318
|
{
|
|
1120
1319
|
input_type: "section_header",
|
|
@@ -1124,6 +1323,7 @@ module.exports = {
|
|
|
1124
1323
|
topic: "JavaScript action code",
|
|
1125
1324
|
},
|
|
1126
1325
|
showIf: { run_where: "Client page" },
|
|
1326
|
+
attributes: { secondColHoriz: true },
|
|
1127
1327
|
},
|
|
1128
1328
|
{
|
|
1129
1329
|
name: "run_where",
|
|
@@ -1147,7 +1347,23 @@ module.exports = {
|
|
|
1147
1347
|
* @returns {Promise<object[]>}
|
|
1148
1348
|
*/
|
|
1149
1349
|
description: "Run arbitrary JavaScript code from a String field",
|
|
1150
|
-
configFields: async ({ table }) => {
|
|
1350
|
+
configFields: async ({ table, mode }) => {
|
|
1351
|
+
if (mode === "workflow")
|
|
1352
|
+
return [
|
|
1353
|
+
{
|
|
1354
|
+
name: "code_field",
|
|
1355
|
+
label: "Code field",
|
|
1356
|
+
sublabel: "String variable in context contains the JavaScript code to run",
|
|
1357
|
+
type: "String",
|
|
1358
|
+
required: true,
|
|
1359
|
+
},
|
|
1360
|
+
{
|
|
1361
|
+
name: "run_where",
|
|
1362
|
+
label: "Run where",
|
|
1363
|
+
input_type: "select",
|
|
1364
|
+
options: ["Server", "Client page"],
|
|
1365
|
+
},
|
|
1366
|
+
];
|
|
1151
1367
|
const field_opts = table.fields
|
|
1152
1368
|
.filter((f) => f.type?.name === "String")
|
|
1153
1369
|
.map((f) => f.name);
|
|
@@ -1185,7 +1401,7 @@ module.exports = {
|
|
|
1185
1401
|
* @type {base-plugin/actions~run_code}
|
|
1186
1402
|
* @see base-plugin/actions~run_code
|
|
1187
1403
|
**/
|
|
1188
|
-
run: async ({ table, configuration: { code_field, run_where }, row, ...rest }) => {
|
|
1404
|
+
run: async ({ table, configuration: { code_field, run_where }, row, mode, ...rest }) => {
|
|
1189
1405
|
let code;
|
|
1190
1406
|
if (code_field.includes(".")) {
|
|
1191
1407
|
const [ref, target] = code_field.split(".");
|
|
@@ -1232,6 +1448,7 @@ module.exports = {
|
|
|
1232
1448
|
...fldOpts,
|
|
1233
1449
|
];
|
|
1234
1450
|
},
|
|
1451
|
+
disableInWorkflow: true,
|
|
1235
1452
|
requireRow: true,
|
|
1236
1453
|
run: async ({ row, table, configuration: { viewname, ...flds }, user }) => {
|
|
1237
1454
|
const qs = Object.entries(flds)
|
|
@@ -1310,14 +1527,18 @@ module.exports = {
|
|
|
1310
1527
|
label: "Source table",
|
|
1311
1528
|
sublabel: "External table to sync from",
|
|
1312
1529
|
input_type: "select",
|
|
1313
|
-
options: tables
|
|
1530
|
+
options: tables
|
|
1531
|
+
.filter((t) => t.external || t.provider_name)
|
|
1532
|
+
.map((t) => t.name),
|
|
1314
1533
|
},
|
|
1315
1534
|
{
|
|
1316
1535
|
name: "table_dest",
|
|
1317
1536
|
label: "Destination table",
|
|
1318
1537
|
sublabel: "Table to sync to",
|
|
1319
1538
|
input_type: "select",
|
|
1320
|
-
options: tables
|
|
1539
|
+
options: tables
|
|
1540
|
+
.filter((t) => !(t.external || t.provider_name))
|
|
1541
|
+
.map((t) => t.name),
|
|
1321
1542
|
},
|
|
1322
1543
|
{
|
|
1323
1544
|
name: "pk_field",
|