@saltcorn/data 0.9.4-beta.8 → 0.9.4
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 +137 -71
- package/dist/base-plugin/actions.d.ts.map +1 -1
- package/dist/base-plugin/actions.js +105 -22
- 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 +19 -9
- package/dist/base-plugin/fieldviews.js.map +1 -1
- package/dist/base-plugin/fileviews.d.ts +13 -0
- package/dist/base-plugin/fileviews.js +42 -2
- package/dist/base-plugin/fileviews.js.map +1 -1
- package/dist/base-plugin/index.d.ts +208 -204
- 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 +25 -10
- package/dist/base-plugin/types.js.map +1 -1
- package/dist/base-plugin/viewtemplates/edit.d.ts +4 -1
- package/dist/base-plugin/viewtemplates/edit.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/edit.js +181 -81
- package/dist/base-plugin/viewtemplates/edit.js.map +1 -1
- package/dist/base-plugin/viewtemplates/feed.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/feed.js +4 -1
- package/dist/base-plugin/viewtemplates/feed.js.map +1 -1
- package/dist/base-plugin/viewtemplates/filter.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/filter.js +89 -7
- package/dist/base-plugin/viewtemplates/filter.js.map +1 -1
- package/dist/base-plugin/viewtemplates/list.d.ts +3 -2
- package/dist/base-plugin/viewtemplates/list.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/list.js +274 -38
- package/dist/base-plugin/viewtemplates/list.js.map +1 -1
- package/dist/base-plugin/viewtemplates/show.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/show.js +116 -56
- package/dist/base-plugin/viewtemplates/show.js.map +1 -1
- package/dist/base-plugin/viewtemplates/viewable_fields.d.ts +4 -3
- package/dist/base-plugin/viewtemplates/viewable_fields.d.ts.map +1 -1
- package/dist/base-plugin/viewtemplates/viewable_fields.js +173 -57
- package/dist/base-plugin/viewtemplates/viewable_fields.js.map +1 -1
- package/dist/db/connect.d.ts.map +1 -1
- package/dist/db/connect.js +20 -0
- package/dist/db/connect.js.map +1 -1
- package/dist/db/fixtures.d.ts.map +1 -1
- package/dist/db/fixtures.js +196 -30
- package/dist/db/fixtures.js.map +1 -1
- package/dist/db/state.d.ts +5 -0
- package/dist/db/state.d.ts.map +1 -1
- package/dist/db/state.js +20 -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 +27 -0
- package/dist/models/config.js.map +1 -1
- package/dist/models/email.d.ts.map +1 -1
- package/dist/models/email.js +6 -2
- package/dist/models/email.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 +4 -4
- package/dist/models/field.js.map +1 -1
- package/dist/models/file.d.ts +2 -0
- package/dist/models/file.d.ts.map +1 -1
- package/dist/models/file.js +9 -0
- package/dist/models/file.js.map +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/models/internal/query.d.ts +6 -0
- package/dist/models/internal/query.d.ts.map +1 -0
- package/dist/models/internal/query.js +86 -0
- package/dist/models/internal/query.js.map +1 -0
- package/dist/models/page.d.ts.map +1 -1
- package/dist/models/page.js +4 -0
- package/dist/models/page.js.map +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/table.d.ts +18 -4
- package/dist/models/table.d.ts.map +1 -1
- package/dist/models/table.js +84 -52
- package/dist/models/table.js.map +1 -1
- package/dist/models/tag_entry.d.ts.map +1 -1
- package/dist/models/tag_entry.js +9 -0
- package/dist/models/tag_entry.js.map +1 -1
- package/dist/models/trigger.d.ts +3 -3
- package/dist/models/trigger.d.ts.map +1 -1
- package/dist/models/trigger.js +69 -7
- package/dist/models/trigger.js.map +1 -1
- package/dist/models/user.d.ts.map +1 -1
- package/dist/models/user.js +5 -4
- package/dist/models/user.js.map +1 -1
- package/dist/models/view.d.ts +1 -0
- package/dist/models/view.d.ts.map +1 -1
- package/dist/models/view.js +6 -0
- package/dist/models/view.js.map +1 -1
- package/dist/plugin-helper.d.ts +7 -19
- package/dist/plugin-helper.d.ts.map +1 -1
- package/dist/plugin-helper.js +79 -70
- package/dist/plugin-helper.js.map +1 -1
- package/dist/tests/actions.test.js +143 -2
- package/dist/tests/actions.test.js.map +1 -1
- package/dist/tests/auth.test.js +101 -1
- package/dist/tests/auth.test.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 +20 -0
- package/dist/tests/calc.test.js.map +1 -1
- package/dist/tests/edit.test.js +558 -0
- package/dist/tests/edit.test.js.map +1 -1
- package/dist/tests/filter.test.d.ts +2 -0
- package/dist/tests/filter.test.d.ts.map +1 -0
- package/dist/tests/filter.test.js +438 -0
- package/dist/tests/filter.test.js.map +1 -0
- package/dist/tests/list.test.d.ts +2 -0
- package/dist/tests/list.test.d.ts.map +1 -0
- package/dist/tests/list.test.js +903 -0
- package/dist/tests/list.test.js.map +1 -0
- 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/table.test.js +213 -56
- package/dist/tests/table.test.js.map +1 -1
- package/dist/tests/table_history.test.js +51 -0
- package/dist/tests/table_history.test.js.map +1 -1
- package/dist/tests/tag.test.js +1 -1
- package/dist/tests/tag.test.js.map +1 -1
- package/dist/tests/view.test.js +16 -2
- 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 +19 -32
- package/dist/utils.js.map +1 -1
- package/package.json +8 -7
package/dist/tests/edit.test.js
CHANGED
|
@@ -510,4 +510,562 @@ const mkConfig = (hasSave, onChange) => {
|
|
|
510
510
|
});
|
|
511
511
|
});
|
|
512
512
|
});
|
|
513
|
+
const accordionConfig = {
|
|
514
|
+
name: "authoredit1",
|
|
515
|
+
configuration: {
|
|
516
|
+
layout: {
|
|
517
|
+
type: "tabs",
|
|
518
|
+
ntabs: "2",
|
|
519
|
+
tabId: "",
|
|
520
|
+
showif: [null, "pages<800"],
|
|
521
|
+
titles: ["By {{ author }}", "Publisher Tab title {{ publisher }}"],
|
|
522
|
+
contents: [
|
|
523
|
+
{
|
|
524
|
+
font: "",
|
|
525
|
+
icon: "",
|
|
526
|
+
type: "blank",
|
|
527
|
+
block: false,
|
|
528
|
+
style: {},
|
|
529
|
+
inline: false,
|
|
530
|
+
contents: "Hello 1",
|
|
531
|
+
labelFor: "",
|
|
532
|
+
isFormula: {},
|
|
533
|
+
textStyle: "",
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
above: [
|
|
537
|
+
{
|
|
538
|
+
font: "",
|
|
539
|
+
icon: "",
|
|
540
|
+
type: "blank",
|
|
541
|
+
block: false,
|
|
542
|
+
style: {},
|
|
543
|
+
inline: false,
|
|
544
|
+
contents: "Publisher JF: ",
|
|
545
|
+
labelFor: "",
|
|
546
|
+
isFormula: {},
|
|
547
|
+
textStyle: "",
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
type: "join_field",
|
|
551
|
+
block: false,
|
|
552
|
+
fieldview: "show_with_html",
|
|
553
|
+
textStyle: "",
|
|
554
|
+
join_field: "publisher.name",
|
|
555
|
+
configuration: {
|
|
556
|
+
code: "<span>the publisher {{it}} </span>",
|
|
557
|
+
},
|
|
558
|
+
},
|
|
559
|
+
],
|
|
560
|
+
},
|
|
561
|
+
],
|
|
562
|
+
deeplink: true,
|
|
563
|
+
tabsStyle: "Accordion",
|
|
564
|
+
independent: false,
|
|
565
|
+
startClosed: false,
|
|
566
|
+
serverRendered: false,
|
|
567
|
+
disable_inactive: false,
|
|
568
|
+
},
|
|
569
|
+
columns: [
|
|
570
|
+
{
|
|
571
|
+
type: "JoinField",
|
|
572
|
+
block: false,
|
|
573
|
+
fieldview: "show_with_html",
|
|
574
|
+
textStyle: "",
|
|
575
|
+
join_field: "publisher.name",
|
|
576
|
+
configuration: {
|
|
577
|
+
code: "<span>the publisher {{it}} </span>",
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
],
|
|
581
|
+
},
|
|
582
|
+
};
|
|
583
|
+
const mkViewWithCfg = async (viewCfg) => {
|
|
584
|
+
return await view_1.default.create({
|
|
585
|
+
viewtemplate: "Edit",
|
|
586
|
+
description: "",
|
|
587
|
+
min_role: 1,
|
|
588
|
+
name: `someView${Math.round(Math.random() * 100000)}`,
|
|
589
|
+
table_id: table_1.default.findOne("books")?.id,
|
|
590
|
+
default_render_page: "",
|
|
591
|
+
slug: {
|
|
592
|
+
label: "",
|
|
593
|
+
steps: [],
|
|
594
|
+
},
|
|
595
|
+
attributes: {
|
|
596
|
+
page_title: "",
|
|
597
|
+
popup_title: "",
|
|
598
|
+
popup_width: null,
|
|
599
|
+
popup_link_out: false,
|
|
600
|
+
popup_minwidth: null,
|
|
601
|
+
page_description: "",
|
|
602
|
+
popup_width_units: null,
|
|
603
|
+
popup_minwidth_units: null,
|
|
604
|
+
popup_save_indicator: false,
|
|
605
|
+
},
|
|
606
|
+
...viewCfg,
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
(0, globals_1.describe)("Edit config flow", () => {
|
|
610
|
+
(0, globals_1.it)("should compute for author table", async () => {
|
|
611
|
+
const view = await mkViewWithCfg({
|
|
612
|
+
configuration: {},
|
|
613
|
+
});
|
|
614
|
+
const configFlow = await view.get_config_flow(mockReqRes.req);
|
|
615
|
+
const result = await configFlow.run({
|
|
616
|
+
table_id: view.table_id,
|
|
617
|
+
exttable_name: null,
|
|
618
|
+
viewname: view.name,
|
|
619
|
+
...view.configuration,
|
|
620
|
+
}, mockReqRes.req);
|
|
621
|
+
const fieldNames = result?.renderBuilder?.options.fields.map((f) => f.name);
|
|
622
|
+
(0, globals_1.expect)(fieldNames).toContain("author");
|
|
623
|
+
(0, globals_1.expect)(fieldNames).not.toContain("password");
|
|
624
|
+
});
|
|
625
|
+
(0, globals_1.it)("should compute for users table", async () => {
|
|
626
|
+
const view = await mkViewWithCfg({
|
|
627
|
+
configuration: {},
|
|
628
|
+
table_id: table_1.default.findOne("users")?.id,
|
|
629
|
+
});
|
|
630
|
+
const configFlow = await view.get_config_flow(mockReqRes.req);
|
|
631
|
+
const result = await configFlow.run({
|
|
632
|
+
table_id: view.table_id,
|
|
633
|
+
exttable_name: null,
|
|
634
|
+
viewname: view.name,
|
|
635
|
+
...view.configuration,
|
|
636
|
+
}, mockReqRes.req);
|
|
637
|
+
const fieldNames = result?.renderBuilder?.options.fields.map((f) => f.name);
|
|
638
|
+
(0, globals_1.expect)(fieldNames).not.toContain("author");
|
|
639
|
+
(0, globals_1.expect)(fieldNames).toContain("password");
|
|
640
|
+
(0, globals_1.expect)(fieldNames).toContain("email");
|
|
641
|
+
});
|
|
642
|
+
});
|
|
643
|
+
(0, globals_1.describe)("Edit view with accordion and join fields", () => {
|
|
644
|
+
(0, globals_1.it)("should run", async () => {
|
|
645
|
+
const view = await mkViewWithCfg(accordionConfig);
|
|
646
|
+
const vres1 = await view.run({ id: 1 }, mockReqRes);
|
|
647
|
+
(0, globals_1.expect)(vres1).toContain(">By Herman Melville<");
|
|
648
|
+
(0, globals_1.expect)(vres1).not.toContain(">Publisher Tab title");
|
|
649
|
+
(0, globals_1.expect)(vres1).not.toContain(">Publisher JF:");
|
|
650
|
+
const vres2 = await view.run({ id: 2 }, mockReqRes);
|
|
651
|
+
(0, globals_1.expect)(vres2).toContain(">By Leo Tolstoy<");
|
|
652
|
+
(0, globals_1.expect)(vres2).toContain(">Publisher Tab title 1<");
|
|
653
|
+
(0, globals_1.expect)(vres2).toContain(" data-source-url=");
|
|
654
|
+
});
|
|
655
|
+
});
|
|
656
|
+
(0, globals_1.describe)("Edit view components", () => {
|
|
657
|
+
(0, globals_1.it)("runs on_page_load action", async () => {
|
|
658
|
+
const view = await mkViewWithCfg({
|
|
659
|
+
configuration: {
|
|
660
|
+
layout: {
|
|
661
|
+
type: "action",
|
|
662
|
+
block: false,
|
|
663
|
+
rndid: "b6fd72",
|
|
664
|
+
nsteps: 1,
|
|
665
|
+
confirm: false,
|
|
666
|
+
minRole: 100,
|
|
667
|
+
isFormula: {},
|
|
668
|
+
action_icon: "",
|
|
669
|
+
action_name: "toast",
|
|
670
|
+
action_label: "",
|
|
671
|
+
action_style: "on_page_load",
|
|
672
|
+
configuration: {
|
|
673
|
+
text: "Hello!",
|
|
674
|
+
notify_type: "Notify",
|
|
675
|
+
},
|
|
676
|
+
},
|
|
677
|
+
columns: [
|
|
678
|
+
{
|
|
679
|
+
type: "Action",
|
|
680
|
+
rndid: "b6fd72",
|
|
681
|
+
nsteps: 1,
|
|
682
|
+
confirm: false,
|
|
683
|
+
minRole: 100,
|
|
684
|
+
isFormula: {},
|
|
685
|
+
action_icon: "",
|
|
686
|
+
action_name: "toast",
|
|
687
|
+
action_label: "",
|
|
688
|
+
action_style: "on_page_load",
|
|
689
|
+
configuration: {
|
|
690
|
+
text: "Hello!",
|
|
691
|
+
notify_type: "Notify",
|
|
692
|
+
},
|
|
693
|
+
},
|
|
694
|
+
],
|
|
695
|
+
},
|
|
696
|
+
});
|
|
697
|
+
const vres1 = await view.run({ id: 1 }, mockReqRes);
|
|
698
|
+
(0, globals_1.expect)(vres1).toBe(`<form data-viewname="${view.name}" action="/view/${view.name}" class="form-namespace " method="post" data-row-values="%7B%22user%22%3A%7B%22id%22%3A1%2C%22role_id%22%3A1%7D%2C%22author%22%3A%22Herman%20Melville%22%2C%22pages%22%3A967%2C%22publisher%22%3Anull%7D"><input type="hidden" name="_csrf" value=""><input type="hidden" class="form-control " name="id" value="1"><script>(function(f){if (document.readyState === "complete") f(); else document.addEventListener(\'DOMContentLoaded\',()=>setTimeout(f),false)})(function(){common_done({"notify":"Hello!"}, "${view.name}")});</script></form>`);
|
|
699
|
+
});
|
|
700
|
+
(0, globals_1.it)("runs button action", async () => {
|
|
701
|
+
const view = await mkViewWithCfg({
|
|
702
|
+
configuration: {
|
|
703
|
+
layout: {
|
|
704
|
+
type: "action",
|
|
705
|
+
block: false,
|
|
706
|
+
rndid: "b6fd72",
|
|
707
|
+
nsteps: 1,
|
|
708
|
+
confirm: false,
|
|
709
|
+
minRole: 100,
|
|
710
|
+
isFormula: {},
|
|
711
|
+
action_icon: "",
|
|
712
|
+
action_name: "toast",
|
|
713
|
+
action_label: "",
|
|
714
|
+
action_style: "btn btn-primary",
|
|
715
|
+
configuration: {
|
|
716
|
+
text: "Hello!",
|
|
717
|
+
notify_type: "Notify",
|
|
718
|
+
},
|
|
719
|
+
},
|
|
720
|
+
columns: [
|
|
721
|
+
{
|
|
722
|
+
type: "Action",
|
|
723
|
+
rndid: "b6fd72",
|
|
724
|
+
nsteps: 1,
|
|
725
|
+
confirm: false,
|
|
726
|
+
minRole: 100,
|
|
727
|
+
isFormula: {},
|
|
728
|
+
action_icon: "",
|
|
729
|
+
action_name: "toast",
|
|
730
|
+
action_label: "",
|
|
731
|
+
action_style: "btn btn-primary",
|
|
732
|
+
configuration: {
|
|
733
|
+
text: "Hello!",
|
|
734
|
+
notify_type: "Notify",
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
],
|
|
738
|
+
},
|
|
739
|
+
});
|
|
740
|
+
const vres1 = await view.run({ id: 1 }, mockReqRes);
|
|
741
|
+
(0, globals_1.expect)(vres1).toBe(`<form data-viewname="${view.name}" action="/view/${view.name}" class="form-namespace " method="post" data-row-values="%7B%22user%22%3A%7B%22id%22%3A1%2C%22role_id%22%3A1%7D%2C%22author%22%3A%22Herman%20Melville%22%2C%22pages%22%3A967%2C%22publisher%22%3Anull%7D"><input type="hidden" name="_csrf" value=""><input type="hidden" class="form-control " name="id" value="1"><a href="javascript:view_post('${view.name}', 'run_action', {rndid:'b6fd72', ...get_form_record({viewname: '${view.name}'})});" class="btn btn btn-primary ">toast</a></form>`);
|
|
742
|
+
mockReqRes.reset();
|
|
743
|
+
const body = { rndid: "b6fd72", id: "1" };
|
|
744
|
+
await view.runRoute("run_action", body, mockReqRes.res, { req: { body } }, false);
|
|
745
|
+
(0, globals_1.expect)(mockReqRes.getStored().json).toStrictEqual({
|
|
746
|
+
notify: "Hello!",
|
|
747
|
+
success: "ok",
|
|
748
|
+
});
|
|
749
|
+
});
|
|
750
|
+
(0, globals_1.it)("runs button action with form input", async () => {
|
|
751
|
+
const view = await mkViewWithCfg({
|
|
752
|
+
configuration: {
|
|
753
|
+
layout: {
|
|
754
|
+
above: [
|
|
755
|
+
{
|
|
756
|
+
type: "field",
|
|
757
|
+
block: false,
|
|
758
|
+
fieldview: "edit",
|
|
759
|
+
textStyle: "",
|
|
760
|
+
field_name: "author",
|
|
761
|
+
configuration: {},
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
type: "action",
|
|
765
|
+
block: false,
|
|
766
|
+
rndid: "40bb3f",
|
|
767
|
+
nsteps: "",
|
|
768
|
+
minRole: 100,
|
|
769
|
+
isFormula: {},
|
|
770
|
+
action_icon: "",
|
|
771
|
+
action_name: "toast",
|
|
772
|
+
action_size: "",
|
|
773
|
+
action_bgcol: "",
|
|
774
|
+
action_label: "",
|
|
775
|
+
action_style: "btn-primary",
|
|
776
|
+
configuration: {
|
|
777
|
+
text: "Hello from {{ author}}",
|
|
778
|
+
notify_type: "Notify",
|
|
779
|
+
},
|
|
780
|
+
step_only_ifs: "",
|
|
781
|
+
action_textcol: "",
|
|
782
|
+
action_bordercol: "",
|
|
783
|
+
step_action_names: "",
|
|
784
|
+
},
|
|
785
|
+
],
|
|
786
|
+
},
|
|
787
|
+
columns: [
|
|
788
|
+
{
|
|
789
|
+
type: "Field",
|
|
790
|
+
block: false,
|
|
791
|
+
fieldview: "edit",
|
|
792
|
+
textStyle: "",
|
|
793
|
+
field_name: "author",
|
|
794
|
+
configuration: {},
|
|
795
|
+
},
|
|
796
|
+
{
|
|
797
|
+
type: "Action",
|
|
798
|
+
rndid: "40bb3f",
|
|
799
|
+
nsteps: "",
|
|
800
|
+
minRole: 100,
|
|
801
|
+
isFormula: {},
|
|
802
|
+
action_icon: "",
|
|
803
|
+
action_name: "toast",
|
|
804
|
+
action_size: "",
|
|
805
|
+
action_bgcol: "",
|
|
806
|
+
action_label: "",
|
|
807
|
+
action_style: "btn-primary",
|
|
808
|
+
configuration: {
|
|
809
|
+
text: "Hello {{ user.email}} from {{ author}}",
|
|
810
|
+
notify_type: "Notify",
|
|
811
|
+
},
|
|
812
|
+
step_only_ifs: "",
|
|
813
|
+
action_textcol: "",
|
|
814
|
+
action_bordercol: "",
|
|
815
|
+
step_action_names: "",
|
|
816
|
+
},
|
|
817
|
+
],
|
|
818
|
+
},
|
|
819
|
+
});
|
|
820
|
+
mockReqRes.reset();
|
|
821
|
+
const body = {
|
|
822
|
+
rndid: "40bb3f",
|
|
823
|
+
user: {
|
|
824
|
+
email: "admin@bar.com",
|
|
825
|
+
id: 1,
|
|
826
|
+
role_id: 1,
|
|
827
|
+
language: "en",
|
|
828
|
+
},
|
|
829
|
+
author: "Chris Date",
|
|
830
|
+
};
|
|
831
|
+
await view.runRoute("run_action", body, mockReqRes.res, {
|
|
832
|
+
req: {
|
|
833
|
+
body,
|
|
834
|
+
user: {
|
|
835
|
+
email: "admin@foo.com",
|
|
836
|
+
id: 1,
|
|
837
|
+
role_id: 1,
|
|
838
|
+
language: "en",
|
|
839
|
+
},
|
|
840
|
+
},
|
|
841
|
+
}, false);
|
|
842
|
+
(0, globals_1.expect)(mockReqRes.getStored().json).toStrictEqual({
|
|
843
|
+
notify: "Hello admin@foo.com from Chris Date",
|
|
844
|
+
success: "ok",
|
|
845
|
+
});
|
|
846
|
+
});
|
|
847
|
+
(0, globals_1.it)("runs button action with fixed inputs", async () => {
|
|
848
|
+
const view = await mkViewWithCfg({
|
|
849
|
+
configuration: {
|
|
850
|
+
fixed: {
|
|
851
|
+
author: "MrFoo",
|
|
852
|
+
},
|
|
853
|
+
layout: {
|
|
854
|
+
type: "action",
|
|
855
|
+
block: false,
|
|
856
|
+
rndid: "ca9d71",
|
|
857
|
+
nsteps: 1,
|
|
858
|
+
confirm: false,
|
|
859
|
+
minRole: 100,
|
|
860
|
+
isFormula: {},
|
|
861
|
+
action_icon: "",
|
|
862
|
+
action_name: "toast",
|
|
863
|
+
action_label: "",
|
|
864
|
+
configuration: {
|
|
865
|
+
text: "Hello {{ user.email}} from {{ author}}",
|
|
866
|
+
notify_type: "Notify",
|
|
867
|
+
},
|
|
868
|
+
},
|
|
869
|
+
columns: [
|
|
870
|
+
{
|
|
871
|
+
type: "Action",
|
|
872
|
+
rndid: "ca9d71",
|
|
873
|
+
nsteps: 1,
|
|
874
|
+
confirm: false,
|
|
875
|
+
minRole: 100,
|
|
876
|
+
isFormula: {},
|
|
877
|
+
action_icon: "",
|
|
878
|
+
action_name: "toast",
|
|
879
|
+
action_label: "",
|
|
880
|
+
configuration: {
|
|
881
|
+
text: "Hello {{ user.email}} from {{ author}}",
|
|
882
|
+
notify_type: "Notify",
|
|
883
|
+
},
|
|
884
|
+
},
|
|
885
|
+
],
|
|
886
|
+
},
|
|
887
|
+
});
|
|
888
|
+
mockReqRes.reset();
|
|
889
|
+
const body = {
|
|
890
|
+
rndid: "ca9d71",
|
|
891
|
+
user: {
|
|
892
|
+
email: "admin@bar.com",
|
|
893
|
+
id: 1,
|
|
894
|
+
role_id: 1,
|
|
895
|
+
language: "en",
|
|
896
|
+
},
|
|
897
|
+
};
|
|
898
|
+
await view.runRoute("run_action", body, mockReqRes.res, {
|
|
899
|
+
req: {
|
|
900
|
+
body,
|
|
901
|
+
user: {
|
|
902
|
+
email: "admin@foo.com",
|
|
903
|
+
id: 1,
|
|
904
|
+
role_id: 1,
|
|
905
|
+
language: "en",
|
|
906
|
+
},
|
|
907
|
+
},
|
|
908
|
+
}, false);
|
|
909
|
+
(0, globals_1.expect)(mockReqRes.getStored().json).toStrictEqual({
|
|
910
|
+
notify: "Hello admin@foo.com from MrFoo",
|
|
911
|
+
success: "ok",
|
|
912
|
+
});
|
|
913
|
+
});
|
|
914
|
+
(0, globals_1.it)("view link independent same table", async () => {
|
|
915
|
+
const view = await mkViewWithCfg({
|
|
916
|
+
configuration: {
|
|
917
|
+
layout: {
|
|
918
|
+
type: "view_link",
|
|
919
|
+
view: "patientlist",
|
|
920
|
+
block: false,
|
|
921
|
+
minRole: 100,
|
|
922
|
+
relation: ".",
|
|
923
|
+
isFormula: {},
|
|
924
|
+
link_icon: "",
|
|
925
|
+
view_label: "",
|
|
926
|
+
},
|
|
927
|
+
columns: [
|
|
928
|
+
{
|
|
929
|
+
type: "ViewLink",
|
|
930
|
+
view: "patientlist",
|
|
931
|
+
block: false,
|
|
932
|
+
label: "",
|
|
933
|
+
minRole: 100,
|
|
934
|
+
relation: ".",
|
|
935
|
+
link_icon: "",
|
|
936
|
+
},
|
|
937
|
+
],
|
|
938
|
+
},
|
|
939
|
+
});
|
|
940
|
+
const vres1 = await view.run({ id: 1 }, mockReqRes);
|
|
941
|
+
(0, globals_1.expect)(vres1).toContain('<a href="/view/patientlist">patientlist</a>');
|
|
942
|
+
// TODO FIX THIS
|
|
943
|
+
//const vres0 = await view.run({}, mockReqRes);
|
|
944
|
+
//expect(vres0).toContain('<a href="/view/patientlist">patientlist</a>');
|
|
945
|
+
});
|
|
946
|
+
(0, globals_1.it)("view link independent different table", async () => {
|
|
947
|
+
const view = await mkViewWithCfg({
|
|
948
|
+
configuration: {
|
|
949
|
+
layout: {
|
|
950
|
+
type: "view_link",
|
|
951
|
+
view: "list_employees",
|
|
952
|
+
block: false,
|
|
953
|
+
minRole: 100,
|
|
954
|
+
relation: ".",
|
|
955
|
+
isFormula: {},
|
|
956
|
+
link_icon: "",
|
|
957
|
+
view_label: "",
|
|
958
|
+
},
|
|
959
|
+
columns: [
|
|
960
|
+
{
|
|
961
|
+
type: "ViewLink",
|
|
962
|
+
view: "list_employees",
|
|
963
|
+
block: false,
|
|
964
|
+
label: "",
|
|
965
|
+
minRole: 100,
|
|
966
|
+
relation: ".",
|
|
967
|
+
link_icon: "",
|
|
968
|
+
},
|
|
969
|
+
],
|
|
970
|
+
},
|
|
971
|
+
});
|
|
972
|
+
const vres1 = await view.run({ id: 1 }, mockReqRes);
|
|
973
|
+
(0, globals_1.expect)(vres1).toContain('<a href="/view/list_employees">list_employees</a>');
|
|
974
|
+
// TODO FIX THIS
|
|
975
|
+
//const vres0 = await view.run({}, mockReqRes);
|
|
976
|
+
//expect(vres0).toContain(
|
|
977
|
+
// '<a href="/view/list_employees">list_employees</a>'
|
|
978
|
+
//);
|
|
979
|
+
});
|
|
980
|
+
(0, globals_1.it)("view link children", async () => {
|
|
981
|
+
const view = await mkViewWithCfg({
|
|
982
|
+
configuration: {
|
|
983
|
+
layout: {
|
|
984
|
+
type: "view_link",
|
|
985
|
+
view: "patientlist",
|
|
986
|
+
block: false,
|
|
987
|
+
minRole: 100,
|
|
988
|
+
relation: ".books.patients$favbook",
|
|
989
|
+
isFormula: {},
|
|
990
|
+
link_icon: "",
|
|
991
|
+
view_label: "",
|
|
992
|
+
},
|
|
993
|
+
columns: [
|
|
994
|
+
{
|
|
995
|
+
type: "ViewLink",
|
|
996
|
+
view: "patientlist",
|
|
997
|
+
block: false,
|
|
998
|
+
label: "",
|
|
999
|
+
minRole: 100,
|
|
1000
|
+
relation: ".books.patients$favbook",
|
|
1001
|
+
link_icon: "",
|
|
1002
|
+
},
|
|
1003
|
+
],
|
|
1004
|
+
},
|
|
1005
|
+
});
|
|
1006
|
+
const vres1 = await view.run({ id: 1 }, mockReqRes);
|
|
1007
|
+
(0, globals_1.expect)(vres1).toContain('<a href="/view/patientlist?favbook=1">patientlist</a>');
|
|
1008
|
+
const vres0 = await view.run({}, mockReqRes);
|
|
1009
|
+
(0, globals_1.expect)(vres0).not.toContain("patientlist");
|
|
1010
|
+
});
|
|
1011
|
+
(0, globals_1.it)("embed view independent different table", async () => {
|
|
1012
|
+
const view = await mkViewWithCfg({
|
|
1013
|
+
configuration: {
|
|
1014
|
+
layout: {
|
|
1015
|
+
name: "f98a40",
|
|
1016
|
+
type: "view",
|
|
1017
|
+
view: "list_employees",
|
|
1018
|
+
state: "shared",
|
|
1019
|
+
relation: ".",
|
|
1020
|
+
},
|
|
1021
|
+
columns: [],
|
|
1022
|
+
},
|
|
1023
|
+
});
|
|
1024
|
+
const vres1 = await view.run({ id: 1 }, mockReqRes);
|
|
1025
|
+
(0, globals_1.expect)(vres1).toContain("my_department");
|
|
1026
|
+
const vres0 = await view.run({}, mockReqRes);
|
|
1027
|
+
(0, globals_1.expect)(vres0).toContain("my_department");
|
|
1028
|
+
});
|
|
1029
|
+
(0, globals_1.it)("embed view independent same table", async () => {
|
|
1030
|
+
const view = await mkViewWithCfg({
|
|
1031
|
+
configuration: {
|
|
1032
|
+
layout: {
|
|
1033
|
+
name: "f98a40",
|
|
1034
|
+
type: "view",
|
|
1035
|
+
view: "authorlist",
|
|
1036
|
+
state: "shared",
|
|
1037
|
+
relation: ".",
|
|
1038
|
+
},
|
|
1039
|
+
columns: [],
|
|
1040
|
+
},
|
|
1041
|
+
});
|
|
1042
|
+
const vres1 = await view.run({ id: 1 }, mockReqRes);
|
|
1043
|
+
(0, globals_1.expect)(vres1).toContain(">Leo Tolstoy<");
|
|
1044
|
+
(0, globals_1.expect)(vres1).toContain(">Herman Melville<");
|
|
1045
|
+
const vres0 = await view.run({}, mockReqRes);
|
|
1046
|
+
(0, globals_1.expect)(vres0).toContain(">Leo Tolstoy<");
|
|
1047
|
+
(0, globals_1.expect)(vres0).toContain(">Herman Melville<");
|
|
1048
|
+
});
|
|
1049
|
+
(0, globals_1.it)("embed view children", async () => {
|
|
1050
|
+
const view = await mkViewWithCfg({
|
|
1051
|
+
configuration: {
|
|
1052
|
+
layout: {
|
|
1053
|
+
name: "4ff12b",
|
|
1054
|
+
type: "view",
|
|
1055
|
+
view: "patientlist",
|
|
1056
|
+
state: "shared",
|
|
1057
|
+
relation: ".books.patients$favbook",
|
|
1058
|
+
},
|
|
1059
|
+
columns: [],
|
|
1060
|
+
},
|
|
1061
|
+
});
|
|
1062
|
+
const vres1 = await view.run({ id: 1 }, mockReqRes);
|
|
1063
|
+
(0, globals_1.expect)(vres1).toContain("Kirk");
|
|
1064
|
+
(0, globals_1.expect)(vres1).toContain('data-sc-embed-viewname="patientlist"');
|
|
1065
|
+
(0, globals_1.expect)(vres1).not.toContain("Michael");
|
|
1066
|
+
const vres0 = await view.run({}, mockReqRes);
|
|
1067
|
+
(0, globals_1.expect)(vres0).not.toContain('data-sc-embed-viewname="patientlist"');
|
|
1068
|
+
(0, globals_1.expect)(vres0).toContain("<form");
|
|
1069
|
+
});
|
|
1070
|
+
});
|
|
513
1071
|
//# sourceMappingURL=edit.test.js.map
|