@saltcorn/server 1.1.0-beta.13 → 1.1.0-beta.15
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 +15 -1
- package/locales/pl.json +19 -2
- package/markup/admin.js +1 -0
- package/package.json +9 -9
- package/public/mermaid.min.js +1077 -792
- package/public/saltcorn-common.js +53 -38
- package/public/saltcorn.js +37 -11
- package/routes/actions.js +937 -4
- package/routes/eventlog.js +36 -0
- package/routes/fields.js +4 -0
- package/routes/tables.js +58 -20
|
@@ -40,6 +40,19 @@ $(window).resize(() => {
|
|
|
40
40
|
setScreenInfoCookie();
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
function get_current_state_url(e) {
|
|
44
|
+
const localizer = e ? $(e).closest("[data-sc-local-state]") : [];
|
|
45
|
+
let $modal = $("#scmodal");
|
|
46
|
+
if (localizer.length) {
|
|
47
|
+
const localState = localizer.attr("data-sc-local-state") || "";
|
|
48
|
+
return localState;
|
|
49
|
+
} else if ($modal.length === 0 || !$modal.hasClass("show"))
|
|
50
|
+
return getIsNode()
|
|
51
|
+
? window.location.href
|
|
52
|
+
: parent.saltcorn.mobileApp.navigation.currentUrl();
|
|
53
|
+
else return $modal.prop("data-modal-state");
|
|
54
|
+
}
|
|
55
|
+
|
|
43
56
|
//avoids hiding in overflow:hidden
|
|
44
57
|
function init_bs5_dropdowns() {
|
|
45
58
|
$("body").on(
|
|
@@ -704,7 +717,7 @@ function doMobileTransforms() {
|
|
|
704
717
|
href: [
|
|
705
718
|
{
|
|
706
719
|
web: "javascript:history.back()",
|
|
707
|
-
mobile: "javascript:parent.goBack()",
|
|
720
|
+
mobile: "javascript:parent.saltcorn.mobileApp.navigation.goBack()",
|
|
708
721
|
},
|
|
709
722
|
{
|
|
710
723
|
web: "javascript:ajax_modal",
|
|
@@ -714,7 +727,7 @@ function doMobileTransforms() {
|
|
|
714
727
|
onclick: [
|
|
715
728
|
{
|
|
716
729
|
web: "history.back()",
|
|
717
|
-
mobile: "parent.goBack()",
|
|
730
|
+
mobile: "parent.saltcorn.mobileApp.navigation.goBack()",
|
|
718
731
|
},
|
|
719
732
|
{
|
|
720
733
|
web: "ajax_modal",
|
|
@@ -823,48 +836,46 @@ function doMobileTransforms() {
|
|
|
823
836
|
});
|
|
824
837
|
|
|
825
838
|
$("[mobile-img-path]").each(async function () {
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
}
|
|
839
|
+
const fileId = $(this).attr("mobile-img-path");
|
|
840
|
+
const base64Encoded =
|
|
841
|
+
await parent.saltcorn.mobileApp.common.loadEncodedFile(fileId);
|
|
842
|
+
this.src = base64Encoded;
|
|
831
843
|
});
|
|
832
844
|
|
|
833
845
|
$("[mobile-bg-img-path]").each(async function () {
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
}
|
|
846
|
+
const fileId = $(this).attr("mobile-bg-img-path");
|
|
847
|
+
if (fileId) {
|
|
848
|
+
const base64Encoded =
|
|
849
|
+
await parent.saltcorn.mobileApp.common.loadEncodedFile(fileId);
|
|
850
|
+
this.style.backgroundImage = `url("${base64Encoded}")`;
|
|
840
851
|
}
|
|
841
852
|
});
|
|
842
853
|
|
|
843
854
|
$("img:not([mobile-img-path]):not([mobile-bg-img-path])").each(
|
|
844
855
|
async function () {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
856
|
+
const jThis = $(this);
|
|
857
|
+
const src = jThis.attr("src");
|
|
858
|
+
if (src?.includes("/files/serve/")) {
|
|
859
|
+
const tokens = src.split("/files/serve/");
|
|
860
|
+
if (tokens.length > 1) {
|
|
861
|
+
const fileId = tokens[1];
|
|
862
|
+
const base64Encoded =
|
|
863
|
+
await parent.saltcorn.mobileApp.common.loadEncodedFile(fileId);
|
|
864
|
+
this.src = base64Encoded;
|
|
865
|
+
}
|
|
866
|
+
} else if (src?.includes("/files/resize/")) {
|
|
867
|
+
const tokens = src.split("/files/resize/");
|
|
868
|
+
if (tokens.length > 1) {
|
|
869
|
+
const idAndDims = tokens[1].split("/");
|
|
870
|
+
const width = idAndDims[0];
|
|
871
|
+
const height = idAndDims.length > 2 ? idAndDims[1] : undefined;
|
|
872
|
+
const fileId = idAndDims[idAndDims.length - 1];
|
|
873
|
+
const style = { width: `${width || 50}px` };
|
|
874
|
+
if (height > 0) style.height = `${height}px`;
|
|
875
|
+
const base64Encoded =
|
|
876
|
+
await parent.saltcorn.mobileApp.common.loadEncodedFile(fileId);
|
|
877
|
+
this.src = base64Encoded;
|
|
878
|
+
jThis.css(style);
|
|
868
879
|
}
|
|
869
880
|
}
|
|
870
881
|
}
|
|
@@ -1569,14 +1580,15 @@ async function common_done(res, viewnameOrElem, isWeb = true) {
|
|
|
1569
1580
|
});
|
|
1570
1581
|
}
|
|
1571
1582
|
if (res.eval_js) await handle(res.eval_js, eval_it);
|
|
1583
|
+
/// TODO got and resume_workflow - use localStorage
|
|
1572
1584
|
if (res.goto) {
|
|
1573
1585
|
if (!isWeb) {
|
|
1574
1586
|
const next = new URL(res.goto, "http://localhost");
|
|
1575
1587
|
const pathname = next.pathname;
|
|
1576
1588
|
if (pathname.startsWith("/view/") || pathname.startsWith("/page/")) {
|
|
1577
1589
|
const route = `get${pathname}${next.search ? "?" + next.search : ""}`;
|
|
1578
|
-
await parent.handleRoute(route);
|
|
1579
|
-
} else parent.cordova.InAppBrowser.open(res.goto, "_system");
|
|
1590
|
+
await parent.saltcorn.mobileApp.navigation.handleRoute(route);
|
|
1591
|
+
} else parent.cordova.InAppBrowser.open(res.goto, "_system"); // TODO
|
|
1580
1592
|
} else if (res.target === "_blank") window.open(res.goto, "_blank").focus();
|
|
1581
1593
|
else {
|
|
1582
1594
|
const prev = new URL(window.location.href);
|
|
@@ -1591,6 +1603,9 @@ async function common_done(res, viewnameOrElem, isWeb = true) {
|
|
|
1591
1603
|
location.reload();
|
|
1592
1604
|
}
|
|
1593
1605
|
}
|
|
1606
|
+
if (res.resume_workflow) {
|
|
1607
|
+
ajax_post_json(`/actions/resume-workflow/${res.resume_workflow}`, {});
|
|
1608
|
+
}
|
|
1594
1609
|
if (res.reload_page) {
|
|
1595
1610
|
(isWeb ? location : parent).reload(); //TODO notify to cookie if reload or goto
|
|
1596
1611
|
}
|
package/public/saltcorn.js
CHANGED
|
@@ -84,17 +84,6 @@ function removeQueryStringParameter(uri1, key) {
|
|
|
84
84
|
return uri + hash;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
function get_current_state_url(e) {
|
|
88
|
-
const localizer = e ? $(e).closest("[data-sc-local-state]") : [];
|
|
89
|
-
let $modal = $("#scmodal");
|
|
90
|
-
if (localizer.length) {
|
|
91
|
-
const localState = localizer.attr("data-sc-local-state") || "";
|
|
92
|
-
return localState;
|
|
93
|
-
} else if ($modal.length === 0 || !$modal.hasClass("show"))
|
|
94
|
-
return window.location.href;
|
|
95
|
-
else return $modal.prop("data-modal-state");
|
|
96
|
-
}
|
|
97
|
-
|
|
98
87
|
function select_id(id, e) {
|
|
99
88
|
pjax_to(updateQueryStringParameter(get_current_state_url(e), "id", id), e);
|
|
100
89
|
}
|
|
@@ -423,6 +412,27 @@ function saveAndContinueAsync(e) {
|
|
|
423
412
|
});
|
|
424
413
|
}
|
|
425
414
|
|
|
415
|
+
function saveAndContinueIfValid(e, k, event) {
|
|
416
|
+
//wait for applyShowIf
|
|
417
|
+
setTimeout(() => {
|
|
418
|
+
if (
|
|
419
|
+
event &&
|
|
420
|
+
event.target &&
|
|
421
|
+
event.target.classList &&
|
|
422
|
+
event.target.classList.contains("no-form-change")
|
|
423
|
+
)
|
|
424
|
+
return;
|
|
425
|
+
var form = $(e).closest("form");
|
|
426
|
+
|
|
427
|
+
if (form[0].checkValidity?.() === false) {
|
|
428
|
+
form[0].reportValidity();
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
saveAndContinue(e, k, event);
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
426
436
|
function saveAndContinue(e, k, event) {
|
|
427
437
|
if (
|
|
428
438
|
event &&
|
|
@@ -432,6 +442,7 @@ function saveAndContinue(e, k, event) {
|
|
|
432
442
|
)
|
|
433
443
|
return;
|
|
434
444
|
var form = $(e).closest("form");
|
|
445
|
+
|
|
435
446
|
let focusedEl = null;
|
|
436
447
|
if (!event || !event.srcElement) {
|
|
437
448
|
const el = form.find("select[sc-received-focus]")[0];
|
|
@@ -1197,6 +1208,21 @@ function check_unsaved_form(event, script_tag) {
|
|
|
1197
1208
|
event.returnValue = true;
|
|
1198
1209
|
}
|
|
1199
1210
|
}
|
|
1211
|
+
function check_delete_unsaved(tablename, script_tag) {
|
|
1212
|
+
const form = $(script_tag).parent().find("form");
|
|
1213
|
+
if (form.length && !form.attr("data-form-changed")) {
|
|
1214
|
+
//delete row
|
|
1215
|
+
const rec = get_form_record(form);
|
|
1216
|
+
|
|
1217
|
+
$.ajax({
|
|
1218
|
+
url: `/api/${tablename}/${rec.id}`,
|
|
1219
|
+
type: "DELETE",
|
|
1220
|
+
headers: {
|
|
1221
|
+
"CSRF-Token": _sc_globalCsrf,
|
|
1222
|
+
},
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1200
1226
|
|
|
1201
1227
|
(() => {
|
|
1202
1228
|
const e = document.querySelector("[data-sidebar-toggler]");
|