@axelor/aos-mobile-core 9.1.7 → 9.1.9
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/android/build.gradle +24 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/axelor/aosmobile/core/AosMobileCorePackage.java +40 -0
- package/android/src/main/java/com/axelor/aosmobile/core/ErrorFeedbackModule.java +55 -0
- package/lib/apiProviders/File/AopFileApi.js +11 -3
- package/lib/apiProviders/File/AopFileApi.js.map +1 -1
- package/lib/apiProviders/File/utils.js +8 -3
- package/lib/apiProviders/File/utils.js.map +1 -1
- package/lib/apiProviders/Standard/requests.helper.js +2 -2
- package/lib/apiProviders/Standard/requests.helper.js.map +1 -1
- package/lib/apiProviders/index.d.ts +7 -7
- package/lib/apiProviders/index.js.map +1 -1
- package/lib/app/ContextedApplication.js +2 -0
- package/lib/app/ContextedApplication.js.map +1 -1
- package/lib/components/external/WebView/WebView.d.ts +5 -1
- package/lib/components/external/WebView/WebView.js +14 -5
- package/lib/components/external/WebView/WebView.js.map +1 -1
- package/lib/components/organisms/DateInput/DateInput.js +5 -2
- package/lib/components/organisms/DateInput/DateInput.js.map +1 -1
- package/lib/components/pages/CustomFieldForm/CustomFieldForm.d.ts +2 -2
- package/lib/components/pages/CustomFieldForm/CustomFieldForm.js +23 -13
- package/lib/components/pages/CustomFieldForm/CustomFieldForm.js.map +1 -1
- package/lib/forms/studio/api.helpers.d.ts +1 -1
- package/lib/forms/studio/api.helpers.js +9 -2
- package/lib/forms/studio/api.helpers.js.map +1 -1
- package/lib/forms/studio/display.helpers.d.ts +2 -2
- package/lib/forms/studio/display.helpers.js +44 -15
- package/lib/forms/studio/display.helpers.js.map +1 -1
- package/lib/forms/studio/formula.helpers.d.ts +1 -1
- package/lib/forms/studio/formula.helpers.js +6 -5
- package/lib/forms/studio/formula.helpers.js.map +1 -1
- package/lib/header/HeaderActionsProvider.js +6 -4
- package/lib/header/HeaderActionsProvider.js.map +1 -1
- package/lib/hooks/use-mass-scanner.js +5 -0
- package/lib/hooks/use-mass-scanner.js.map +1 -1
- package/lib/loader/ProcessStorage.d.ts +1 -0
- package/lib/loader/ProcessStorage.js +3 -0
- package/lib/loader/ProcessStorage.js.map +1 -1
- package/lib/loader/hooks.js +3 -0
- package/lib/loader/hooks.js.map +1 -1
- package/lib/permissions/format.helpers.js +9 -3
- package/lib/permissions/format.helpers.js.map +1 -1
- package/lib/selections/SelectionProvider.js +3 -2
- package/lib/selections/SelectionProvider.js.map +1 -1
- package/lib/tools/FileViewer.js +2 -2
- package/lib/tools/FileViewer.js.map +1 -1
- package/lib/utils/file.d.ts +1 -0
- package/lib/utils/file.js +1 -0
- package/lib/utils/file.js.map +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +1 -1
- package/lib/utils/index.js.map +1 -1
- package/lib/webViews/WebViewPreloader.d.ts +3 -0
- package/lib/webViews/WebViewPreloader.js +111 -0
- package/lib/webViews/WebViewPreloader.js.map +1 -0
- package/lib/webViews/display.helpers.d.ts +5 -0
- package/lib/webViews/display.helpers.js +5 -0
- package/lib/webViews/display.helpers.js.map +1 -1
- package/lib/webViews/menu.helper.d.ts +2 -9
- package/lib/webViews/menu.helper.js +11 -4
- package/lib/webViews/menu.helper.js.map +1 -1
- package/lib/webViews/view/WebViewScreen.d.ts +3 -1
- package/lib/webViews/view/WebViewScreen.js +14 -10
- package/lib/webViews/view/WebViewScreen.js.map +1 -1
- package/lib/webViews/webView.provider.d.ts +28 -0
- package/lib/webViews/webView.provider.js +65 -0
- package/lib/webViews/webView.provider.js.map +1 -0
- package/package.json +6 -4
package/lib/utils/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,QAAQ,GACT,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,gBAAgB,EAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAC3C,cAAc,OAAO,CAAC;AACtB,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,MAAM,EACN,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,QAAQ,GACT,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,gBAAgB,EAAE,qBAAqB,EAAC,MAAM,QAAQ,CAAC;AAC/D,OAAO,EACL,UAAU,EACV,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACT,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,iBAAiB,EAAE,mBAAmB,EAAE,cAAc,EAAC,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAC,UAAU,EAAE,iBAAiB,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,QAAQ,CAAC;AAC/E,OAAO,EACL,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,EACd,2BAA2B,EAC3B,mBAAmB,GACpB,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,gBAAgB,EAChB,OAAO,EACP,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAC,gBAAgB,EAAC,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,MAAM,EACN,UAAU,EACV,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,UAAU,EAAE,kBAAkB,EAAC,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Axelor Business Solutions
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2026 Axelor (<http://axelor.com>).
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License, version 3,
|
|
8
|
+
* as published by the Free Software Foundation.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
19
|
+
import { StyleSheet, View } from 'react-native';
|
|
20
|
+
import { WebView } from '../components';
|
|
21
|
+
import { useOnline } from '../features/onlineSlice';
|
|
22
|
+
import { useSelector } from '../redux/hooks';
|
|
23
|
+
import { createWebViewPath } from './display.helpers';
|
|
24
|
+
import { useWebViewConfigs } from './webView.provider';
|
|
25
|
+
const PRELOAD_MESSAGE_TYPE = 'aos-webview-preload';
|
|
26
|
+
const SERVICE_WORKER_TIMEOUT = 20000;
|
|
27
|
+
const NATIVE_FALLBACK_TIMEOUT = SERVICE_WORKER_TIMEOUT + 5000;
|
|
28
|
+
const PRELOAD_SCRIPT = `
|
|
29
|
+
(function () {
|
|
30
|
+
var reported = false;
|
|
31
|
+
var report = function (hasServiceWorker) {
|
|
32
|
+
if (reported) { return; }
|
|
33
|
+
reported = true;
|
|
34
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
35
|
+
type: '${PRELOAD_MESSAGE_TYPE}',
|
|
36
|
+
hasServiceWorker: hasServiceWorker,
|
|
37
|
+
}));
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
if (!('serviceWorker' in navigator)) {
|
|
41
|
+
report(false);
|
|
42
|
+
} else {
|
|
43
|
+
navigator.serviceWorker.ready.then(function () { report(true); });
|
|
44
|
+
setTimeout(function () { report(false); }, ${SERVICE_WORKER_TIMEOUT});
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
true;
|
|
48
|
+
`;
|
|
49
|
+
const WebViewPreloader = () => {
|
|
50
|
+
const configs = useWebViewConfigs();
|
|
51
|
+
const { isConnected } = useOnline();
|
|
52
|
+
const { logged } = useSelector(state => state.auth);
|
|
53
|
+
const [queue, setQueue] = useState([]);
|
|
54
|
+
const preloadedIds = useRef([]);
|
|
55
|
+
const fallbackTimeout = useRef(null);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!logged) {
|
|
58
|
+
preloadedIds.current = [];
|
|
59
|
+
setQueue([]);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!isConnected)
|
|
63
|
+
return;
|
|
64
|
+
setQueue(configs.filter(({ id }) => !preloadedIds.current.includes(id)));
|
|
65
|
+
}, [configs, isConnected, logged]);
|
|
66
|
+
const current = useMemo(() => (logged && isConnected ? queue[0] : null), [isConnected, logged, queue]);
|
|
67
|
+
const completeCurrent = useCallback((isPreloaded) => {
|
|
68
|
+
clearTimeout(fallbackTimeout.current);
|
|
69
|
+
if (isPreloaded && current != null) {
|
|
70
|
+
preloadedIds.current = [...preloadedIds.current, current.id];
|
|
71
|
+
}
|
|
72
|
+
setQueue(_queue => _queue.slice(1));
|
|
73
|
+
}, [current]);
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (current == null)
|
|
76
|
+
return;
|
|
77
|
+
fallbackTimeout.current = setTimeout(() => completeCurrent(false), NATIVE_FALLBACK_TIMEOUT);
|
|
78
|
+
return () => clearTimeout(fallbackTimeout.current);
|
|
79
|
+
}, [completeCurrent, current]);
|
|
80
|
+
const handleMessage = useCallback((event) => {
|
|
81
|
+
try {
|
|
82
|
+
const payload = JSON.parse(event?.nativeEvent?.data);
|
|
83
|
+
if (payload?.type === PRELOAD_MESSAGE_TYPE) {
|
|
84
|
+
completeCurrent(payload.hasServiceWorker === true);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch { }
|
|
88
|
+
}, [completeCurrent]);
|
|
89
|
+
const handleError = useCallback(() => completeCurrent(false), [completeCurrent]);
|
|
90
|
+
if (current == null)
|
|
91
|
+
return null;
|
|
92
|
+
return (<View style={styles.container} pointerEvents="none">
|
|
93
|
+
<WebView key={current.id} style={styles.webView} baseUrl={current.url} path={createWebViewPath(current)} injectedJavaScript={PRELOAD_SCRIPT} onMessage={handleMessage} onError={handleError}/>
|
|
94
|
+
</View>);
|
|
95
|
+
};
|
|
96
|
+
const styles = StyleSheet.create({
|
|
97
|
+
container: {
|
|
98
|
+
position: 'absolute',
|
|
99
|
+
top: -1000,
|
|
100
|
+
left: -1000,
|
|
101
|
+
width: 1,
|
|
102
|
+
height: 1,
|
|
103
|
+
opacity: 0,
|
|
104
|
+
},
|
|
105
|
+
webView: {
|
|
106
|
+
width: 1,
|
|
107
|
+
height: 1,
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
export default WebViewPreloader;
|
|
111
|
+
//# sourceMappingURL=WebViewPreloader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebViewPreloader.js","sourceRoot":"","sources":["../../src/webViews/WebViewPreloader.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAC,UAAU,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAC,OAAO,EAAC,MAAM,eAAe,CAAC;AACtC,OAAO,EAAC,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAC,iBAAiB,EAAgB,MAAM,oBAAoB,CAAC;AAEpE,MAAM,oBAAoB,GAAG,qBAAqB,CAAC;AACnD,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,uBAAuB,GAAG,sBAAsB,GAAG,IAAI,CAAC;AAE9D,MAAM,cAAc,GAAG;;;;;;;eAOR,oBAAoB;;;;;;;;;iDASc,sBAAsB;;;;CAItE,CAAC;AAEF,MAAM,gBAAgB,GAAG,GAAG,EAAE;IAC5B,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;IACpC,MAAM,EAAC,WAAW,EAAC,GAAG,SAAS,EAAE,CAAC;IAElC,MAAM,EAAC,MAAM,EAAC,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAElD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAkB,EAAE,CAAC,CAAC;IACxD,MAAM,YAAY,GAA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EzB;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,SAAS,EAAE;QACT,QAAQ,EAAE,UAAU;QACpB,GAAG,EAAE,CAAC,IAAI;QACV,IAAI,EAAE,CAAC,IAAI;QACX,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;QACT,OAAO,EAAE,CAAC;KACX;IACD,OAAO,EAAE;QACP,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,CAAC;KACV;CACF,CAAC,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
|
|
@@ -18,4 +18,9 @@
|
|
|
18
18
|
export const createWebViewActionID = (id) => {
|
|
19
19
|
return `core_webView${id}_details`;
|
|
20
20
|
};
|
|
21
|
+
export const createWebViewPath = (config) => {
|
|
22
|
+
return config?.metaAction?.name != null
|
|
23
|
+
? `#/ds/${config.metaAction.name}`
|
|
24
|
+
: '';
|
|
25
|
+
};
|
|
21
26
|
//# sourceMappingURL=display.helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"display.helpers.js","sourceRoot":"","sources":["../../src/webViews/display.helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAAU,EAAE,EAAE;IAClD,OAAO,eAAe,EAAE,UAAU,CAAC;AACrC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"display.helpers.js","sourceRoot":"","sources":["../../src/webViews/display.helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAAU,EAAE,EAAE;IAClD,OAAO,eAAe,EAAE,UAAU,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAEjC,EAAU,EAAE;IACX,OAAO,MAAM,EAAE,UAAU,EAAE,IAAI,IAAI,IAAI;QACrC,CAAC,CAAC,QAAQ,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAClC,CAAC,CAAC,EAAE,CAAC;AACT,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Menu, Screen } from '../app';
|
|
2
|
+
import { WebViewConfig } from './webView.provider';
|
|
2
3
|
type WebViewMenuConfig = {
|
|
3
4
|
[menuKey: string]: {
|
|
4
5
|
menu: Menu;
|
|
@@ -11,15 +12,7 @@ type Menus = {
|
|
|
11
12
|
type Screens = {
|
|
12
13
|
[screenKey: string]: Screen;
|
|
13
14
|
};
|
|
14
|
-
export declare const createWebViewScreens: (webViewConfigs: {
|
|
15
|
-
id: number;
|
|
16
|
-
appName: string;
|
|
17
|
-
isAosWebView: boolean;
|
|
18
|
-
menuTitle?: string;
|
|
19
|
-
iconName?: string;
|
|
20
|
-
menuOrder?: number;
|
|
21
|
-
authorizedRoleSet: any[];
|
|
22
|
-
}[]) => {
|
|
15
|
+
export declare const createWebViewScreens: (webViewConfigs: WebViewConfig[]) => {
|
|
23
16
|
menus: WebViewMenuConfig;
|
|
24
17
|
screens: Screens;
|
|
25
18
|
};
|
|
@@ -19,15 +19,21 @@ import { modulesProvider } from '../app';
|
|
|
19
19
|
import { fetchWebViewConfigs } from './api.helpers';
|
|
20
20
|
import { createWebViewActionID } from './display.helpers';
|
|
21
21
|
import { WebViewScreen } from './view';
|
|
22
|
+
import { webViewProvider } from './webView.provider';
|
|
22
23
|
import { getRoles } from '../utils';
|
|
23
|
-
const createScreenComponent =
|
|
24
|
-
return props => WebViewScreen({
|
|
24
|
+
const createScreenComponent = (webViewConfig) => {
|
|
25
|
+
return props => WebViewScreen({
|
|
26
|
+
...props,
|
|
27
|
+
webViewId: webViewConfig.id,
|
|
28
|
+
defaultConfig: webViewConfig,
|
|
29
|
+
});
|
|
25
30
|
};
|
|
26
31
|
export const createWebViewScreens = (webViewConfigs) => {
|
|
27
32
|
const screens = {};
|
|
28
33
|
const menus = {};
|
|
29
34
|
if (Array.isArray(webViewConfigs) && webViewConfigs.length > 0) {
|
|
30
|
-
webViewConfigs.forEach(
|
|
35
|
+
webViewConfigs.forEach(webViewConfig => {
|
|
36
|
+
const { id, appName, menuTitle, iconName, menuOrder, authorizedRoleSet = [], } = webViewConfig;
|
|
31
37
|
const config = {
|
|
32
38
|
title: menuTitle ?? 'Base_WebView',
|
|
33
39
|
icon: iconName ?? 'layers',
|
|
@@ -36,7 +42,7 @@ export const createWebViewScreens = (webViewConfigs) => {
|
|
|
36
42
|
const screenKey = `WebView_${appName}_${id}`;
|
|
37
43
|
screens[screenKey] = {
|
|
38
44
|
title: config.title,
|
|
39
|
-
component: createScreenComponent(
|
|
45
|
+
component: createScreenComponent(webViewConfig),
|
|
40
46
|
actionID: createWebViewActionID(id),
|
|
41
47
|
};
|
|
42
48
|
const _menu = {
|
|
@@ -81,6 +87,7 @@ export const registerWebViewModule = async (user) => {
|
|
|
81
87
|
const webViewConfigs = await fetchWebViewConfigs()
|
|
82
88
|
.then(res => res?.data?.data)
|
|
83
89
|
.catch(() => []);
|
|
90
|
+
webViewProvider.registerConfigs(webViewConfigs);
|
|
84
91
|
const { screens, menus } = createWebViewScreens(webViewConfigs);
|
|
85
92
|
const userRoles = getRoles(user);
|
|
86
93
|
modulesProvider.registerModule({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu.helper.js","sourceRoot":"","sources":["../../src/webViews/menu.helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAO,eAAe,EAAS,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAC,mBAAmB,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAC,aAAa,EAAC,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CA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OAAO,KAAK,CAAC;QACf,CAAC;aAAM,CAAC;YACN,OAAO,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAC1C,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,WAAW,CAAC,EAAE,CAAC,CAC7D,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;SACD,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,EAAC,IAAI,EAAC,CAAC,EAAE,EAAE;QACzB,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACpB,CAAC,CAAC,CAAC;IAEL,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE,IAAS,EAAE,EAAE;IACvD,MAAM,cAAc,GAAG,MAAM,mBAAmB,EAAE;SAC/C,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC;SAC5B,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IAEnB,eAAe,CAAC,eAAe,CAAC,cAAc,CAAC,CAAC;IAEhD,MAAM,EAAC,OAAO,EAAE,KAAK,EAAC,GAAG,oBAAoB,CAAC,cAAc,CAAC,CAAC;IAC9D,MAAM,SAAS,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAEjC,eAAe,CAAC,cAAc,CAAC;QAC7B,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,4BAA4B,CAAC,KAAK,EAAE,SAAS,CAAC;QACrD,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { WebViewConfig } from '../webView.provider';
|
|
2
3
|
interface WebViewScreenProps {
|
|
3
4
|
webViewId: number;
|
|
5
|
+
defaultConfig?: WebViewConfig;
|
|
4
6
|
hideCardBackground?: boolean;
|
|
5
7
|
chartWidth?: number;
|
|
6
8
|
}
|
|
7
|
-
export declare const WebViewScreen: ({ webViewId }: WebViewScreenProps) => React.JSX.Element;
|
|
9
|
+
export declare const WebViewScreen: ({ webViewId, defaultConfig, }: WebViewScreenProps) => React.JSX.Element;
|
|
8
10
|
export {};
|
|
@@ -15,24 +15,29 @@
|
|
|
15
15
|
* You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
|
-
import React, { useCallback, useEffect, useState } from 'react';
|
|
18
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
19
19
|
import { ActivityIndicator } from 'react-native';
|
|
20
20
|
import { WebView } from '../../components';
|
|
21
21
|
import { headerActionsProvider } from '../../header';
|
|
22
22
|
import { useTranslator } from '../../i18n';
|
|
23
23
|
import { fetchWebViewById } from '../api.helpers';
|
|
24
|
-
import { createWebViewActionID } from '../display.helpers';
|
|
25
|
-
|
|
24
|
+
import { createWebViewActionID, createWebViewPath } from '../display.helpers';
|
|
25
|
+
import { webViewProvider } from '../webView.provider';
|
|
26
|
+
export const WebViewScreen = ({ webViewId, defaultConfig, }) => {
|
|
26
27
|
const I18n = useTranslator();
|
|
27
|
-
const [webViewData, setWebViewData] = useState({});
|
|
28
|
+
const [webViewData, setWebViewData] = useState(defaultConfig ?? webViewProvider.getConfig(webViewId) ?? {});
|
|
28
29
|
const [loading, setLoading] = useState(false);
|
|
29
30
|
const refresh = useCallback(() => {
|
|
30
31
|
setLoading(true);
|
|
31
32
|
fetchWebViewById({ mobileWebViewId: webViewId })
|
|
32
33
|
.then(response => {
|
|
33
|
-
|
|
34
|
+
const config = response?.data?.data?.[0];
|
|
35
|
+
if (config != null) {
|
|
36
|
+
setWebViewData(config);
|
|
37
|
+
webViewProvider.updateConfig(config);
|
|
38
|
+
}
|
|
34
39
|
})
|
|
35
|
-
.catch(() =>
|
|
40
|
+
.catch(() => { })
|
|
36
41
|
.finally(() => setLoading(false));
|
|
37
42
|
}, [webViewId]);
|
|
38
43
|
useEffect(() => {
|
|
@@ -44,6 +49,7 @@ export const WebViewScreen = ({ webViewId }) => {
|
|
|
44
49
|
isMounted = false;
|
|
45
50
|
};
|
|
46
51
|
}, [refresh]);
|
|
52
|
+
const hasConfig = useMemo(() => Object.keys(webViewData ?? {}).length > 0, [webViewData]);
|
|
47
53
|
useEffect(() => {
|
|
48
54
|
headerActionsProvider.registerModel(createWebViewActionID(webViewId), {
|
|
49
55
|
actions: [
|
|
@@ -58,11 +64,9 @@ export const WebViewScreen = ({ webViewId }) => {
|
|
|
58
64
|
],
|
|
59
65
|
});
|
|
60
66
|
}, [I18n, webViewId, refresh]);
|
|
61
|
-
if (loading) {
|
|
67
|
+
if (loading && !hasConfig) {
|
|
62
68
|
return <ActivityIndicator size="large"/>;
|
|
63
69
|
}
|
|
64
|
-
return (<WebView baseUrl={webViewData?.url} path={webViewData
|
|
65
|
-
? `#/ds/${webViewData?.metaAction?.name}`
|
|
66
|
-
: ''}/>);
|
|
70
|
+
return (<WebView baseUrl={webViewData?.url} path={createWebViewPath(webViewData)}/>);
|
|
67
71
|
};
|
|
68
72
|
//# sourceMappingURL=WebViewScreen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebViewScreen.js","sourceRoot":"","sources":["../../../src/webViews/view/WebViewScreen.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"WebViewScreen.js","sourceRoot":"","sources":["../../../src/webViews/view/WebViewScreen.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AACvE,OAAO,EAAC,iBA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;
|
|
3
|
+
appName: string;
|
|
4
|
+
isAosWebView?: boolean;
|
|
5
|
+
url?: string;
|
|
6
|
+
metaAction?: {
|
|
7
|
+
name: string;
|
|
8
|
+
};
|
|
9
|
+
menuTitle?: string;
|
|
10
|
+
iconName?: string;
|
|
11
|
+
menuOrder?: number;
|
|
12
|
+
authorizedRoleSet?: any[];
|
|
13
|
+
}
|
|
14
|
+
declare class WebViewProvider {
|
|
15
|
+
private configs;
|
|
16
|
+
private refreshCallBack;
|
|
17
|
+
constructor();
|
|
18
|
+
registerCallback(callBack: Function): void;
|
|
19
|
+
unregisterCallback(callBack: Function): void;
|
|
20
|
+
registerConfigs(configs: WebViewConfig[]): void;
|
|
21
|
+
updateConfig(config: WebViewConfig): void;
|
|
22
|
+
getConfigs(): WebViewConfig[];
|
|
23
|
+
getConfig(id: number): WebViewConfig;
|
|
24
|
+
private updateState;
|
|
25
|
+
}
|
|
26
|
+
export declare const webViewProvider: WebViewProvider;
|
|
27
|
+
export declare const useWebViewConfigs: () => WebViewConfig[];
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Axelor Business Solutions
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2026 Axelor (<http://axelor.com>).
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License, version 3,
|
|
8
|
+
* as published by the Free Software Foundation.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
19
|
+
class WebViewProvider {
|
|
20
|
+
configs;
|
|
21
|
+
refreshCallBack;
|
|
22
|
+
constructor() {
|
|
23
|
+
this.configs = [];
|
|
24
|
+
this.refreshCallBack = [];
|
|
25
|
+
}
|
|
26
|
+
registerCallback(callBack) {
|
|
27
|
+
this.refreshCallBack.push(callBack);
|
|
28
|
+
}
|
|
29
|
+
unregisterCallback(callBack) {
|
|
30
|
+
this.refreshCallBack = this.refreshCallBack.filter(_f => _f !== callBack);
|
|
31
|
+
}
|
|
32
|
+
registerConfigs(configs) {
|
|
33
|
+
this.configs = Array.isArray(configs) ? configs : [];
|
|
34
|
+
this.updateState();
|
|
35
|
+
}
|
|
36
|
+
updateConfig(config) {
|
|
37
|
+
if (config?.id == null) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
this.configs = this.configs.map(_config => _config.id === config.id ? { ..._config, ...config } : _config);
|
|
41
|
+
this.updateState();
|
|
42
|
+
}
|
|
43
|
+
getConfigs() {
|
|
44
|
+
return this.configs;
|
|
45
|
+
}
|
|
46
|
+
getConfig(id) {
|
|
47
|
+
return this.configs.find(_config => _config.id === id);
|
|
48
|
+
}
|
|
49
|
+
updateState() {
|
|
50
|
+
this.refreshCallBack.forEach(_f => _f(this.configs));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export const webViewProvider = new WebViewProvider();
|
|
54
|
+
export const useWebViewConfigs = () => {
|
|
55
|
+
const [configs, setConfigs] = useState(webViewProvider.getConfigs());
|
|
56
|
+
const refreshData = useCallback((data) => setConfigs([...data]), []);
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
webViewProvider.registerCallback(refreshData);
|
|
59
|
+
return () => {
|
|
60
|
+
webViewProvider.unregisterCallback(refreshData);
|
|
61
|
+
};
|
|
62
|
+
}, [refreshData]);
|
|
63
|
+
return configs;
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=webView.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|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IAED,SAAS,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,CAAkB,CAAC;IAC1E,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;AAErD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAoB,EAAE;IACrD,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CACpC,eAAe,CAAC,UAAU,EAAE,CAC7B,CAAC;IAEF,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,IAAqB,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAChD,EAAE,CACH,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,eAAe,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAE9C,OAAO,GAAG,EAAE;YACV,eAAe,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axelor/aos-mobile-core",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.9",
|
|
4
4
|
"author": "Axelor",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
"main": "lib/index.js",
|
|
15
15
|
"types": "lib/index.d.js",
|
|
16
16
|
"files": [
|
|
17
|
-
"lib"
|
|
17
|
+
"lib",
|
|
18
|
+
"android",
|
|
19
|
+
"!android/build"
|
|
18
20
|
],
|
|
19
21
|
"scripts": {
|
|
20
22
|
"clean": "rm -rf lib/",
|
|
@@ -29,8 +31,8 @@
|
|
|
29
31
|
"license:add": "npx add-copyright-header --generate --dir 'src'"
|
|
30
32
|
},
|
|
31
33
|
"dependencies": {
|
|
32
|
-
"@axelor/aos-mobile-error": "9.1.
|
|
33
|
-
"@axelor/aos-mobile-ui": "9.1.
|
|
34
|
+
"@axelor/aos-mobile-error": "9.1.9",
|
|
35
|
+
"@axelor/aos-mobile-ui": "9.1.9",
|
|
34
36
|
"@react-navigation/drawer": "7.7.13",
|
|
35
37
|
"@react-navigation/native": "7.1.28",
|
|
36
38
|
"@react-navigation/native-stack": "7.10.1",
|