@saltcorn/data 0.9.4-beta.1 → 0.9.4-beta.11
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 +109 -30
- package/dist/base-plugin/actions.d.ts.map +1 -1
- package/dist/base-plugin/actions.js +78 -21
- package/dist/base-plugin/actions.js.map +1 -1
- package/dist/base-plugin/fieldviews.d.ts.map +1 -1
- package/dist/base-plugin/fieldviews.js +18 -9
- package/dist/base-plugin/fieldviews.js.map +1 -1
- package/dist/base-plugin/index.d.ts +412 -410
- 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 +8 -2
- package/dist/base-plugin/types.js.map +1 -1
- package/dist/base-plugin/viewtemplates/edit.d.ts +2 -0
- package/dist/base-plugin/viewtemplates/edit.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/edit.js +148 -51
- package/dist/base-plugin/viewtemplates/edit.js.map +1 -1
- package/dist/base-plugin/viewtemplates/filter.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/filter.js +26 -5
- package/dist/base-plugin/viewtemplates/filter.js.map +1 -1
- package/dist/base-plugin/viewtemplates/list.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/list.js +4 -4
- package/dist/base-plugin/viewtemplates/list.js.map +1 -1
- package/dist/base-plugin/viewtemplates/show.d.ts +2 -0
- package/dist/base-plugin/viewtemplates/show.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/show.js +110 -56
- package/dist/base-plugin/viewtemplates/show.js.map +1 -1
- package/dist/base-plugin/viewtemplates/viewable_fields.d.ts +2 -2
- package/dist/base-plugin/viewtemplates/viewable_fields.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/viewable_fields.js +27 -35
- package/dist/base-plugin/viewtemplates/viewable_fields.js.map +1 -1
- package/dist/db/fixtures.d.ts.map +1 -1
- package/dist/db/fixtures.js +149 -30
- package/dist/db/fixtures.js.map +1 -1
- package/dist/db/state.d.ts.map +1 -1
- package/dist/db/state.js +2 -0
- package/dist/db/state.js.map +1 -1
- package/dist/migrate.d.ts +1 -0
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +6 -3
- package/dist/migrate.js.map +1 -1
- package/dist/migrations/202402071125.d.ts +2 -0
- package/dist/migrations/202402071125.d.ts.map +1 -0
- package/dist/migrations/202402071125.js +4 -0
- package/dist/migrations/202402071125.js.map +1 -0
- package/dist/models/config.d.ts.map +1 -1
- package/dist/models/config.js +6 -0
- package/dist/models/config.js.map +1 -1
- package/dist/models/expression.d.ts +2 -0
- package/dist/models/expression.d.ts.map +1 -1
- package/dist/models/expression.js +9 -0
- package/dist/models/expression.js.map +1 -1
- package/dist/models/field.d.ts +1 -1
- package/dist/models/field.d.ts.map +1 -1
- package/dist/models/field.js +2 -2
- package/dist/models/field.js.map +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/models/page_group.d.ts +1 -0
- package/dist/models/page_group.d.ts.map +1 -1
- package/dist/models/page_group.js +1 -0
- package/dist/models/page_group.js.map +1 -1
- package/dist/models/view.d.ts +6 -0
- package/dist/models/view.d.ts.map +1 -1
- package/dist/models/view.js +10 -0
- package/dist/models/view.js.map +1 -1
- package/dist/plugin-helper.d.ts +8 -19
- package/dist/plugin-helper.d.ts.map +1 -1
- package/dist/plugin-helper.js +55 -60
- package/dist/plugin-helper.js.map +1 -1
- package/dist/tests/auxtest.test.js +4 -0
- package/dist/tests/auxtest.test.js.map +1 -1
- package/dist/tests/calc.test.js +11 -1
- package/dist/tests/calc.test.js.map +1 -1
- package/dist/tests/edit.test.js +204 -0
- package/dist/tests/edit.test.js.map +1 -1
- package/dist/tests/show.test.d.ts +2 -0
- package/dist/tests/show.test.d.ts.map +1 -0
- package/dist/tests/show.test.js +325 -0
- package/dist/tests/show.test.js.map +1 -0
- package/dist/tests/view.test.js +15 -1
- package/dist/tests/view.test.js.map +1 -1
- package/dist/utils.d.ts +2 -17
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +15 -32
- package/dist/utils.js.map +1 -1
- package/package.json +8 -7
|
@@ -38,6 +38,11 @@ export namespace emit_event {
|
|
|
38
38
|
required: boolean;
|
|
39
39
|
input_type: string;
|
|
40
40
|
options: string[];
|
|
41
|
+
/**
|
|
42
|
+
* @param {object} opts
|
|
43
|
+
* @param {*} opts.table
|
|
44
|
+
* @returns {Promise<object[]>}
|
|
45
|
+
*/
|
|
41
46
|
type?: undefined;
|
|
42
47
|
fieldview?: undefined;
|
|
43
48
|
sublabel?: undefined;
|
|
@@ -84,7 +89,7 @@ export namespace webhook {
|
|
|
84
89
|
fieldview: string;
|
|
85
90
|
})[];
|
|
86
91
|
export { configFields_2 as configFields };
|
|
87
|
-
export function run_1({ row, configuration: { url, body } }: {
|
|
92
|
+
export function run_1({ row, user, configuration: { url, body } }: {
|
|
88
93
|
url: string;
|
|
89
94
|
body: object;
|
|
90
95
|
}): Promise<object>;
|
|
@@ -155,6 +160,11 @@ export namespace send_email {
|
|
|
155
160
|
body_type: string;
|
|
156
161
|
to_email?: undefined;
|
|
157
162
|
};
|
|
163
|
+
/**
|
|
164
|
+
* @param {object} opts
|
|
165
|
+
* @param {*} opts.table
|
|
166
|
+
* @returns {Promise<object[]>}
|
|
167
|
+
*/
|
|
158
168
|
type?: undefined;
|
|
159
169
|
required?: undefined;
|
|
160
170
|
attributes?: undefined;
|
|
@@ -167,6 +177,11 @@ export namespace send_email {
|
|
|
167
177
|
input_type: string;
|
|
168
178
|
required: boolean;
|
|
169
179
|
options: string[];
|
|
180
|
+
/**
|
|
181
|
+
* @param {object} opts
|
|
182
|
+
* @param {*} opts.table
|
|
183
|
+
* @returns {Promise<object[]>}
|
|
184
|
+
*/
|
|
170
185
|
type?: undefined;
|
|
171
186
|
attributes?: undefined;
|
|
172
187
|
showIf?: undefined;
|
|
@@ -182,6 +197,11 @@ export namespace send_email {
|
|
|
182
197
|
to_email: string;
|
|
183
198
|
body_type?: undefined;
|
|
184
199
|
};
|
|
200
|
+
/**
|
|
201
|
+
* @param {object} opts
|
|
202
|
+
* @param {*} opts.table
|
|
203
|
+
* @returns {Promise<object[]>}
|
|
204
|
+
*/
|
|
185
205
|
type?: undefined;
|
|
186
206
|
required?: undefined;
|
|
187
207
|
attributes?: undefined;
|
|
@@ -207,49 +227,49 @@ export namespace send_email {
|
|
|
207
227
|
label: string;
|
|
208
228
|
sublabel: string;
|
|
209
229
|
type: string;
|
|
210
|
-
|
|
211
|
-
required: boolean;
|
|
230
|
+
required?: undefined;
|
|
212
231
|
attributes?: undefined;
|
|
213
232
|
showIf?: undefined;
|
|
214
233
|
input_type?: undefined;
|
|
215
234
|
options?: undefined;
|
|
235
|
+
class?: undefined;
|
|
216
236
|
default?: undefined;
|
|
217
237
|
} | {
|
|
218
238
|
name: string;
|
|
219
239
|
label: string;
|
|
240
|
+
sublabel: string;
|
|
220
241
|
type: string;
|
|
242
|
+
class: string;
|
|
221
243
|
required: boolean;
|
|
222
244
|
attributes?: undefined;
|
|
223
245
|
showIf?: undefined;
|
|
224
|
-
sublabel?: undefined;
|
|
225
246
|
input_type?: undefined;
|
|
226
247
|
options?: undefined;
|
|
227
|
-
class?: undefined;
|
|
228
248
|
default?: undefined;
|
|
229
249
|
} | {
|
|
230
250
|
name: string;
|
|
231
251
|
label: string;
|
|
232
|
-
sublabel: string;
|
|
233
|
-
input_type: string;
|
|
234
|
-
options: string[];
|
|
235
252
|
type: string;
|
|
236
|
-
|
|
237
|
-
required?: undefined;
|
|
253
|
+
required: boolean;
|
|
238
254
|
attributes?: undefined;
|
|
239
255
|
showIf?: undefined;
|
|
256
|
+
sublabel?: undefined;
|
|
257
|
+
input_type?: undefined;
|
|
258
|
+
options?: undefined;
|
|
240
259
|
class?: undefined;
|
|
260
|
+
default?: undefined;
|
|
241
261
|
} | {
|
|
242
262
|
name: string;
|
|
243
263
|
label: string;
|
|
244
264
|
sublabel: string;
|
|
265
|
+
input_type: string;
|
|
266
|
+
options: string[];
|
|
245
267
|
type: string;
|
|
268
|
+
default: string;
|
|
246
269
|
required?: undefined;
|
|
247
270
|
attributes?: undefined;
|
|
248
271
|
showIf?: undefined;
|
|
249
|
-
input_type?: undefined;
|
|
250
|
-
options?: undefined;
|
|
251
272
|
class?: undefined;
|
|
252
|
-
default?: undefined;
|
|
253
273
|
} | {
|
|
254
274
|
name: string;
|
|
255
275
|
label: string;
|
|
@@ -279,7 +299,7 @@ export namespace send_email {
|
|
|
279
299
|
})[]>;
|
|
280
300
|
export { configFields_4 as configFields };
|
|
281
301
|
export const requireRow: boolean;
|
|
282
|
-
export function run_3({ row, table, configuration: { body_type, body_field, viewname, subject, subject_formula, to_email, to_email_field, to_email_fixed, only_if, attachment_path, disable_notify, confirm_field, }, user, }: {
|
|
302
|
+
export function run_3({ 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, }: {
|
|
283
303
|
row: object;
|
|
284
304
|
table: object;
|
|
285
305
|
configuration: object;
|
|
@@ -335,6 +355,11 @@ export namespace recalculate_stored_fields {
|
|
|
335
355
|
sublabel: string;
|
|
336
356
|
input_type: string;
|
|
337
357
|
options: string[];
|
|
358
|
+
/**
|
|
359
|
+
* @param {object} opts
|
|
360
|
+
* @param {*} opts.table
|
|
361
|
+
* @returns {Promise<object[]>}
|
|
362
|
+
*/
|
|
338
363
|
type?: undefined;
|
|
339
364
|
showIf?: undefined;
|
|
340
365
|
} | {
|
|
@@ -367,6 +392,11 @@ export namespace insert_any_row {
|
|
|
367
392
|
sublabel: string;
|
|
368
393
|
input_type: string;
|
|
369
394
|
options: string[];
|
|
395
|
+
/**
|
|
396
|
+
* @param {object} opts
|
|
397
|
+
* @param {*} opts.table
|
|
398
|
+
* @returns {Promise<object[]>}
|
|
399
|
+
*/
|
|
370
400
|
type?: undefined;
|
|
371
401
|
fieldview?: undefined;
|
|
372
402
|
} | {
|
|
@@ -402,6 +432,11 @@ export namespace modify_row {
|
|
|
402
432
|
mode: string;
|
|
403
433
|
options?: undefined;
|
|
404
434
|
};
|
|
435
|
+
/**
|
|
436
|
+
* @param {object} opts
|
|
437
|
+
* @param {*} opts.table
|
|
438
|
+
* @returns {Promise<object[]>}
|
|
439
|
+
*/
|
|
405
440
|
type?: undefined;
|
|
406
441
|
required?: undefined;
|
|
407
442
|
} | {
|
|
@@ -454,7 +489,9 @@ export namespace navigate {
|
|
|
454
489
|
attributes?: undefined;
|
|
455
490
|
})[];
|
|
456
491
|
export { configFields_10 as configFields };
|
|
457
|
-
export function run_9({ configuration: { nav_action, url } }: {
|
|
492
|
+
export function run_9({ row, user, configuration: { nav_action, url } }: {
|
|
493
|
+
row: any;
|
|
494
|
+
user: any;
|
|
458
495
|
configuration: {
|
|
459
496
|
nav_action: any;
|
|
460
497
|
url: any;
|
|
@@ -523,7 +560,9 @@ export namespace toast {
|
|
|
523
560
|
attributes?: undefined;
|
|
524
561
|
})[];
|
|
525
562
|
export { configFields_12 as configFields };
|
|
526
|
-
export function run_11({ configuration: { type, notify_type, text } }: {
|
|
563
|
+
export function run_11({ row, user, configuration: { type, notify_type, text } }: {
|
|
564
|
+
row: any;
|
|
565
|
+
user: any;
|
|
527
566
|
configuration: {
|
|
528
567
|
type: any;
|
|
529
568
|
notify_type: any;
|
|
@@ -650,6 +689,11 @@ export namespace sync_table_from_external {
|
|
|
650
689
|
sublabel: string;
|
|
651
690
|
input_type: string;
|
|
652
691
|
options: string[];
|
|
692
|
+
/**
|
|
693
|
+
* @param {object} opts
|
|
694
|
+
* @param {*} opts.table
|
|
695
|
+
* @returns {Promise<object[]>}
|
|
696
|
+
*/
|
|
653
697
|
type?: undefined;
|
|
654
698
|
required?: undefined;
|
|
655
699
|
attributes?: undefined;
|
|
@@ -709,7 +753,7 @@ export namespace sync_table_from_external {
|
|
|
709
753
|
export namespace reload_embedded_view {
|
|
710
754
|
const description_16: string;
|
|
711
755
|
export { description_16 as description };
|
|
712
|
-
export function configFields_17(): Promise<{
|
|
756
|
+
export function configFields_17(): Promise<({
|
|
713
757
|
name: string;
|
|
714
758
|
label: string;
|
|
715
759
|
type: string;
|
|
@@ -717,21 +761,51 @@ export namespace reload_embedded_view {
|
|
|
717
761
|
attributes: {
|
|
718
762
|
options: any[];
|
|
719
763
|
};
|
|
720
|
-
|
|
764
|
+
class?: undefined;
|
|
765
|
+
} | {
|
|
766
|
+
name: string;
|
|
767
|
+
label: string;
|
|
768
|
+
type: string;
|
|
769
|
+
class: string;
|
|
770
|
+
required?: undefined;
|
|
771
|
+
attributes?: undefined;
|
|
772
|
+
})[]>;
|
|
721
773
|
export { configFields_17 as configFields };
|
|
722
|
-
export function run_15({ configuration: { view } }: {
|
|
774
|
+
export function run_15({ row, user, configuration: { view, new_state_fml } }: {
|
|
775
|
+
row: any;
|
|
776
|
+
user: any;
|
|
723
777
|
configuration: {
|
|
724
778
|
view: any;
|
|
779
|
+
new_state_fml: any;
|
|
725
780
|
};
|
|
726
781
|
}): Promise<{
|
|
727
782
|
eval_js: string;
|
|
728
783
|
}>;
|
|
729
784
|
export { run_15 as run };
|
|
730
785
|
}
|
|
731
|
-
export namespace
|
|
786
|
+
export namespace sleep {
|
|
732
787
|
const description_17: string;
|
|
733
788
|
export { description_17 as description };
|
|
734
|
-
|
|
789
|
+
const configFields_18: {
|
|
790
|
+
name: string;
|
|
791
|
+
label: string;
|
|
792
|
+
type: string;
|
|
793
|
+
required: boolean;
|
|
794
|
+
}[];
|
|
795
|
+
export { configFields_18 as configFields };
|
|
796
|
+
export function run_16({ configuration: { seconds } }: {
|
|
797
|
+
configuration: {
|
|
798
|
+
seconds: any;
|
|
799
|
+
};
|
|
800
|
+
}): Promise<{
|
|
801
|
+
eval_js: string;
|
|
802
|
+
}>;
|
|
803
|
+
export { run_16 as run };
|
|
804
|
+
}
|
|
805
|
+
export namespace notify_user {
|
|
806
|
+
const description_18: string;
|
|
807
|
+
export { description_18 as description };
|
|
808
|
+
export function configFields_19(): ({
|
|
735
809
|
name: string;
|
|
736
810
|
label: string;
|
|
737
811
|
type: string;
|
|
@@ -742,18 +816,18 @@ export namespace notify_user {
|
|
|
742
816
|
required: boolean;
|
|
743
817
|
type: string;
|
|
744
818
|
})[];
|
|
745
|
-
export {
|
|
746
|
-
export function
|
|
819
|
+
export { configFields_19 as configFields };
|
|
820
|
+
export function run_17({ row, user, configuration: { title, body, link, user_spec }, }: {
|
|
747
821
|
row: object;
|
|
748
822
|
configuration: object;
|
|
749
823
|
user: object;
|
|
750
824
|
}): Promise<void>;
|
|
751
|
-
export {
|
|
825
|
+
export { run_17 as run };
|
|
752
826
|
}
|
|
753
827
|
export namespace convert_session_to_user {
|
|
754
|
-
const
|
|
755
|
-
export {
|
|
756
|
-
export function
|
|
828
|
+
const description_19: string;
|
|
829
|
+
export { description_19 as description };
|
|
830
|
+
export function configFields_20({ table }: {
|
|
757
831
|
table: any;
|
|
758
832
|
}): Promise<({
|
|
759
833
|
name: string;
|
|
@@ -761,6 +835,11 @@ export namespace convert_session_to_user {
|
|
|
761
835
|
sublabel: string;
|
|
762
836
|
input_type: string;
|
|
763
837
|
options: string[];
|
|
838
|
+
/**
|
|
839
|
+
* @param {object} opts
|
|
840
|
+
* @param {*} opts.table
|
|
841
|
+
* @returns {Promise<object[]>}
|
|
842
|
+
*/
|
|
764
843
|
type?: undefined;
|
|
765
844
|
attributes?: undefined;
|
|
766
845
|
} | {
|
|
@@ -774,8 +853,8 @@ export namespace convert_session_to_user {
|
|
|
774
853
|
input_type?: undefined;
|
|
775
854
|
options?: undefined;
|
|
776
855
|
})[]>;
|
|
777
|
-
export {
|
|
778
|
-
export function
|
|
856
|
+
export { configFields_20 as configFields };
|
|
857
|
+
export function run_18({ row, configuration: { table_name, session_field, user_field }, user, }: {
|
|
779
858
|
row: any;
|
|
780
859
|
configuration: {
|
|
781
860
|
table_name: any;
|
|
@@ -784,7 +863,7 @@ export namespace convert_session_to_user {
|
|
|
784
863
|
};
|
|
785
864
|
user: any;
|
|
786
865
|
}): Promise<void>;
|
|
787
|
-
export {
|
|
866
|
+
export { run_18 as run };
|
|
788
867
|
}
|
|
789
868
|
export {};
|
|
790
869
|
//# sourceMappingURL=actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../base-plugin/actions.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../base-plugin/actions.js"],"names":[],"mappings":"AAsDA;;;;;;;;;GASG;AACH;;;;;;;;;;iBAyEC;;;;;;;;;;;;;;IAuCiB;;;;;;QA2sBd;;;;WAIG;;;;;;;;;;;;;;;;;;;;;;SA1rBF;;IAQI;;;;sBAWJ;;;;;;;;;;;;;;;;;;;IA+BI;;;wBAQJ;;;;;;IAca;;;;;;SAeb;;IAUI;;;;;wBA0CJ;;;;;;IAea;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA4hBd;;;;WAIG;;;;;;;;;;;;;QAJH;;;;WAIG;;;;;;;;;;;;;;;;QAJH;;;;WAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAjZF;;;IAUI;;;;;wBAoHJ;;;;;;IAea;;;;;;;;SAYb;;;;IAUI;;;;;wBAsBJ;;;;;;IAaa,0CAAQ;;;;IASjB;;;;wBAKJ;;;;;;IAgBa;;;;;;;;QAyKd;;;;WAIG;;;;;;;;;;;;;;;UA5JF;;IAMI;;sBAgBJ;;;;;;IAea;;;;;;;;QAmHd;;;;WAIG;;;;;;;;;;;UApGF;;IAUI;;;;;;kCAiBJ;;;;;;IAca;;;;;;;;;;;QAuDd;;;;WAIG;;;;;;;;;;;;;;UAjCF;;;;IAEI;;;;;;;;;qBAkBJ;;;;;;;;;;;;;;;;;;;;;;;;;;IAuCI;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAkBJ;;;;;;;;;;;;;;;;IAqBI;;;;;;OAcJ;;;;;;;;;;;;;;;;;;;;;;IA2BI;;;;;;;;;;;;;;;;;;;;OAYJ;;;;;;IAea;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+Eb;;;;;IAQa;;uBAsBb;;;;IAEI;;;;;;;;;;OAUJ;;;;;;IASa;;;;;;;;;;;;SAcb;;IACI;;;;;;;;;OAgBJ;;;;;;IAea;;;;;;;;QAzTd;;;;WAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8WF;;IASI;;;;;kCAmFJ;;;;;;IAIa;;;;;;;;;;;;;;;;UAiBb;;IACI;;;;;;;;;OAQJ;;;;;;;;;;;;;IAYI;;;;;;OAMJ;;;;;;IAIa;;;;;;;;;;SAsBb;;IAQI;;;;sBAmBJ;;;;;;IAKa;;;;;;;;QAxjBd;;;;WAIG;;;;;;;;;;;;;UA+lBF;;IACI;;;;;;;;sBAeJ"}
|
|
@@ -18,12 +18,23 @@ const Notification = require("../models/notification");
|
|
|
18
18
|
const { getMailTransport, viewToEmailHtml, loadAttachments, getFileAggregations, mjml2html, } = require("../models/email");
|
|
19
19
|
const { get_async_expression_function, recalculate_for_stored, eval_expression, } = require("../models/expression");
|
|
20
20
|
const { div, code, a, span } = require("@saltcorn/markup/tags");
|
|
21
|
-
const { sleep, getSessionId, urlStringToObject, dollarizeObject, } = require("../utils");
|
|
21
|
+
const { sleep, getSessionId, urlStringToObject, dollarizeObject, objectToQueryString, } = require("../utils");
|
|
22
22
|
const db = require("../db");
|
|
23
23
|
const { isNode } = require("../utils");
|
|
24
24
|
const { available_languages } = require("../models/config");
|
|
25
|
+
const _ = require("underscore");
|
|
25
26
|
//action use cases: field modify, like/rate (insert join), notify, send row to webhook
|
|
26
27
|
// todo add translation
|
|
28
|
+
const interpolate = (s, row, user) => {
|
|
29
|
+
if (s && row) {
|
|
30
|
+
const template = _.template(s, {
|
|
31
|
+
interpolate: /\{\{([^#].+?)\}\}/g,
|
|
32
|
+
});
|
|
33
|
+
return template({ row, user, ...row });
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
return s;
|
|
37
|
+
};
|
|
27
38
|
/**
|
|
28
39
|
* @param opts
|
|
29
40
|
* @param opts.row
|
|
@@ -197,8 +208,9 @@ module.exports = {
|
|
|
197
208
|
* @param {object} opts.body
|
|
198
209
|
* @returns {Promise<object>}
|
|
199
210
|
*/
|
|
200
|
-
run: async ({ row, configuration: { url, body } }) => {
|
|
201
|
-
|
|
211
|
+
run: async ({ row, user, configuration: { url, body } }) => {
|
|
212
|
+
let url1 = interpolate(url, row, user);
|
|
213
|
+
return await fetch(url1, {
|
|
202
214
|
method: "post",
|
|
203
215
|
body: body || JSON.stringify(row),
|
|
204
216
|
headers: { "Content-Type": "application/json" },
|
|
@@ -349,10 +361,16 @@ module.exports = {
|
|
|
349
361
|
{
|
|
350
362
|
name: "to_email_fixed",
|
|
351
363
|
label: "Fixed address",
|
|
352
|
-
sublabel: "
|
|
364
|
+
sublabel: "To addresses, comma separated, <code>{{ }}</code> interpolations usable",
|
|
353
365
|
type: "String",
|
|
354
366
|
showIf: { to_email: "Fixed" },
|
|
355
367
|
},
|
|
368
|
+
{
|
|
369
|
+
name: "cc_email",
|
|
370
|
+
label: "cc address",
|
|
371
|
+
sublabel: "cc addresses, comma separated, <code>{{ }}</code> interpolations usable",
|
|
372
|
+
type: "String",
|
|
373
|
+
},
|
|
356
374
|
{
|
|
357
375
|
name: "subject",
|
|
358
376
|
label: "Subject",
|
|
@@ -404,7 +422,7 @@ module.exports = {
|
|
|
404
422
|
* @param {object} opts.user
|
|
405
423
|
* @returns {Promise<object>}
|
|
406
424
|
*/
|
|
407
|
-
run: async ({ row, table, configuration: { body_type, body_field, viewname, subject, subject_formula, to_email, to_email_field, to_email_fixed, only_if, attachment_path, disable_notify, confirm_field, }, user, }) => {
|
|
425
|
+
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, }) => {
|
|
408
426
|
let to_addr;
|
|
409
427
|
if (only_if) {
|
|
410
428
|
const bres = eval_expression(only_if, row);
|
|
@@ -413,7 +431,7 @@ module.exports = {
|
|
|
413
431
|
}
|
|
414
432
|
switch (to_email) {
|
|
415
433
|
case "Fixed":
|
|
416
|
-
to_addr = to_email_fixed;
|
|
434
|
+
to_addr = interpolate(to_email_fixed, row, user);
|
|
417
435
|
break;
|
|
418
436
|
case "User":
|
|
419
437
|
to_addr = user.email;
|
|
@@ -447,7 +465,7 @@ module.exports = {
|
|
|
447
465
|
}
|
|
448
466
|
else {
|
|
449
467
|
const view = await View.findOne({ name: viewname });
|
|
450
|
-
setBody.html = await viewToEmailHtml(view, { id: row.
|
|
468
|
+
setBody.html = await viewToEmailHtml(view, { id: row[table.pk_name] });
|
|
451
469
|
}
|
|
452
470
|
const from = getState().getConfig("email_from");
|
|
453
471
|
const attachments = await loadAttachments(attachment_path, row, user ? user : { role_id: 100 });
|
|
@@ -455,9 +473,11 @@ module.exports = {
|
|
|
455
473
|
? eval_expression(subject, row)
|
|
456
474
|
: subject;
|
|
457
475
|
getState().log(3, `Sending email from ${from} to ${to_addr} with subject ${the_subject}`);
|
|
476
|
+
const cc = cc_email ? interpolate(cc_email, row, user) : undefined;
|
|
458
477
|
const email = {
|
|
459
478
|
from,
|
|
460
479
|
to: to_addr,
|
|
480
|
+
cc,
|
|
461
481
|
subject: the_subject,
|
|
462
482
|
...setBody,
|
|
463
483
|
attachments,
|
|
@@ -467,9 +487,9 @@ module.exports = {
|
|
|
467
487
|
if (confirm_field && sendres.accepted.includes(to_addr)) {
|
|
468
488
|
const confirm_fld = table.getField(confirm_field);
|
|
469
489
|
if (confirm_fld && confirm_fld.type.name === "Date")
|
|
470
|
-
await table.updateRow({ [confirm_field]: new Date() }, row.
|
|
490
|
+
await table.updateRow({ [confirm_field]: new Date() }, row[table.pk_name]);
|
|
471
491
|
else if (confirm_fld && confirm_fld.type.name === "Bool")
|
|
472
|
-
await table.updateRow({ [confirm_field]: true }, row.
|
|
492
|
+
await table.updateRow({ [confirm_field]: true }, row[table.pk_name]);
|
|
473
493
|
}
|
|
474
494
|
if (disable_notify)
|
|
475
495
|
return;
|
|
@@ -480,7 +500,7 @@ module.exports = {
|
|
|
480
500
|
if (confirm_field) {
|
|
481
501
|
const confirm_fld = table.getField(confirm_field);
|
|
482
502
|
if (confirm_fld && confirm_fld.type.name === "Bool")
|
|
483
|
-
await table.updateRow({ [confirm_field]: false }, row.
|
|
503
|
+
await table.updateRow({ [confirm_field]: false }, row[table.pk_name]);
|
|
484
504
|
throw e;
|
|
485
505
|
}
|
|
486
506
|
}
|
|
@@ -766,12 +786,13 @@ module.exports = {
|
|
|
766
786
|
showIf: { nav_action: ["Go to URL", "Popup modal"] },
|
|
767
787
|
},
|
|
768
788
|
],
|
|
769
|
-
run: async ({ configuration: { nav_action, url } }) => {
|
|
789
|
+
run: async ({ row, user, configuration: { nav_action, url } }) => {
|
|
790
|
+
let url1 = interpolate(url, row, user);
|
|
770
791
|
switch (nav_action) {
|
|
771
792
|
case "Go to URL":
|
|
772
|
-
return { goto:
|
|
793
|
+
return { goto: url1 };
|
|
773
794
|
case "Popup modal":
|
|
774
|
-
return { popup:
|
|
795
|
+
return { popup: url1 };
|
|
775
796
|
case "Back":
|
|
776
797
|
return { eval_js: isNode() ? "history.back()" : "parent.goBack()" };
|
|
777
798
|
case "Close modal":
|
|
@@ -841,15 +862,16 @@ module.exports = {
|
|
|
841
862
|
required: true,
|
|
842
863
|
},
|
|
843
864
|
],
|
|
844
|
-
run: async ({ configuration: { type, notify_type, text } }) => {
|
|
865
|
+
run: async ({ row, user, configuration: { type, notify_type, text } }) => {
|
|
845
866
|
//type is legacy. this name gave react problems
|
|
867
|
+
let text1 = interpolate(text, row, user);
|
|
846
868
|
switch (notify_type || type) {
|
|
847
869
|
case "Error":
|
|
848
|
-
return { error:
|
|
870
|
+
return { error: text1 };
|
|
849
871
|
case "Success":
|
|
850
|
-
return { notify_success:
|
|
872
|
+
return { notify_success: text1 };
|
|
851
873
|
default:
|
|
852
|
-
return { notify:
|
|
874
|
+
return { notify: text1 };
|
|
853
875
|
}
|
|
854
876
|
},
|
|
855
877
|
},
|
|
@@ -1160,10 +1182,40 @@ module.exports = {
|
|
|
1160
1182
|
required: true,
|
|
1161
1183
|
attributes: { options: views.map((v) => v.select_option) },
|
|
1162
1184
|
},
|
|
1185
|
+
{
|
|
1186
|
+
name: "new_state_fml",
|
|
1187
|
+
label: "New state formula",
|
|
1188
|
+
type: "String",
|
|
1189
|
+
class: "validate-expression",
|
|
1190
|
+
},
|
|
1163
1191
|
];
|
|
1164
1192
|
},
|
|
1165
|
-
run: async ({ configuration: { view } }) => {
|
|
1166
|
-
|
|
1193
|
+
run: async ({ row, user, configuration: { view, new_state_fml } }) => {
|
|
1194
|
+
if (new_state_fml) {
|
|
1195
|
+
const new_state = eval_expression(new_state_fml, row || {}, user);
|
|
1196
|
+
const newqs = objectToQueryString(new_state);
|
|
1197
|
+
return {
|
|
1198
|
+
eval_js: `reload_embedded_view('${view}', '${newqs}')`,
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1201
|
+
else
|
|
1202
|
+
return { eval_js: `reload_embedded_view('${view}')` };
|
|
1203
|
+
},
|
|
1204
|
+
},
|
|
1205
|
+
sleep: {
|
|
1206
|
+
description: "Delay for a set number of seconds",
|
|
1207
|
+
configFields: [
|
|
1208
|
+
{
|
|
1209
|
+
name: "seconds",
|
|
1210
|
+
label: "Seconds",
|
|
1211
|
+
type: "Float",
|
|
1212
|
+
required: true,
|
|
1213
|
+
},
|
|
1214
|
+
],
|
|
1215
|
+
run: async ({ configuration: { seconds } }) => {
|
|
1216
|
+
return {
|
|
1217
|
+
eval_js: `return new Promise((resolve) => setTimeout(resolve, ${(seconds || 0) * 1000}));`,
|
|
1218
|
+
};
|
|
1167
1219
|
},
|
|
1168
1220
|
},
|
|
1169
1221
|
notify_user: {
|
|
@@ -1198,7 +1250,7 @@ module.exports = {
|
|
|
1198
1250
|
* @param {object} opts.user
|
|
1199
1251
|
* @returns {Promise<void>}
|
|
1200
1252
|
*/
|
|
1201
|
-
run: async ({ row, configuration: { title, body, link, user_spec } }) => {
|
|
1253
|
+
run: async ({ row, user, configuration: { title, body, link, user_spec }, }) => {
|
|
1202
1254
|
const user_where = User.valid_email(user_spec)
|
|
1203
1255
|
? { email: user_spec }
|
|
1204
1256
|
: user_spec === "*"
|
|
@@ -1206,7 +1258,12 @@ module.exports = {
|
|
|
1206
1258
|
: eval_expression(user_spec, row || {});
|
|
1207
1259
|
const users = await User.find(user_where);
|
|
1208
1260
|
for (const user of users) {
|
|
1209
|
-
await Notification.create({
|
|
1261
|
+
await Notification.create({
|
|
1262
|
+
title: interpolate(title, row, user),
|
|
1263
|
+
body: interpolate(body, row, user),
|
|
1264
|
+
link: interpolate(link, row, user),
|
|
1265
|
+
user_id: user.id,
|
|
1266
|
+
});
|
|
1210
1267
|
}
|
|
1211
1268
|
},
|
|
1212
1269
|
},
|