@saltcorn/mobile-app 1.3.1-beta.1 → 1.3.1-beta.11
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/src/init.js +6 -0
- package/src/routing/routes/view.js +46 -39
- package/src/routing/utils.js +1 -0
- package/www/index.html +0 -3
package/package.json
CHANGED
package/src/init.js
CHANGED
|
@@ -30,6 +30,7 @@ import i18nextSprintfPostProcessor from "i18next-sprintf-postprocessor";
|
|
|
30
30
|
import { jwtDecode } from "jwt-decode";
|
|
31
31
|
|
|
32
32
|
import { Network } from "@capacitor/network";
|
|
33
|
+
import { App } from '@capacitor/app';
|
|
33
34
|
|
|
34
35
|
import { defineCustomElements } from "jeep-sqlite/loader";
|
|
35
36
|
|
|
@@ -357,6 +358,11 @@ export async function init(mobileConfig) {
|
|
|
357
358
|
document.body.appendChild(jeepSqlite);
|
|
358
359
|
await jeepSqlite.componentOnReady();
|
|
359
360
|
}
|
|
361
|
+
|
|
362
|
+
App.addListener('backButton', async ({ canGoBack }) => {
|
|
363
|
+
await saltcorn.mobileApp.navigation.goBack(1, true);
|
|
364
|
+
});
|
|
365
|
+
|
|
360
366
|
const lastLocation = takeLastLocation();
|
|
361
367
|
document.addEventListener("resume", onResume, false);
|
|
362
368
|
await addScripts(mobileConfig.version_tag);
|
|
@@ -148,7 +148,6 @@ export const getView = async (context) => {
|
|
|
148
148
|
const { viewname } = context.params;
|
|
149
149
|
const view = saltcorn.data.models.View.findOne({ name: viewname });
|
|
150
150
|
if (!view) throw new Error(req.__("No such view: %s", viewname));
|
|
151
|
-
const res = new MobileResponse();
|
|
152
151
|
if (
|
|
153
152
|
state.mobileConfig.user.role_id > view.min_role &&
|
|
154
153
|
!(await view.authorise_get({ query, req, ...view }))
|
|
@@ -158,45 +157,53 @@ export const getView = async (context) => {
|
|
|
158
157
|
req.__("Not authorized") + additionalInfos
|
|
159
158
|
);
|
|
160
159
|
}
|
|
161
|
-
state.queriesCache = {};
|
|
162
160
|
let contents0 = null;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
161
|
+
if (!view.renderLocally()) {
|
|
162
|
+
const response = await apiCall({
|
|
163
|
+
method: "GET",
|
|
164
|
+
path: `/view/${encodeURIComponent(viewname)}${context.query ? `?${context.query}` : ""}`,
|
|
165
|
+
});
|
|
166
|
+
const data = response.data;
|
|
167
|
+
contents0 = data;
|
|
168
|
+
} else {
|
|
169
|
+
const res = new MobileResponse();
|
|
170
|
+
state.queriesCache = {};
|
|
171
|
+
try {
|
|
172
|
+
contents0 = await view.run_possibly_on_page(
|
|
173
|
+
query,
|
|
174
|
+
req,
|
|
175
|
+
res,
|
|
176
|
+
view.isRemoteTable()
|
|
177
|
+
);
|
|
178
|
+
} finally {
|
|
179
|
+
state.queriesCache = null;
|
|
180
|
+
}
|
|
181
|
+
const wrapped = res.getWrapHtml();
|
|
182
|
+
if (wrapped)
|
|
183
|
+
return await wrapContents(
|
|
184
|
+
wrapped,
|
|
185
|
+
res.getWrapViewName() || "viewname",
|
|
186
|
+
context,
|
|
187
|
+
req
|
|
188
|
+
);
|
|
172
189
|
}
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
? context.query.startsWith("?")
|
|
191
|
-
? context.query
|
|
192
|
-
: `?${context.query}`
|
|
193
|
-
: ""
|
|
194
|
-
}`,
|
|
195
|
-
},
|
|
196
|
-
contents0
|
|
197
|
-
)
|
|
198
|
-
: contents0;
|
|
190
|
+
const contents =
|
|
191
|
+
typeof contents0 === "string"
|
|
192
|
+
? saltcorn.markup.div(
|
|
193
|
+
{
|
|
194
|
+
class: "d-inline",
|
|
195
|
+
"data-sc-embed-viewname": view.name,
|
|
196
|
+
"data-sc-view-source": `/view/${context.params.viewname}${
|
|
197
|
+
context.query
|
|
198
|
+
? context.query.startsWith("?")
|
|
199
|
+
? context.query
|
|
200
|
+
: `?${context.query}`
|
|
201
|
+
: ""
|
|
202
|
+
}`,
|
|
203
|
+
},
|
|
204
|
+
contents0
|
|
205
|
+
)
|
|
206
|
+
: contents0;
|
|
199
207
|
|
|
200
|
-
|
|
201
|
-
}
|
|
208
|
+
return await wrapContents(contents, viewname, context, req);
|
|
202
209
|
};
|
package/src/routing/utils.js
CHANGED
|
@@ -11,6 +11,7 @@ export const getHeaders = () => {
|
|
|
11
11
|
{ css: `static_assets/${versionTag}/saltcorn.css` },
|
|
12
12
|
{ script: `static_assets/${versionTag}/saltcorn-common.js` },
|
|
13
13
|
{ script: `static_assets/${versionTag}/dayjs.min.js` },
|
|
14
|
+
{ script: `static_assets/${versionTag}/socket.io.min.js` },
|
|
14
15
|
{ script: "js/iframe_view_utils.js" },
|
|
15
16
|
];
|
|
16
17
|
|
package/www/index.html
CHANGED
|
@@ -20,9 +20,6 @@
|
|
|
20
20
|
document.addEventListener("deviceready", () => {
|
|
21
21
|
saltcorn.mobileApp.init(_sc_mobile_config);
|
|
22
22
|
});
|
|
23
|
-
document.addEventListener("backbutton", async () => {
|
|
24
|
-
await saltcorn.mobileApp.navigation.goBack(1, true);
|
|
25
|
-
});
|
|
26
23
|
} else {
|
|
27
24
|
saltcorn.mobileApp.init(_sc_mobile_config);
|
|
28
25
|
}
|