@saltcorn/server 0.9.1-beta.17 → 0.9.1-beta.19
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/routes.js +14 -2
- package/locales/en.json +2 -1
- package/package.json +8 -8
- package/public/saltcorn-common.js +20 -13
- package/public/saltcorn.js +9 -0
- package/routes/pageedit.js +1 -0
- package/routes/view.js +19 -6
package/auth/routes.js
CHANGED
|
@@ -1623,12 +1623,24 @@ router.post(
|
|
|
1623
1623
|
if (user_settings_form) {
|
|
1624
1624
|
const view = await View.findOne({ name: user_settings_form });
|
|
1625
1625
|
if (view) {
|
|
1626
|
+
const fakeRes = {
|
|
1627
|
+
status() {},
|
|
1628
|
+
sendWrap() {},
|
|
1629
|
+
json() {},
|
|
1630
|
+
redirect() {},
|
|
1631
|
+
};
|
|
1626
1632
|
await view.runPost({ id: user.id }, req.body, {
|
|
1627
1633
|
req,
|
|
1628
|
-
res,
|
|
1634
|
+
res: fakeRes,
|
|
1629
1635
|
redirect: "/auth/settings",
|
|
1630
1636
|
});
|
|
1631
|
-
|
|
1637
|
+
const u = await User.findForSession({ id: user.id });
|
|
1638
|
+
req.login(u.session_object, function (err) {
|
|
1639
|
+
if (err) req.flash("danger", err);
|
|
1640
|
+
else req.flash("success", req.__("User settings changed"));
|
|
1641
|
+
|
|
1642
|
+
res.redirect("/auth/settings");
|
|
1643
|
+
});
|
|
1632
1644
|
}
|
|
1633
1645
|
} else {
|
|
1634
1646
|
res.redirect("/auth/settings");
|
package/locales/en.json
CHANGED
|
@@ -1284,5 +1284,6 @@
|
|
|
1284
1284
|
"Set theme for each user role »": "Set theme for each user role »",
|
|
1285
1285
|
"Available themes": "Available themes",
|
|
1286
1286
|
"Install more themes »": "Install more themes »",
|
|
1287
|
-
"Configure action": "Configure action"
|
|
1287
|
+
"Configure action": "Configure action",
|
|
1288
|
+
"No changes detected, snapshot skipped": "No changes detected, snapshot skipped"
|
|
1288
1289
|
}
|
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.19",
|
|
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.19",
|
|
11
|
+
"@saltcorn/builder": "0.9.1-beta.19",
|
|
12
|
+
"@saltcorn/data": "0.9.1-beta.19",
|
|
13
|
+
"@saltcorn/admin-models": "0.9.1-beta.19",
|
|
14
|
+
"@saltcorn/filemanager": "0.9.1-beta.19",
|
|
15
|
+
"@saltcorn/markup": "0.9.1-beta.19",
|
|
16
|
+
"@saltcorn/sbadmin2": "0.9.1-beta.19",
|
|
17
17
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
18
18
|
"@socket.io/sticky": "^1.0.1",
|
|
19
19
|
"adm-zip": "0.5.10",
|
|
@@ -1083,32 +1083,39 @@ function restore_old_button(btnId) {
|
|
|
1083
1083
|
btn.removeData("old-text");
|
|
1084
1084
|
}
|
|
1085
1085
|
|
|
1086
|
-
function common_done(res, viewname, isWeb = true) {
|
|
1087
|
-
const handle = (element, fn) => {
|
|
1088
|
-
if (Array.isArray(element))
|
|
1089
|
-
|
|
1086
|
+
async function common_done(res, viewname, isWeb = true) {
|
|
1087
|
+
const handle = async (element, fn) => {
|
|
1088
|
+
if (Array.isArray(element))
|
|
1089
|
+
for (const current of element) await fn(current);
|
|
1090
|
+
else await fn(element);
|
|
1090
1091
|
};
|
|
1091
|
-
const eval_it = (s) => {
|
|
1092
|
+
const eval_it = async (s) => {
|
|
1092
1093
|
if (res.row && res.field_names) {
|
|
1093
1094
|
const f = new Function(`viewname, row, {${res.field_names}}`, s);
|
|
1094
|
-
const evalres = f(viewname, res.row, res.row);
|
|
1095
|
-
if (evalres) common_done(evalres, viewname, isWeb);
|
|
1095
|
+
const evalres = await f(viewname, res.row, res.row);
|
|
1096
|
+
if (evalres) await common_done(evalres, viewname, isWeb);
|
|
1096
1097
|
} else {
|
|
1097
1098
|
const f = new Function(`viewname`, s);
|
|
1098
|
-
const evalres = f(viewname);
|
|
1099
|
-
if (evalres) common_done(evalres, viewname, isWeb);
|
|
1099
|
+
const evalres = await f(viewname);
|
|
1100
|
+
if (evalres) await common_done(evalres, viewname, isWeb);
|
|
1100
1101
|
}
|
|
1101
1102
|
};
|
|
1102
|
-
if (res.notify) handle(res.notify, notifyAlert);
|
|
1103
|
+
if (res.notify) await handle(res.notify, notifyAlert);
|
|
1103
1104
|
if (res.error)
|
|
1104
|
-
handle(res.error, (text) =>
|
|
1105
|
-
|
|
1105
|
+
await handle(res.error, (text) =>
|
|
1106
|
+
notifyAlert({ type: "danger", text: text })
|
|
1107
|
+
);
|
|
1108
|
+
if (res.notify_success)
|
|
1109
|
+
await handle(res.notify_success, (text) =>
|
|
1110
|
+
notifyAlert({ type: "success", text: text })
|
|
1111
|
+
);
|
|
1112
|
+
if (res.eval_js) await handle(res.eval_js, eval_it);
|
|
1106
1113
|
|
|
1107
1114
|
if (res.reload_page) {
|
|
1108
1115
|
(isWeb ? location : parent).reload(); //TODO notify to cookie if reload or goto
|
|
1109
1116
|
}
|
|
1110
1117
|
if (res.download) {
|
|
1111
|
-
handle(res.download, (download) => {
|
|
1118
|
+
await handle(res.download, (download) => {
|
|
1112
1119
|
const dataurl = `data:${
|
|
1113
1120
|
download.mimetype || "application/octet-stream"
|
|
1114
1121
|
};base64,${download.blob}`;
|
package/public/saltcorn.js
CHANGED
|
@@ -280,6 +280,7 @@ function globalErrorCatcher(message, source, lineno, colno, error) {
|
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
function close_saltcorn_modal() {
|
|
283
|
+
$("#scmodal").off("hidden.bs.modal");
|
|
283
284
|
var myModalEl = document.getElementById("scmodal");
|
|
284
285
|
if (!myModalEl) return;
|
|
285
286
|
var modal = bootstrap.Modal.getInstance(myModalEl);
|
|
@@ -396,6 +397,11 @@ function submitWithAjax(e) {
|
|
|
396
397
|
notifyAlert({ type: "danger", text: res.responseJSON.error });
|
|
397
398
|
});
|
|
398
399
|
}
|
|
400
|
+
function saveAndContinueAsync(e) {
|
|
401
|
+
return new Promise((resolve, reject) => {
|
|
402
|
+
saveAndContinue(e, (x) => resolve(x));
|
|
403
|
+
});
|
|
404
|
+
}
|
|
399
405
|
|
|
400
406
|
function saveAndContinue(e, k) {
|
|
401
407
|
var form = $(e).closest("form");
|
|
@@ -422,6 +428,9 @@ function saveAndContinue(e, k) {
|
|
|
422
428
|
if (res.notify) {
|
|
423
429
|
notifyAlert(res.notify);
|
|
424
430
|
}
|
|
431
|
+
if (res.notify_success) {
|
|
432
|
+
notifyAlert({ type: "success", text: res.notify });
|
|
433
|
+
}
|
|
425
434
|
if (res.reload_page) {
|
|
426
435
|
location.reload(); //TODO notify to cookie if reload or goto
|
|
427
436
|
}
|
package/routes/pageedit.js
CHANGED
package/routes/view.js
CHANGED
|
@@ -10,7 +10,7 @@ const View = require("@saltcorn/data/models/view");
|
|
|
10
10
|
const Table = require("@saltcorn/data/models/table");
|
|
11
11
|
const Trigger = require("@saltcorn/data/models/trigger");
|
|
12
12
|
|
|
13
|
-
const { text, style } = require("@saltcorn/markup/tags");
|
|
13
|
+
const { text, style, div } = require("@saltcorn/markup/tags");
|
|
14
14
|
const {
|
|
15
15
|
isAdmin,
|
|
16
16
|
error_catcher,
|
|
@@ -70,11 +70,11 @@ router.get(
|
|
|
70
70
|
}
|
|
71
71
|
const isModal = req.headers?.saltcornmodalrequest;
|
|
72
72
|
|
|
73
|
-
const
|
|
73
|
+
const contents0 = await view.run_possibly_on_page(query, req, res);
|
|
74
74
|
const title =
|
|
75
75
|
isModal && view.attributes?.popup_title
|
|
76
76
|
? view.attributes?.popup_title
|
|
77
|
-
: scan_for_page_title(
|
|
77
|
+
: scan_for_page_title(contents0, view.name);
|
|
78
78
|
if (isModal && view.attributes?.popup_width)
|
|
79
79
|
res.set(
|
|
80
80
|
"SaltcornModalWidth",
|
|
@@ -95,9 +95,21 @@ router.get(
|
|
|
95
95
|
name: viewname,
|
|
96
96
|
render_time: ms,
|
|
97
97
|
});
|
|
98
|
-
if (typeof
|
|
99
|
-
res.redirect(
|
|
100
|
-
else
|
|
98
|
+
if (typeof contents0 === "object" && contents0.goto)
|
|
99
|
+
res.redirect(contents0.goto);
|
|
100
|
+
else {
|
|
101
|
+
const qs = "";
|
|
102
|
+
const contents =
|
|
103
|
+
typeof contents0 === "string" && !req.xhr
|
|
104
|
+
? div(
|
|
105
|
+
{
|
|
106
|
+
class: "d-inline",
|
|
107
|
+
"data-sc-embed-viewname": view.name,
|
|
108
|
+
"data-sc-view-source": req.originalUrl,
|
|
109
|
+
},
|
|
110
|
+
contents0
|
|
111
|
+
)
|
|
112
|
+
: contents0;
|
|
101
113
|
res.sendWrap(
|
|
102
114
|
title,
|
|
103
115
|
add_edit_bar({
|
|
@@ -112,6 +124,7 @@ router.get(
|
|
|
112
124
|
table: view.table_id || view.exttable_name,
|
|
113
125
|
})
|
|
114
126
|
);
|
|
127
|
+
}
|
|
115
128
|
})
|
|
116
129
|
);
|
|
117
130
|
|