@saltcorn/server 1.0.0-beta.10 → 1.0.0-beta.13
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/load_plugins.js +1 -1
- package/package.json +9 -9
- package/public/saltcorn-common.js +42 -34
- package/routes/scapi.js +19 -0
package/load_plugins.js
CHANGED
|
@@ -51,7 +51,7 @@ const ensurePluginSupport = async (plugin) => {
|
|
|
51
51
|
* @param force - force flag
|
|
52
52
|
*/
|
|
53
53
|
const loadPlugin = async (plugin, force) => {
|
|
54
|
-
if (plugin.source === "npm") {
|
|
54
|
+
if (plugin.source === "npm" && isRoot()) {
|
|
55
55
|
try {
|
|
56
56
|
await ensurePluginSupport(plugin);
|
|
57
57
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@saltcorn/server",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.13",
|
|
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": "1.0.0-beta.
|
|
11
|
-
"@saltcorn/builder": "1.0.0-beta.
|
|
12
|
-
"@saltcorn/data": "1.0.0-beta.
|
|
13
|
-
"@saltcorn/admin-models": "1.0.0-beta.
|
|
14
|
-
"@saltcorn/filemanager": "1.0.0-beta.
|
|
15
|
-
"@saltcorn/markup": "1.0.0-beta.
|
|
16
|
-
"@saltcorn/plugins-loader": "1.0.0-beta.
|
|
17
|
-
"@saltcorn/sbadmin2": "1.0.0-beta.
|
|
10
|
+
"@saltcorn/base-plugin": "1.0.0-beta.13",
|
|
11
|
+
"@saltcorn/builder": "1.0.0-beta.13",
|
|
12
|
+
"@saltcorn/data": "1.0.0-beta.13",
|
|
13
|
+
"@saltcorn/admin-models": "1.0.0-beta.13",
|
|
14
|
+
"@saltcorn/filemanager": "1.0.0-beta.13",
|
|
15
|
+
"@saltcorn/markup": "1.0.0-beta.13",
|
|
16
|
+
"@saltcorn/plugins-loader": "1.0.0-beta.13",
|
|
17
|
+
"@saltcorn/sbadmin2": "1.0.0-beta.13",
|
|
18
18
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
19
19
|
"@socket.io/sticky": "^1.0.1",
|
|
20
20
|
"adm-zip": "0.5.10",
|
|
@@ -63,14 +63,20 @@ function reset_nearest_form(that) {
|
|
|
63
63
|
|
|
64
64
|
function add_repeater(nm) {
|
|
65
65
|
var es = $("div.form-repeat.repeat-" + nm);
|
|
66
|
-
|
|
66
|
+
const ncopy = es.length - 1;
|
|
67
|
+
var e = es.last();
|
|
67
68
|
var newix = es.length;
|
|
68
69
|
var newe = $(e).clone();
|
|
69
70
|
newe.find("[name]").each(function (ix, element) {
|
|
70
71
|
if ($(element).hasClass("omit-repeater-clone")) $(element).remove();
|
|
71
|
-
|
|
72
|
-
var
|
|
72
|
+
const oldnm = element.name || "";
|
|
73
|
+
var newnm = (element.name || "").replace("_" + ncopy, "_" + newix);
|
|
74
|
+
var newid = (element.id || "").replace("_" + ncopy, "_" + newix);
|
|
73
75
|
$(element).attr("name", newnm).attr("id", newid);
|
|
76
|
+
if (element.tagName === "SELECT") {
|
|
77
|
+
const original = document.getElementsByName(oldnm)[0];
|
|
78
|
+
if (original) element.selectedIndex = original.selectedIndex;
|
|
79
|
+
}
|
|
74
80
|
});
|
|
75
81
|
newe.appendTo($("div.repeats-" + nm));
|
|
76
82
|
newe.find("[data-on-cloned]").each(function (ix, element) {
|
|
@@ -80,6 +86,27 @@ function add_repeater(nm) {
|
|
|
80
86
|
});
|
|
81
87
|
}
|
|
82
88
|
|
|
89
|
+
function rep_del(e) {
|
|
90
|
+
var myrep = $(e).closest(".form-repeat");
|
|
91
|
+
var ix = myrep.index();
|
|
92
|
+
var parent = myrep.parent();
|
|
93
|
+
myrep.remove();
|
|
94
|
+
parent.children().each(function (childix, element) {
|
|
95
|
+
if (childix > ix) {
|
|
96
|
+
reindex(element, childix, childix - 1);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function reindex(element, oldix, newix) {
|
|
102
|
+
$(element).html(
|
|
103
|
+
$(element)
|
|
104
|
+
.html()
|
|
105
|
+
.split("_" + oldix + '"')
|
|
106
|
+
.join("_" + newix + '"')
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
83
110
|
const _apply_showif_plugins = [];
|
|
84
111
|
|
|
85
112
|
const add_apply_showif_plugin = (p) => {
|
|
@@ -115,16 +142,18 @@ function apply_showif() {
|
|
|
115
142
|
}
|
|
116
143
|
if (!e.data("data-closest-form-ns"))
|
|
117
144
|
e.data("data-closest-form-ns", e.closest(".form-namespace"));
|
|
118
|
-
if (to_show(e))
|
|
119
|
-
e.show(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
)
|
|
127
|
-
|
|
145
|
+
if (to_show(e)) {
|
|
146
|
+
e.find("input, textarea, button, select, [data-show-if]").prop(
|
|
147
|
+
"disabled",
|
|
148
|
+
e.attr("data-disabled") || false
|
|
149
|
+
);
|
|
150
|
+
element.style.display = "";
|
|
151
|
+
} else {
|
|
152
|
+
e.find(
|
|
153
|
+
"input:enabled, textarea:enabled, button:enabled, select:enabled, [data-show-if]:not([disabled])"
|
|
154
|
+
).prop("disabled", true);
|
|
155
|
+
element.style.setProperty("display", "none", "important");
|
|
156
|
+
}
|
|
128
157
|
} catch (e) {
|
|
129
158
|
console.error(e);
|
|
130
159
|
}
|
|
@@ -561,27 +590,6 @@ function showIfFormulaInputs(e, fml) {
|
|
|
561
590
|
}
|
|
562
591
|
}
|
|
563
592
|
|
|
564
|
-
function rep_del(e) {
|
|
565
|
-
var myrep = $(e).closest(".form-repeat");
|
|
566
|
-
var ix = myrep.index();
|
|
567
|
-
var parent = myrep.parent();
|
|
568
|
-
parent.children().each(function (childix, element) {
|
|
569
|
-
if (childix > ix) {
|
|
570
|
-
reindex(element, childix, childix - 1);
|
|
571
|
-
}
|
|
572
|
-
});
|
|
573
|
-
myrep.remove();
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
function reindex(element, oldix, newix) {
|
|
577
|
-
$(element).html(
|
|
578
|
-
$(element)
|
|
579
|
-
.html()
|
|
580
|
-
.split("_" + oldix)
|
|
581
|
-
.join("_" + newix)
|
|
582
|
-
);
|
|
583
|
-
}
|
|
584
|
-
|
|
585
593
|
function get_form_subset_record(e) {
|
|
586
594
|
const rec = {};
|
|
587
595
|
e.find("input[name],select[name]").each(function () {
|
package/routes/scapi.js
CHANGED
|
@@ -25,6 +25,7 @@ const {
|
|
|
25
25
|
stateFieldsToWhere,
|
|
26
26
|
readState,
|
|
27
27
|
} = require("@saltcorn/data/plugin-helper");
|
|
28
|
+
const { getState } = require("@saltcorn/data/db/state");
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
31
|
* @type {object}
|
|
@@ -307,3 +308,21 @@ router.get(
|
|
|
307
308
|
)(req, res, next);
|
|
308
309
|
})
|
|
309
310
|
);
|
|
311
|
+
|
|
312
|
+
router.get(
|
|
313
|
+
"/reload",
|
|
314
|
+
error_catcher(async (req, res, next) => {
|
|
315
|
+
await passport.authenticate(
|
|
316
|
+
"api-bearer",
|
|
317
|
+
{ session: false },
|
|
318
|
+
async function (err, user, info) {
|
|
319
|
+
if (accessAllowedRead(req, user)) {
|
|
320
|
+
await getState().refresh_plugins();
|
|
321
|
+
res.json({ success: true });
|
|
322
|
+
} else {
|
|
323
|
+
res.status(401).json({ error: req.__("Not authorized") });
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
)(req, res, next);
|
|
327
|
+
})
|
|
328
|
+
);
|