@saltcorn/server 0.9.5-beta.12 → 0.9.5-beta.14
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/locales/en.json +5 -2
- package/package.json +9 -9
- package/public/saltcorn-common.js +11 -3
- package/public/saltcorn.js +8 -1
- package/routes/actions.js +1 -0
- package/routes/admin.js +128 -0
package/locales/en.json
CHANGED
|
@@ -1391,5 +1391,8 @@
|
|
|
1391
1391
|
"refresh": "refresh",
|
|
1392
1392
|
"installed": "installed",
|
|
1393
1393
|
"Include table history in backup": "Include table history in backup",
|
|
1394
|
-
"The plugin was corrupted and had to be repaired. We recommend restarting your server.": "The plugin was corrupted and had to be repaired. We recommend restarting your server."
|
|
1395
|
-
|
|
1394
|
+
"The plugin was corrupted and had to be repaired. We recommend restarting your server.": "The plugin was corrupted and had to be repaired. We recommend restarting your server.",
|
|
1395
|
+
"%s code page": "%s code page",
|
|
1396
|
+
"Constants and function code": "Constants and function code",
|
|
1397
|
+
"Delete code page": "Delete code page"
|
|
1398
|
+
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "0.9.5-beta.
|
|
3
|
+
"version": "0.9.5-beta.14",
|
|
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.5-beta.
|
|
11
|
-
"@saltcorn/builder": "0.9.5-beta.
|
|
12
|
-
"@saltcorn/data": "0.9.5-beta.
|
|
13
|
-
"@saltcorn/admin-models": "0.9.5-beta.
|
|
14
|
-
"@saltcorn/filemanager": "0.9.5-beta.
|
|
15
|
-
"@saltcorn/markup": "0.9.5-beta.
|
|
16
|
-
"@saltcorn/plugins-loader": "0.9.5-beta.
|
|
17
|
-
"@saltcorn/sbadmin2": "0.9.5-beta.
|
|
10
|
+
"@saltcorn/base-plugin": "0.9.5-beta.14",
|
|
11
|
+
"@saltcorn/builder": "0.9.5-beta.14",
|
|
12
|
+
"@saltcorn/data": "0.9.5-beta.14",
|
|
13
|
+
"@saltcorn/admin-models": "0.9.5-beta.14",
|
|
14
|
+
"@saltcorn/filemanager": "0.9.5-beta.14",
|
|
15
|
+
"@saltcorn/markup": "0.9.5-beta.14",
|
|
16
|
+
"@saltcorn/plugins-loader": "0.9.5-beta.14",
|
|
17
|
+
"@saltcorn/sbadmin2": "0.9.5-beta.14",
|
|
18
18
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
19
19
|
"@socket.io/sticky": "^1.0.1",
|
|
20
20
|
"adm-zip": "0.5.10",
|
|
@@ -159,10 +159,18 @@ function apply_showif() {
|
|
|
159
159
|
decodeURIComponent(e.attr("data-fetch-options"))
|
|
160
160
|
);
|
|
161
161
|
if (window._sc_loglevel > 4) console.log("dynwhere", dynwhere);
|
|
162
|
-
const kvToQs = ([k, v]) => {
|
|
162
|
+
const kvToQs = ([k, v], is_or) => {
|
|
163
163
|
return k === "or" && Array.isArray(v)
|
|
164
|
-
? v
|
|
165
|
-
|
|
164
|
+
? v
|
|
165
|
+
.map((v1) =>
|
|
166
|
+
Object.entries(v1)
|
|
167
|
+
.map((kv) => kvToQs(kv, true))
|
|
168
|
+
.join("&")
|
|
169
|
+
)
|
|
170
|
+
.join("&")
|
|
171
|
+
: `${k}=${v[0] === "$" ? rec[v.substring(1)] : v}${
|
|
172
|
+
is_or ? "&_or_field=" + k : ""
|
|
173
|
+
}`;
|
|
166
174
|
};
|
|
167
175
|
const qss = Object.entries(dynwhere.whereParsed).map(kvToQs);
|
|
168
176
|
if (dynwhere.dereference) {
|
package/public/saltcorn.js
CHANGED
|
@@ -450,7 +450,14 @@ function saveAndContinueAsync(e) {
|
|
|
450
450
|
});
|
|
451
451
|
}
|
|
452
452
|
|
|
453
|
-
function saveAndContinue(e, k) {
|
|
453
|
+
function saveAndContinue(e, k, event) {
|
|
454
|
+
if (
|
|
455
|
+
event &&
|
|
456
|
+
event.target &&
|
|
457
|
+
event.target.classList &&
|
|
458
|
+
event.target.classList.contains("no-form-change")
|
|
459
|
+
)
|
|
460
|
+
return;
|
|
454
461
|
var form = $(e).closest("form");
|
|
455
462
|
const valres = form[0].reportValidity();
|
|
456
463
|
if (!valres) return;
|
package/routes/actions.js
CHANGED
package/routes/admin.js
CHANGED
|
@@ -2772,6 +2772,7 @@ admin_config_route({
|
|
|
2772
2772
|
});
|
|
2773
2773
|
},
|
|
2774
2774
|
response(form, req, res) {
|
|
2775
|
+
const code_pages = getState().getConfig("function_code_pages", {});
|
|
2775
2776
|
send_admin_page({
|
|
2776
2777
|
res,
|
|
2777
2778
|
req,
|
|
@@ -2798,11 +2799,138 @@ admin_config_route({
|
|
|
2798
2799
|
),
|
|
2799
2800
|
],
|
|
2800
2801
|
},
|
|
2802
|
+
{
|
|
2803
|
+
type: "card",
|
|
2804
|
+
title: req.__("Constants and function code"),
|
|
2805
|
+
contents: [
|
|
2806
|
+
div(
|
|
2807
|
+
Object.keys(code_pages)
|
|
2808
|
+
.map((k) =>
|
|
2809
|
+
a(
|
|
2810
|
+
{
|
|
2811
|
+
href: `/admin/edit-codepage/${encodeURIComponent(k)}`,
|
|
2812
|
+
class: "",
|
|
2813
|
+
},
|
|
2814
|
+
k
|
|
2815
|
+
)
|
|
2816
|
+
)
|
|
2817
|
+
.join(" | "),
|
|
2818
|
+
button(
|
|
2819
|
+
{
|
|
2820
|
+
class: "btn btn-secondary btn-sm d-block mt-2",
|
|
2821
|
+
onclick: `location.href='/admin/edit-codepage/'+prompt('Name of the new page')`,
|
|
2822
|
+
},
|
|
2823
|
+
i({ class: "fas fa-plus me-1" }),
|
|
2824
|
+
"Add page"
|
|
2825
|
+
)
|
|
2826
|
+
),
|
|
2827
|
+
],
|
|
2828
|
+
},
|
|
2801
2829
|
],
|
|
2802
2830
|
},
|
|
2803
2831
|
});
|
|
2804
2832
|
},
|
|
2805
2833
|
});
|
|
2834
|
+
|
|
2835
|
+
router.get(
|
|
2836
|
+
"/edit-codepage/:name",
|
|
2837
|
+
isAdmin,
|
|
2838
|
+
error_catcher(async (req, res) => {
|
|
2839
|
+
const { name } = req.params;
|
|
2840
|
+
const code_pages = getState().getConfig("function_code_pages", {});
|
|
2841
|
+
const existing = code_pages[name] || "";
|
|
2842
|
+
const form = new Form({
|
|
2843
|
+
action: `/admin/edit-codepage/${encodeURIComponent(name)}`,
|
|
2844
|
+
onChange: "saveAndContinue(this)",
|
|
2845
|
+
values: { code: existing },
|
|
2846
|
+
noSubmitButton: true,
|
|
2847
|
+
labelCols: 0,
|
|
2848
|
+
additionalButtons: [
|
|
2849
|
+
{
|
|
2850
|
+
label: req.__("Delete code page"),
|
|
2851
|
+
class: "btn btn-outline-danger btn-sm",
|
|
2852
|
+
onclick: `if(confirm('Are you sure you would like to delete this code page?'))ajax_post('/admin/delete-codepage/${encodeURIComponent(
|
|
2853
|
+
name
|
|
2854
|
+
)}')`,
|
|
2855
|
+
},
|
|
2856
|
+
],
|
|
2857
|
+
fields: [
|
|
2858
|
+
{
|
|
2859
|
+
name: "code",
|
|
2860
|
+
form_name: "code",
|
|
2861
|
+
label: "Code",
|
|
2862
|
+
sublabel:
|
|
2863
|
+
"Only functions declared as <code>function name(...) {...}</code> or <code>async function name(...) {...}</code> will be available in formulae and code actions. Declare a constant <code>k</code> as <code>globalThis.k = ...</code> In scope: " +
|
|
2864
|
+
a(
|
|
2865
|
+
{
|
|
2866
|
+
href: "https://saltcorn.github.io/saltcorn/classes/_saltcorn_data.models.Table-1.html",
|
|
2867
|
+
target: "_blank",
|
|
2868
|
+
},
|
|
2869
|
+
"Table"
|
|
2870
|
+
),
|
|
2871
|
+
input_type: "code",
|
|
2872
|
+
attributes: { mode: "text/javascript" },
|
|
2873
|
+
class: "validate-statements",
|
|
2874
|
+
validator(s) {
|
|
2875
|
+
try {
|
|
2876
|
+
let AsyncFunction = Object.getPrototypeOf(
|
|
2877
|
+
async function () {}
|
|
2878
|
+
).constructor;
|
|
2879
|
+
AsyncFunction(s);
|
|
2880
|
+
return true;
|
|
2881
|
+
} catch (e) {
|
|
2882
|
+
return e.message;
|
|
2883
|
+
}
|
|
2884
|
+
},
|
|
2885
|
+
},
|
|
2886
|
+
],
|
|
2887
|
+
});
|
|
2888
|
+
|
|
2889
|
+
send_admin_page({
|
|
2890
|
+
res,
|
|
2891
|
+
req,
|
|
2892
|
+
active_sub: "Development",
|
|
2893
|
+
sub2_page: req.__(`%s code page`, name),
|
|
2894
|
+
contents: {
|
|
2895
|
+
type: "card",
|
|
2896
|
+
title: req.__(`%s code page`, name),
|
|
2897
|
+
contents: [renderForm(form, req.csrfToken())],
|
|
2898
|
+
},
|
|
2899
|
+
});
|
|
2900
|
+
})
|
|
2901
|
+
);
|
|
2902
|
+
|
|
2903
|
+
router.post(
|
|
2904
|
+
"/edit-codepage/:name",
|
|
2905
|
+
isAdmin,
|
|
2906
|
+
error_catcher(async (req, res) => {
|
|
2907
|
+
const { name } = req.params;
|
|
2908
|
+
const code_pages = getState().getConfigCopy("function_code_pages", {});
|
|
2909
|
+
|
|
2910
|
+
const code = req.body.code;
|
|
2911
|
+
await getState().setConfig("function_code_pages", {
|
|
2912
|
+
...code_pages,
|
|
2913
|
+
[name]: code,
|
|
2914
|
+
});
|
|
2915
|
+
await getState().refresh_codepages();
|
|
2916
|
+
|
|
2917
|
+
res.json({ success: true });
|
|
2918
|
+
})
|
|
2919
|
+
);
|
|
2920
|
+
router.post(
|
|
2921
|
+
"/delete-codepage/:name",
|
|
2922
|
+
isAdmin,
|
|
2923
|
+
error_catcher(async (req, res) => {
|
|
2924
|
+
const { name } = req.params;
|
|
2925
|
+
const code_pages = getState().getConfigCopy("function_code_pages", {});
|
|
2926
|
+
delete code_pages[name];
|
|
2927
|
+
await getState().setConfig("function_code_pages", code_pages);
|
|
2928
|
+
await getState().refresh_codepages();
|
|
2929
|
+
|
|
2930
|
+
res.json({ goto: `/admin/dev` });
|
|
2931
|
+
})
|
|
2932
|
+
);
|
|
2933
|
+
|
|
2806
2934
|
/**
|
|
2807
2935
|
* Notifications
|
|
2808
2936
|
*/
|