@saltcorn/mobile-app 1.7.0-alpha.1 → 1.7.0-beta.1
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/js/iframe_view_utils.js +66 -1
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*eslint-env browser*/
|
|
2
|
-
/*global $, KTDrawer, reload_embedded_view, submitWithEmptyAction, is_paging_param, bootstrap, common_done, unique_field_from_rows, inline_submit_success, get_current_state_url, initialize_page, reset_spinners */
|
|
2
|
+
/*global $, KTDrawer, reload_embedded_view, submitWithEmptyAction, is_paging_param, bootstrap, common_done, unique_field_from_rows, inline_submit_success, get_current_state_url, initialize_page, reset_spinners, apply_showif_fetching_urls */
|
|
3
3
|
|
|
4
4
|
// Tapping a javascript: link silently does nothing on iOS, so we run the
|
|
5
5
|
// code ourselves instead of relying on the link to do it.
|
|
@@ -227,6 +227,37 @@ function saveAndContinueAsync(e, action) {
|
|
|
227
227
|
});
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
// not currently generated by any server markup, kept for parity with web
|
|
231
|
+
function saveAndContinueIfValid(e, action, event) {
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
if (
|
|
234
|
+
event &&
|
|
235
|
+
event.target &&
|
|
236
|
+
event.target.classList &&
|
|
237
|
+
event.target.classList.contains("no-form-change")
|
|
238
|
+
)
|
|
239
|
+
return;
|
|
240
|
+
const form = $(e).closest("form");
|
|
241
|
+
if (form[0].checkValidity?.() === false) {
|
|
242
|
+
form[0].reportValidity();
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
saveAndContinue(e, action);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// auto_save's onChange - was undefined on mobile, silently dropping every edit
|
|
250
|
+
function saveAndContinueDelayed(e, action, event, retries = 1) {
|
|
251
|
+
setTimeout(() => {
|
|
252
|
+
if (apply_showif_fetching_urls.size > 0 && retries < 5) {
|
|
253
|
+
setTimeout(() => {
|
|
254
|
+
saveAndContinueDelayed(e, action, event, retries + 1);
|
|
255
|
+
}, 200);
|
|
256
|
+
} else saveAndContinue(e, action);
|
|
257
|
+
});
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
|
|
230
261
|
async function saveAndContinue(e, action, k) {
|
|
231
262
|
try {
|
|
232
263
|
showLoadSpinner();
|
|
@@ -245,11 +276,45 @@ async function saveAndContinue(e, action, k) {
|
|
|
245
276
|
}
|
|
246
277
|
if (k) await k();
|
|
247
278
|
// TODO ch error (request.responseText?)
|
|
279
|
+
return res;
|
|
248
280
|
} finally {
|
|
249
281
|
removeLoadSpinner();
|
|
250
282
|
}
|
|
251
283
|
}
|
|
252
284
|
|
|
285
|
+
// SubmitWithAjax - undefined on mobile; follows the redirect saveAndContinue skips
|
|
286
|
+
async function submitWithAjax(e) {
|
|
287
|
+
try {
|
|
288
|
+
const form = $(e).closest("form");
|
|
289
|
+
// action attr is always void(0) on mobile - use data-viewname instead
|
|
290
|
+
const res = await saveAndContinue(e, `/view/${form.attr("data-viewname")}`);
|
|
291
|
+
if (res?.error)
|
|
292
|
+
parent.saltcorn.mobileApp.common.showToasts([
|
|
293
|
+
{ type: "error", msg: res.error },
|
|
294
|
+
]);
|
|
295
|
+
const dest = res?.url_when_done || res?.redirect;
|
|
296
|
+
if (dest) {
|
|
297
|
+
const { path, query } =
|
|
298
|
+
parent.saltcorn.mobileApp.navigation.splitPathQuery(dest);
|
|
299
|
+
// "Back to referer" round-trips a get/... route through the server's
|
|
300
|
+
// sanitizer, which adds a leading "/" - strip it, don't double the prefix
|
|
301
|
+
const stripped = path.replace(/^\//, "");
|
|
302
|
+
const route =
|
|
303
|
+
stripped.startsWith("get/") || stripped.startsWith("post/")
|
|
304
|
+
? stripped
|
|
305
|
+
: path.length > 1
|
|
306
|
+
? `get${path}`
|
|
307
|
+
: path;
|
|
308
|
+
await parent.saltcorn.mobileApp.navigation.handleRoute(
|
|
309
|
+
route,
|
|
310
|
+
query
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
} catch (error) {
|
|
314
|
+
parent.saltcorn.mobileApp.common.errorAlert(error);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
253
318
|
async function login(e, entryPoint, isSignup) {
|
|
254
319
|
try {
|
|
255
320
|
showLoadSpinner();
|