@saltcorn/server 0.9.1-beta.14 → 0.9.1-beta.16
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/markup/admin.js +3 -1
- package/package.json +8 -8
- package/public/saltcorn-common.js +16 -11
- package/public/saltcorn.css +4 -0
- package/public/saltcorn.js +42 -3
- package/routes/menu.js +11 -2
package/markup/admin.js
CHANGED
|
@@ -79,9 +79,11 @@ const add_edit_bar = ({
|
|
|
79
79
|
table,
|
|
80
80
|
cfgUrl,
|
|
81
81
|
}) => {
|
|
82
|
+
if (req && req.headers.localizedstate)
|
|
83
|
+
return { above: [contents], noWrapTop: true };
|
|
82
84
|
if (role > 1 && req && req.xhr) return { above: [contents] }; //make sure not put in card
|
|
83
85
|
if (role > 1) return contents;
|
|
84
|
-
|
|
86
|
+
|
|
85
87
|
let viewSpec = "";
|
|
86
88
|
if (viewtemplate) viewSpec = viewtemplate;
|
|
87
89
|
if (table) {
|
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.16",
|
|
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.16",
|
|
11
|
+
"@saltcorn/builder": "0.9.1-beta.16",
|
|
12
|
+
"@saltcorn/data": "0.9.1-beta.16",
|
|
13
|
+
"@saltcorn/admin-models": "0.9.1-beta.16",
|
|
14
|
+
"@saltcorn/filemanager": "0.9.1-beta.16",
|
|
15
|
+
"@saltcorn/markup": "0.9.1-beta.16",
|
|
16
|
+
"@saltcorn/sbadmin2": "0.9.1-beta.16",
|
|
17
17
|
"@socket.io/cluster-adapter": "^0.2.1",
|
|
18
18
|
"@socket.io/sticky": "^1.0.1",
|
|
19
19
|
"adm-zip": "0.5.10",
|
|
@@ -1049,7 +1049,10 @@ function notifyAlert(note, spin) {
|
|
|
1049
1049
|
type = note.type;
|
|
1050
1050
|
}
|
|
1051
1051
|
const { id, html } = buildToast(txt, type, spin);
|
|
1052
|
-
$("#
|
|
1052
|
+
let $modal = $("#scmodal");
|
|
1053
|
+
if ($modal.length && $modal.hasClass("show"))
|
|
1054
|
+
$("#modal-toasts-area").append(html);
|
|
1055
|
+
else $("#toasts-area").append(html);
|
|
1053
1056
|
if (type === "success") {
|
|
1054
1057
|
setTimeout(() => {
|
|
1055
1058
|
$(`#${id}`).removeClass("show");
|
|
@@ -1085,19 +1088,21 @@ function common_done(res, viewname, isWeb = true) {
|
|
|
1085
1088
|
if (Array.isArray(element)) for (const current of element) fn(current);
|
|
1086
1089
|
else fn(element);
|
|
1087
1090
|
};
|
|
1091
|
+
const eval_it = (s) => {
|
|
1092
|
+
if (res.row && res.field_names) {
|
|
1093
|
+
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);
|
|
1096
|
+
} else {
|
|
1097
|
+
const f = new Function(`viewname`, s);
|
|
1098
|
+
const evalres = f(viewname);
|
|
1099
|
+
if (evalres) common_done(evalres, viewname, isWeb);
|
|
1100
|
+
}
|
|
1101
|
+
};
|
|
1088
1102
|
if (res.notify) handle(res.notify, notifyAlert);
|
|
1089
1103
|
if (res.error)
|
|
1090
1104
|
handle(res.error, (text) => notifyAlert({ type: "danger", text: text }));
|
|
1091
|
-
|
|
1092
|
-
if (res.eval_js && res.row && res.field_names) {
|
|
1093
|
-
const f = new Function(`viewname, row, {${res.field_names}}`, res.eval_js);
|
|
1094
|
-
const evalres = f(viewname, res.row, res.row);
|
|
1095
|
-
if (evalres) common_done(evalres, viewname, isWeb);
|
|
1096
|
-
} else if (res.eval_js) {
|
|
1097
|
-
const f = new Function(`viewname`, res.eval_js);
|
|
1098
|
-
const evalres = f(viewname);
|
|
1099
|
-
if (evalres) common_done(evalres, viewname, isWeb);
|
|
1100
|
-
}
|
|
1105
|
+
if (res.eval_js) handle(res.eval_js, eval_it);
|
|
1101
1106
|
|
|
1102
1107
|
if (res.reload_page) {
|
|
1103
1108
|
(isWeb ? location : parent).reload(); //TODO notify to cookie if reload or goto
|
package/public/saltcorn.css
CHANGED
package/public/saltcorn.js
CHANGED
|
@@ -135,6 +135,29 @@ $(function () {
|
|
|
135
135
|
});
|
|
136
136
|
});
|
|
137
137
|
|
|
138
|
+
function reload_embedded_view(viewname) {
|
|
139
|
+
$(`[data-sc-embed-viewname="${viewname}"]`).each(function () {
|
|
140
|
+
const $e = $(this);
|
|
141
|
+
const url =
|
|
142
|
+
$e.attr("data-sc-local-state") || $e.attr("data-sc-view-source");
|
|
143
|
+
if (!url) return;
|
|
144
|
+
const headers = {
|
|
145
|
+
pjaxpageload: "true",
|
|
146
|
+
localizedstate: "true", //no admin bar
|
|
147
|
+
};
|
|
148
|
+
$.ajax(url, {
|
|
149
|
+
headers,
|
|
150
|
+
success: function (res, textStatus, request) {
|
|
151
|
+
$e.html(res);
|
|
152
|
+
initialize_page();
|
|
153
|
+
},
|
|
154
|
+
error: function (res) {
|
|
155
|
+
notifyAlert({ type: "danger", text: res.responseText });
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
138
161
|
function pjax_to(href, e) {
|
|
139
162
|
let $modal = $("#scmodal");
|
|
140
163
|
const inModal = $modal.length && $modal.hasClass("show");
|
|
@@ -281,6 +304,13 @@ function ensure_modal_exists_and_closed() {
|
|
|
281
304
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
|
|
282
305
|
</button>
|
|
283
306
|
</div>
|
|
307
|
+
<div
|
|
308
|
+
id="modal-toasts-area"
|
|
309
|
+
class="toast-container position-fixed top-0 end-0 p-2 "
|
|
310
|
+
style: "z-index: 7000;"
|
|
311
|
+
aria-live="polite"
|
|
312
|
+
aria-atomic="true">
|
|
313
|
+
</div>
|
|
284
314
|
</div>
|
|
285
315
|
<div class="modal-body">
|
|
286
316
|
<p>Modal body text goes here.</p>
|
|
@@ -292,9 +322,9 @@ function ensure_modal_exists_and_closed() {
|
|
|
292
322
|
// remove reload handler added by edit, for when we have popup link
|
|
293
323
|
// in autosave edit in popup
|
|
294
324
|
$("#scmodal").off("hidden.bs.modal");
|
|
295
|
-
|
|
296
325
|
close_saltcorn_modal();
|
|
297
326
|
}
|
|
327
|
+
$("#modal-toasts-area").empty();
|
|
298
328
|
}
|
|
299
329
|
|
|
300
330
|
function expand_thumbnail(img_id, filename) {
|
|
@@ -308,8 +338,10 @@ function expand_thumbnail(img_id, filename) {
|
|
|
308
338
|
|
|
309
339
|
function ajax_modal(url, opts = {}) {
|
|
310
340
|
ensure_modal_exists_and_closed();
|
|
341
|
+
$("#scmodal").removeClass("no-submit-reload");
|
|
342
|
+
$("#scmodal").attr("data-on-close-reload-view", opts.reload_view || null);
|
|
343
|
+
|
|
311
344
|
if (opts.submitReload === false) $("#scmodal").addClass("no-submit-reload");
|
|
312
|
-
else $("#scmodal").removeClass("no-submit-reload");
|
|
313
345
|
$.ajax(url, {
|
|
314
346
|
headers: {
|
|
315
347
|
SaltcornModalRequest: "true",
|
|
@@ -506,8 +538,15 @@ function ajaxSubmitForm(e) {
|
|
|
506
538
|
contentType: false,
|
|
507
539
|
success: function (res) {
|
|
508
540
|
var no_reload = $("#scmodal").hasClass("no-submit-reload");
|
|
541
|
+
const on_close_reload_view = $("#scmodal").attr(
|
|
542
|
+
"data-on-close-reload-view"
|
|
543
|
+
);
|
|
509
544
|
$("#scmodal").modal("hide");
|
|
510
|
-
if (
|
|
545
|
+
if (on_close_reload_view) {
|
|
546
|
+
const viewE = $(`[data-sc-embed-viewname=${on_close_reload_view}]`);
|
|
547
|
+
if (viewE.length) reload_embedded_view(on_close_reload_view);
|
|
548
|
+
else location.reload();
|
|
549
|
+
} else if (!no_reload) location.reload();
|
|
511
550
|
else common_done(res, form.attr("data-viewname"));
|
|
512
551
|
},
|
|
513
552
|
error: function (request) {
|
package/routes/menu.js
CHANGED
|
@@ -307,7 +307,16 @@ const menuForm = async (req) => {
|
|
|
307
307
|
name: "location",
|
|
308
308
|
label: req.__("Location"),
|
|
309
309
|
showIf: {
|
|
310
|
-
type: [
|
|
310
|
+
type: [
|
|
311
|
+
"View",
|
|
312
|
+
"Page",
|
|
313
|
+
"Link",
|
|
314
|
+
"Header",
|
|
315
|
+
"Dynamic",
|
|
316
|
+
"Search",
|
|
317
|
+
"Separator",
|
|
318
|
+
"Action",
|
|
319
|
+
],
|
|
311
320
|
},
|
|
312
321
|
sublabel: req.__("Not all themes support all locations"),
|
|
313
322
|
class: "item-menu",
|
|
@@ -317,7 +326,7 @@ const menuForm = async (req) => {
|
|
|
317
326
|
//default: "Standard",
|
|
318
327
|
attributes: {
|
|
319
328
|
inline: true,
|
|
320
|
-
options: "Standard, Mobile Bottom",
|
|
329
|
+
options: "Standard, Mobile Bottom, Secondary Menu",
|
|
321
330
|
},
|
|
322
331
|
},
|
|
323
332
|
],
|