@saltcorn/server 0.9.1-beta.7 → 0.9.1-beta.9
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/auth/admin.js +1 -1
- package/locales/en.json +2 -1
- package/package.json +8 -8
- package/public/saltcorn-common.js +35 -24
- package/tests/view.test.js +58 -0
- package/wrapper.js +8 -1
package/auth/admin.js
CHANGED
package/locales/en.json
CHANGED
|
@@ -1277,5 +1277,6 @@
|
|
|
1277
1277
|
"HTML file": "HTML file",
|
|
1278
1278
|
"HTML file to use as page content": "HTML file to use as page content",
|
|
1279
1279
|
"Offline mode: cannot load file": "Offline mode: cannot load file",
|
|
1280
|
-
"None - use drag and drop builder": "None - use drag and drop builder"
|
|
1280
|
+
"None - use drag and drop builder": "None - use drag and drop builder",
|
|
1281
|
+
"Do not pick or compare time": "Do not pick or compare time"
|
|
1281
1282
|
}
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "0.9.1-beta.
|
|
3
|
+
"version": "0.9.1-beta.9",
|
|
4
4
|
"description": "Server app for Saltcorn, open-source no-code platform",
|
|
5
5
|
"homepage": "https://saltcorn.com",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@aws-sdk/client-s3": "^3.451.0",
|
|
10
|
-
"@saltcorn/base-plugin": "0.9.1-beta.
|
|
11
|
-
"@saltcorn/builder": "0.9.1-beta.
|
|
12
|
-
"@saltcorn/data": "0.9.1-beta.
|
|
13
|
-
"@saltcorn/admin-models": "0.9.1-beta.
|
|
14
|
-
"@saltcorn/filemanager": "0.9.1-beta.
|
|
15
|
-
"@saltcorn/markup": "0.9.1-beta.
|
|
16
|
-
"@saltcorn/sbadmin2": "0.9.1-beta.
|
|
10
|
+
"@saltcorn/base-plugin": "0.9.1-beta.9",
|
|
11
|
+
"@saltcorn/builder": "0.9.1-beta.9",
|
|
12
|
+
"@saltcorn/data": "0.9.1-beta.9",
|
|
13
|
+
"@saltcorn/admin-models": "0.9.1-beta.9",
|
|
14
|
+
"@saltcorn/filemanager": "0.9.1-beta.9",
|
|
15
|
+
"@saltcorn/markup": "0.9.1-beta.9",
|
|
16
|
+
"@saltcorn/sbadmin2": "0.9.1-beta.9",
|
|
17
17
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
18
18
|
"@socket.io/sticky": "^1.0.1",
|
|
19
19
|
"adm-zip": "0.5.10",
|
|
@@ -50,6 +50,11 @@ const nubBy = (prop, xs) => {
|
|
|
50
50
|
return true;
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
|
+
|
|
54
|
+
function valid_js_var_name(s) {
|
|
55
|
+
if (!s) return false;
|
|
56
|
+
return !!s.match(/^[a-zA-Z_$][a-zA-Z_$0-9]*$/);
|
|
57
|
+
}
|
|
53
58
|
function apply_showif() {
|
|
54
59
|
const isNode = typeof parent?.saltcorn?.data?.state === "undefined";
|
|
55
60
|
$("[data-show-if]").each(function (ix, element) {
|
|
@@ -83,7 +88,7 @@ function apply_showif() {
|
|
|
83
88
|
const e = $(element);
|
|
84
89
|
const rec = get_form_record(e);
|
|
85
90
|
const href = new Function(
|
|
86
|
-
`{${Object.keys(rec).join(",")}}`,
|
|
91
|
+
`{${Object.keys(rec).filter(valid_js_var_name).join(",")}}`,
|
|
87
92
|
"return " + e.attr("data-dyn-href")
|
|
88
93
|
)(rec);
|
|
89
94
|
e.attr("href", href);
|
|
@@ -756,31 +761,37 @@ function initialize_page() {
|
|
|
756
761
|
$(el).addClass("codemirror-enabled");
|
|
757
762
|
cm.on(
|
|
758
763
|
"change",
|
|
759
|
-
$.debounce(
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
764
|
+
$.debounce(
|
|
765
|
+
(cm1) => {
|
|
766
|
+
cm1.save();
|
|
767
|
+
if ($(el).hasClass("validate-statements")) {
|
|
768
|
+
try {
|
|
769
|
+
let AsyncFunction = Object.getPrototypeOf(
|
|
770
|
+
async function () {}
|
|
771
|
+
).constructor;
|
|
772
|
+
AsyncFunction(cm.getValue());
|
|
773
|
+
$(el).closest("form").trigger("change");
|
|
774
|
+
} catch (e) {
|
|
775
|
+
const form = $(el).closest("form");
|
|
776
|
+
const errorArea = form.parent().find(".full-form-error");
|
|
777
|
+
if (errorArea.length) errorArea.text(e.message);
|
|
778
|
+
else
|
|
779
|
+
form
|
|
780
|
+
.parent()
|
|
781
|
+
.append(
|
|
782
|
+
`<p class="text-danger full-form-error">${e.message}</p>`
|
|
783
|
+
);
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
} else {
|
|
787
|
+
cm1.save();
|
|
766
788
|
$(el).closest("form").trigger("change");
|
|
767
|
-
} catch (e) {
|
|
768
|
-
const form = $(el).closest("form");
|
|
769
|
-
const errorArea = form.parent().find(".full-form-error");
|
|
770
|
-
if (errorArea.length) errorArea.text(e.message);
|
|
771
|
-
else
|
|
772
|
-
form
|
|
773
|
-
.parent()
|
|
774
|
-
.append(
|
|
775
|
-
`<p class="text-danger full-form-error">${e.message}</p>`
|
|
776
|
-
);
|
|
777
|
-
return;
|
|
778
789
|
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
790
|
+
},
|
|
791
|
+
500,
|
|
792
|
+
null,
|
|
793
|
+
true
|
|
794
|
+
)
|
|
784
795
|
);
|
|
785
796
|
});
|
|
786
797
|
}, 100);
|
package/tests/view.test.js
CHANGED
|
@@ -17,6 +17,9 @@ const View = require("@saltcorn/data/models/view");
|
|
|
17
17
|
const Table = require("@saltcorn/data/models/table");
|
|
18
18
|
|
|
19
19
|
const { plugin_with_routes } = require("@saltcorn/data/tests/mocks");
|
|
20
|
+
const {
|
|
21
|
+
prepareArtistsAlbumRelation,
|
|
22
|
+
} = require("@saltcorn/data/tests/common_helpers");
|
|
20
23
|
|
|
21
24
|
afterAll(db.close);
|
|
22
25
|
beforeAll(async () => {
|
|
@@ -586,3 +589,58 @@ describe("inbound relations", () => {
|
|
|
586
589
|
.expect(toNotInclude("Content of post CPost C"));
|
|
587
590
|
});
|
|
588
591
|
});
|
|
592
|
+
|
|
593
|
+
describe("many to many relations", () => {
|
|
594
|
+
beforeAll(async () => {
|
|
595
|
+
await prepareArtistsAlbumRelation();
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
it("artist_plays_on_album", async () => {
|
|
599
|
+
const app = await getApp({ disableCsrf: true });
|
|
600
|
+
const loginCookie = await getAdminLoginCookie();
|
|
601
|
+
await request(app)
|
|
602
|
+
.get("/view/show_artist?id=1")
|
|
603
|
+
.set("Cookie", loginCookie)
|
|
604
|
+
.expect(toInclude("album A"))
|
|
605
|
+
.expect(toInclude("album B"));
|
|
606
|
+
|
|
607
|
+
await request(app)
|
|
608
|
+
.get("/view/show_artist?id=2")
|
|
609
|
+
.set("Cookie", loginCookie)
|
|
610
|
+
.expect(toInclude("album A"))
|
|
611
|
+
.expect(toNotInclude("album B"));
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
it("albums feed with query", async () => {
|
|
615
|
+
const app = await getApp({ disableCsrf: true });
|
|
616
|
+
const loginCookie = await getAdminLoginCookie();
|
|
617
|
+
|
|
618
|
+
const queryObj_1 = {
|
|
619
|
+
relation: ".artists.artist_plays_on_album$artist.album",
|
|
620
|
+
srcId: 1,
|
|
621
|
+
};
|
|
622
|
+
await request(app)
|
|
623
|
+
.get(
|
|
624
|
+
`/view/albums_feed?_inbound_relation_path_=${encodeURIComponent(
|
|
625
|
+
JSON.stringify(queryObj_1)
|
|
626
|
+
)}`
|
|
627
|
+
)
|
|
628
|
+
.set("Cookie", loginCookie)
|
|
629
|
+
.expect(toInclude("album A"))
|
|
630
|
+
.expect(toInclude("album B"));
|
|
631
|
+
|
|
632
|
+
const queryObj_2 = {
|
|
633
|
+
relation: ".artists.artist_plays_on_album$artist.album",
|
|
634
|
+
srcId: 2,
|
|
635
|
+
};
|
|
636
|
+
await request(app)
|
|
637
|
+
.get(
|
|
638
|
+
`/view/albums_feed?_inbound_relation_path_=${encodeURIComponent(
|
|
639
|
+
JSON.stringify(queryObj_2)
|
|
640
|
+
)}`
|
|
641
|
+
)
|
|
642
|
+
.set("Cookie", loginCookie)
|
|
643
|
+
.expect(toInclude("album A"))
|
|
644
|
+
.expect(toNotInclude("album B"));
|
|
645
|
+
});
|
|
646
|
+
});
|
package/wrapper.js
CHANGED
|
@@ -316,7 +316,14 @@ module.exports = (version_tag) =>
|
|
|
316
316
|
if (req.xhr) {
|
|
317
317
|
const renderToHtml = layout.renderBody
|
|
318
318
|
? (h, role, req) =>
|
|
319
|
-
layout.renderBody({
|
|
319
|
+
layout.renderBody({
|
|
320
|
+
title,
|
|
321
|
+
body: h,
|
|
322
|
+
role,
|
|
323
|
+
alerts,
|
|
324
|
+
req,
|
|
325
|
+
hints: layout.hints,
|
|
326
|
+
})
|
|
320
327
|
: defaultRenderToHtml;
|
|
321
328
|
res.header(
|
|
322
329
|
"Cache-Control",
|