@saltcorn/mobile-app 0.9.6-beta.2 → 0.9.6-beta.20
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/package.json +1 -1
- package/www/index.html +1 -0
- package/www/js/routes/view.js +23 -3
- package/www/js/utils/global_utils.js +10 -0
- package/www/js/utils/iframe_view_utils.js +56 -34
package/package.json
CHANGED
package/www/index.html
CHANGED
package/www/js/routes/view.js
CHANGED
|
@@ -138,9 +138,9 @@ const getView = async (context) => {
|
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
state.queriesCache = {};
|
|
141
|
-
let
|
|
141
|
+
let contents0 = null;
|
|
142
142
|
try {
|
|
143
|
-
|
|
143
|
+
contents0 = await view.run_possibly_on_page(
|
|
144
144
|
query,
|
|
145
145
|
req,
|
|
146
146
|
res,
|
|
@@ -157,5 +157,25 @@ const getView = async (context) => {
|
|
|
157
157
|
context,
|
|
158
158
|
req
|
|
159
159
|
);
|
|
160
|
-
else
|
|
160
|
+
else {
|
|
161
|
+
const contents =
|
|
162
|
+
typeof contents0 === "string"
|
|
163
|
+
? saltcorn.markup.div(
|
|
164
|
+
{
|
|
165
|
+
class: "d-inline",
|
|
166
|
+
"data-sc-embed-viewname": view.name,
|
|
167
|
+
"data-sc-view-source": `/view/${context.params.viewname}${
|
|
168
|
+
context.query
|
|
169
|
+
? context.query.startsWith("?")
|
|
170
|
+
? context.query
|
|
171
|
+
: `?${context.query}`
|
|
172
|
+
: ""
|
|
173
|
+
}`,
|
|
174
|
+
},
|
|
175
|
+
contents0
|
|
176
|
+
)
|
|
177
|
+
: contents0;
|
|
178
|
+
|
|
179
|
+
return wrapContents(contents, viewname, context, req);
|
|
180
|
+
}
|
|
161
181
|
};
|
|
@@ -260,6 +260,15 @@ async function replaceIframeInnerContent(content) {
|
|
|
260
260
|
iframe.contentWindow.initialize_page();
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
function clearContentDiv() {
|
|
264
|
+
const iframe = document.getElementById("content-iframe");
|
|
265
|
+
if (iframe) {
|
|
266
|
+
const iframeDocument = iframe.contentWindow.document;
|
|
267
|
+
const innerContentDiv = iframeDocument.getElementById("page-inner-content");
|
|
268
|
+
if (innerContentDiv) innerContentDiv.innerHTML = "";
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
263
272
|
async function gotoEntryView() {
|
|
264
273
|
const mobileConfig = saltcorn.data.state.getState().mobileConfig;
|
|
265
274
|
try {
|
|
@@ -309,6 +318,7 @@ async function handleRoute(route, query, files, data) {
|
|
|
309
318
|
const mobileConfig = saltcorn.data.state.getState().mobileConfig;
|
|
310
319
|
let routeAdded = false;
|
|
311
320
|
try {
|
|
321
|
+
clearContentDiv();
|
|
312
322
|
if (
|
|
313
323
|
mobileConfig.networkState === "none" &&
|
|
314
324
|
mobileConfig.allowOfflineMode &&
|
|
@@ -26,6 +26,7 @@ async function execLink(url, linkSrc) {
|
|
|
26
26
|
parent.cordova.InAppBrowser.open(url, "_system");
|
|
27
27
|
} else
|
|
28
28
|
try {
|
|
29
|
+
if (document.getElementById("scspinner")) return;
|
|
29
30
|
showLoadSpinner();
|
|
30
31
|
if (url.startsWith("javascript:")) eval(url.substring(11));
|
|
31
32
|
else {
|
|
@@ -47,6 +48,7 @@ async function runUrl(url, method = "get") {
|
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
async function execNavbarLink(url) {
|
|
51
|
+
if (document.getElementById("scspinner")) return;
|
|
50
52
|
$(".navbar-toggler").click();
|
|
51
53
|
if (typeof KTDrawer === "function") {
|
|
52
54
|
const aside = $("#kt_aside")[0];
|
|
@@ -572,7 +574,7 @@ async function local_post(url, args) {
|
|
|
572
574
|
data: args,
|
|
573
575
|
});
|
|
574
576
|
if (result.redirect) await parent.handleRoute(result.redirect);
|
|
575
|
-
else common_done(result, "", false);
|
|
577
|
+
else await common_done(result, "", false);
|
|
576
578
|
} catch (error) {
|
|
577
579
|
parent.errorAlert(error);
|
|
578
580
|
} finally {
|
|
@@ -590,7 +592,7 @@ async function local_post_json(url, data, cb) {
|
|
|
590
592
|
});
|
|
591
593
|
if (result.server_eval) await evalServerCode(url);
|
|
592
594
|
if (result.redirect) await parent.handleRoute(result.redirect);
|
|
593
|
-
else common_done(result, "", false);
|
|
595
|
+
else await common_done(result, "", false);
|
|
594
596
|
if (cb?.success) cb.success(result);
|
|
595
597
|
} catch (error) {
|
|
596
598
|
parent.errorAlert(error);
|
|
@@ -700,7 +702,13 @@ async function clear_state() {
|
|
|
700
702
|
}
|
|
701
703
|
}
|
|
702
704
|
|
|
703
|
-
async function view_post(
|
|
705
|
+
async function view_post(viewnameOrElem, route, data, onDone, sendState) {
|
|
706
|
+
const viewname =
|
|
707
|
+
typeof viewnameOrElem === "string"
|
|
708
|
+
? viewnameOrElem
|
|
709
|
+
: $(viewnameOrElem)
|
|
710
|
+
.closest("[data-sc-embed-viewname]")
|
|
711
|
+
.attr("data-sc-embed-viewname");
|
|
704
712
|
const buildQuery = () => {
|
|
705
713
|
const query = parent.currentQuery();
|
|
706
714
|
return query ? `?${query}` : "";
|
|
@@ -731,8 +739,8 @@ async function view_post(viewname, route, data, onDone, sendState) {
|
|
|
731
739
|
|
|
732
740
|
if (!respData)
|
|
733
741
|
throw new Error(`The response of '${viewname}/${route}' is ${respData}`);
|
|
734
|
-
if (onDone) onDone(respData);
|
|
735
|
-
common_done(respData, viewname, false);
|
|
742
|
+
if (onDone) await onDone(respData);
|
|
743
|
+
await common_done(respData, viewname, false);
|
|
736
744
|
} catch (error) {
|
|
737
745
|
parent.errorAlert(error);
|
|
738
746
|
} finally {
|
|
@@ -892,43 +900,57 @@ async function deleteOfflineData(noFeedback) {
|
|
|
892
900
|
}
|
|
893
901
|
|
|
894
902
|
function showLoadSpinner() {
|
|
895
|
-
if (!parent.isHtmlFile()
|
|
896
|
-
$("
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
style="position: fixed;
|
|
900
|
-
top: 50%;
|
|
901
|
-
left: 50%;
|
|
902
|
-
transform: translate(-50%, -50%);
|
|
903
|
-
z-index: 9999;"
|
|
904
|
-
>
|
|
903
|
+
if (!parent.isHtmlFile()) {
|
|
904
|
+
const spinner = $("#scspinner");
|
|
905
|
+
if (spinner.length === 0) {
|
|
906
|
+
$("body").append(`
|
|
905
907
|
<div
|
|
906
|
-
|
|
907
|
-
|
|
908
|
+
id="scspinner"
|
|
909
|
+
style="position: fixed;
|
|
908
910
|
top: 50%;
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
911
|
+
left: 50%;
|
|
912
|
+
transform: translate(-50%, -50%);
|
|
913
|
+
z-index: 9999;"
|
|
914
|
+
spinner-count="1"
|
|
912
915
|
>
|
|
913
|
-
<
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
style="margin-left: -125px"
|
|
921
|
-
id="scspinner-text-id"
|
|
922
|
-
class="d-none fs-5 fw-bold bg-secondary text-white p-1 rounded"
|
|
916
|
+
<div
|
|
917
|
+
style="position: absolute;
|
|
918
|
+
left: 50%;
|
|
919
|
+
top: 50%;
|
|
920
|
+
height: 60px;
|
|
921
|
+
width: 250px;
|
|
922
|
+
margin: 0px auto;"
|
|
923
923
|
>
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
924
|
+
<span
|
|
925
|
+
class="spinner-border d-block"
|
|
926
|
+
role="status"
|
|
927
|
+
>
|
|
928
|
+
<span class="visually-hidden">Loading...</span>
|
|
929
|
+
</span>
|
|
930
|
+
<span
|
|
931
|
+
style="margin-left: -125px"
|
|
932
|
+
id="scspinner-text-id"
|
|
933
|
+
class="d-none fs-5 fw-bold bg-secondary text-white p-1 rounded"
|
|
934
|
+
>
|
|
935
|
+
</span>
|
|
936
|
+
</div>
|
|
937
|
+
</div>`);
|
|
938
|
+
} else {
|
|
939
|
+
const count = parseInt(spinner.attr("spinner-count")) + 1;
|
|
940
|
+
spinner.attr("spinner-count", count);
|
|
941
|
+
}
|
|
927
942
|
}
|
|
928
943
|
}
|
|
929
944
|
|
|
930
945
|
function removeLoadSpinner() {
|
|
931
|
-
if (!parent.isHtmlFile())
|
|
946
|
+
if (!parent.isHtmlFile()) {
|
|
947
|
+
const spinner = $("#scspinner");
|
|
948
|
+
if (spinner.length > 0) {
|
|
949
|
+
const count = parseInt(spinner.attr("spinner-count")) - 1;
|
|
950
|
+
if (count === 0) spinner.remove();
|
|
951
|
+
else spinner.attr("spinner-count", count);
|
|
952
|
+
}
|
|
953
|
+
}
|
|
932
954
|
}
|
|
933
955
|
|
|
934
956
|
/**
|