@axelor/aos-mobile-core 8.0.7 → 8.0.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.
Files changed (74) hide show
  1. package/lib/apiProviders/Action/ActionApiProvider.d.ts +1 -1
  2. package/lib/apiProviders/Action/GatewayActionApi.d.ts +1 -1
  3. package/lib/apiProviders/Action/GatewayActionApi.js +2 -2
  4. package/lib/apiProviders/Action/GatewayActionApi.js.map +1 -1
  5. package/lib/apiProviders/Standard/requests.helper.d.ts +4 -2
  6. package/lib/apiProviders/Standard/requests.helper.js +33 -10
  7. package/lib/apiProviders/Standard/requests.helper.js.map +1 -1
  8. package/lib/apiProviders/utils.js +5 -2
  9. package/lib/apiProviders/utils.js.map +1 -1
  10. package/lib/app/ContextsProvider.js +4 -1
  11. package/lib/app/ContextsProvider.js.map +1 -1
  12. package/lib/auth/hooks/use-auth-headers.js +40 -2
  13. package/lib/auth/hooks/use-auth-headers.js.map +1 -1
  14. package/lib/components/external/PlanningView/PlanningView.js +2 -1
  15. package/lib/components/external/PlanningView/PlanningView.js.map +1 -1
  16. package/lib/components/external/PlanningView/agenda.helpers.d.ts +0 -1
  17. package/lib/components/external/PlanningView/agenda.helpers.js +0 -5
  18. package/lib/components/external/PlanningView/agenda.helpers.js.map +1 -1
  19. package/lib/forms/studio/display.helpers.js +5 -0
  20. package/lib/forms/studio/display.helpers.js.map +1 -1
  21. package/lib/i18n/translations/en.json +13 -0
  22. package/lib/i18n/translations/fr.json +13 -0
  23. package/lib/index.d.ts +1 -0
  24. package/lib/index.js +1 -0
  25. package/lib/index.js.map +1 -1
  26. package/lib/loader/ProcessProvider.d.ts +30 -0
  27. package/lib/loader/ProcessProvider.js +211 -0
  28. package/lib/loader/ProcessProvider.js.map +1 -0
  29. package/lib/loader/ProcessStorage.d.ts +18 -0
  30. package/lib/loader/ProcessStorage.js +95 -0
  31. package/lib/loader/ProcessStorage.js.map +1 -0
  32. package/lib/loader/components/atoms/ProcessCard/ProcessCard.d.ts +14 -0
  33. package/lib/loader/components/atoms/ProcessCard/ProcessCard.js +69 -0
  34. package/lib/loader/components/atoms/ProcessCard/ProcessCard.js.map +1 -0
  35. package/lib/loader/components/atoms/index.d.ts +1 -0
  36. package/lib/loader/components/atoms/index.js +19 -0
  37. package/lib/loader/components/atoms/index.js.map +1 -0
  38. package/lib/loader/components/index.d.ts +2 -0
  39. package/lib/loader/components/index.js +20 -0
  40. package/lib/loader/components/index.js.map +1 -0
  41. package/lib/loader/components/organisms/LoaderPopup/LoaderPopup.d.ts +12 -0
  42. package/lib/loader/components/organisms/LoaderPopup/LoaderPopup.js +104 -0
  43. package/lib/loader/components/organisms/LoaderPopup/LoaderPopup.js.map +1 -0
  44. package/lib/loader/components/organisms/index.d.ts +1 -0
  45. package/lib/loader/components/organisms/index.js +19 -0
  46. package/lib/loader/components/organisms/index.js.map +1 -0
  47. package/lib/loader/helpers.d.ts +5 -0
  48. package/lib/loader/helpers.js +59 -0
  49. package/lib/loader/helpers.js.map +1 -0
  50. package/lib/loader/hooks.d.ts +6 -0
  51. package/lib/loader/hooks.js +50 -0
  52. package/lib/loader/hooks.js.map +1 -0
  53. package/lib/loader/index.d.ts +6 -0
  54. package/lib/loader/index.js +24 -0
  55. package/lib/loader/index.js.map +1 -0
  56. package/lib/loader/types.d.ts +26 -0
  57. package/lib/loader/types.js +24 -0
  58. package/lib/loader/types.js.map +1 -0
  59. package/lib/screens/ProcessListScreen.d.ts +2 -0
  60. package/lib/screens/ProcessListScreen.js +75 -0
  61. package/lib/screens/ProcessListScreen.js.map +1 -0
  62. package/lib/screens/index.d.ts +11 -0
  63. package/lib/screens/index.js +8 -0
  64. package/lib/screens/index.js.map +1 -1
  65. package/lib/utils/date.d.ts +1 -0
  66. package/lib/utils/date.js +5 -0
  67. package/lib/utils/date.js.map +1 -1
  68. package/lib/utils/formatters.d.ts +4 -1
  69. package/lib/utils/formatters.js +7 -4
  70. package/lib/utils/formatters.js.map +1 -1
  71. package/lib/utils/index.d.ts +1 -1
  72. package/lib/utils/index.js +1 -1
  73. package/lib/utils/index.js.map +1 -1
  74. package/package.json +3 -3
@@ -0,0 +1,211 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2024 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 { StatusBar } from 'react-native';
19
+ import { showToastMessage } from '../utils';
20
+ import { processStorage } from './ProcessStorage';
21
+ import { ProcessStatus, } from './types';
22
+ class ProcessProvider {
23
+ _events;
24
+ _processMap;
25
+ _numberRunningProcess;
26
+ _NRProcessSubscribers = [];
27
+ _numberUnreadProcess;
28
+ constructor() {
29
+ this._events = new Map();
30
+ this._processMap = new Map(processStorage.getProcessList().map(p => [p.key, p]));
31
+ this._numberRunningProcess = 0;
32
+ this._NRProcessSubscribers = [];
33
+ this._numberUnreadProcess = processStorage.getNumberUnreadProcess();
34
+ this.onCompleted = this.onCompleted.bind(this);
35
+ this.removeOldProcesses = this.removeOldProcesses.bind(this);
36
+ }
37
+ getNumberRunningProcess() {
38
+ return this._numberRunningProcess;
39
+ }
40
+ setNumberRunningProcess(value) {
41
+ this._numberRunningProcess = value;
42
+ this.notifyNRProcessSubscribers();
43
+ }
44
+ subscribeNRProcess(callback) {
45
+ this._NRProcessSubscribers.push(callback);
46
+ }
47
+ unsubscribeNRProcess(callback) {
48
+ this._NRProcessSubscribers = this._NRProcessSubscribers.filter(sub => sub !== callback);
49
+ }
50
+ notifyNRProcessSubscribers() {
51
+ this._NRProcessSubscribers.forEach(callback => callback(this._numberRunningProcess));
52
+ }
53
+ setNumberUnreadProcess(value) {
54
+ this._numberUnreadProcess = value;
55
+ processStorage.saveNumberUnreadProcess(value);
56
+ }
57
+ registerProcess(key, processOptions) {
58
+ const process = {
59
+ ...processOptions,
60
+ key,
61
+ loading: false,
62
+ notifyMe: false,
63
+ response: null,
64
+ status: null,
65
+ executed: false,
66
+ startedDate: null,
67
+ endDate: null,
68
+ };
69
+ this._processMap.set(key, process);
70
+ processStorage.saveProcess(process);
71
+ return process;
72
+ }
73
+ getProcess(key) {
74
+ if (!this._processMap.has(key)) {
75
+ console.error(`Process with key ${key} not found.`);
76
+ return null;
77
+ }
78
+ return this._processMap.get(key);
79
+ }
80
+ async runProcess(key, I18n) {
81
+ const process = this.getProcess(key);
82
+ if (!this._processMap.has(key)) {
83
+ throw new Error(`Process with key ${process.key} not found.`);
84
+ }
85
+ this.onStart(key);
86
+ this.executeProcess(key, I18n);
87
+ }
88
+ onStart(key) {
89
+ const process = this.getProcess(key);
90
+ const _process = {
91
+ ...process,
92
+ loading: true,
93
+ status: ProcessStatus.InProgress,
94
+ startedDate: new Date().toISOString(),
95
+ };
96
+ this._processMap.set(key, _process);
97
+ processStorage.saveProcess(_process);
98
+ this.on(key, ProcessStatus.Success, this.onCompleted);
99
+ this.on(key, ProcessStatus.Failed, this.onCompleted);
100
+ this.emit(key, ProcessStatus.InProgress);
101
+ this.setNumberRunningProcess(this._numberRunningProcess + 1);
102
+ this.setNumberUnreadProcess(this._numberUnreadProcess + 1);
103
+ }
104
+ async executeProcess(key, I18n) {
105
+ const process = this.getProcess(key);
106
+ try {
107
+ const response = await process.process();
108
+ this.onFinish(key, ProcessStatus.Success, response, I18n);
109
+ }
110
+ catch (error) {
111
+ this.onFinish(key, ProcessStatus.Failed, error, I18n);
112
+ }
113
+ }
114
+ on(key, event, callBack) {
115
+ const _event = this._events.has(key)
116
+ ? this._events.get(key)
117
+ : {};
118
+ if (!_event[event]) {
119
+ _event[event] = [];
120
+ }
121
+ _event[event].push(callBack);
122
+ this._events.set(key, _event);
123
+ }
124
+ emit(key, event, ...args) {
125
+ if (this._events.has(key) && this._events.get(key)[event]) {
126
+ this._events.get(key)[event].forEach(callBack => callBack(...args));
127
+ }
128
+ }
129
+ onFinish(key, status, response, I18n) {
130
+ const process = this.getProcess(key);
131
+ const _process = {
132
+ ...process,
133
+ loading: false,
134
+ response,
135
+ status,
136
+ endDate: new Date().toISOString(),
137
+ };
138
+ this._processMap.set(key, _process);
139
+ processStorage.saveProcess(_process);
140
+ this.emit(key, status === ProcessStatus.Success
141
+ ? ProcessStatus.Success
142
+ : ProcessStatus.Failed, _process, I18n);
143
+ this.setNumberRunningProcess(this._numberRunningProcess - 1);
144
+ }
145
+ onCompleted(process, I18n) {
146
+ const _process = this.getProcess(process.key);
147
+ const { status, notifyMe, response, disabled, onSuccess, onError } = _process;
148
+ const isSuccess = status === ProcessStatus.Success;
149
+ const handleEndOfProcess = () => {
150
+ isSuccess ? onSuccess(response) : onError(response);
151
+ this.resolveProcess(_process.key);
152
+ };
153
+ if (!notifyMe) {
154
+ handleEndOfProcess();
155
+ }
156
+ else {
157
+ showToastMessage({
158
+ type: isSuccess ? 'success' : 'error',
159
+ position: 'top',
160
+ topOffset: StatusBar.currentHeight + 30,
161
+ text1: I18n.t(isSuccess ? 'Base_Success' : 'Base_Error'),
162
+ text2: typeof response === 'string'
163
+ ? response
164
+ : I18n.t(isSuccess
165
+ ? 'Base_Loader_ProccessSuccessMessage'
166
+ : 'Base_Loader_ProccessErrorMessage'),
167
+ onPress: () => !disabled && handleEndOfProcess(),
168
+ });
169
+ }
170
+ }
171
+ resolveProcess(key) {
172
+ const process = this.getProcess(key);
173
+ if (!this._processMap.has(key)) {
174
+ throw new Error(`Process with key ${key} not found.`);
175
+ }
176
+ const _process = {
177
+ ...process,
178
+ executed: true,
179
+ };
180
+ this._processMap.set(key, _process);
181
+ processStorage.saveProcess(_process);
182
+ }
183
+ notifyMe(key) {
184
+ const process = this.getProcess(key);
185
+ process.notifyMe = true;
186
+ this._processMap.set(key, process);
187
+ processStorage.saveProcess(process);
188
+ }
189
+ removeOldProcesses() {
190
+ const now = new Date();
191
+ const processList = processStorage.getProcessList();
192
+ const processSortedByDate = processList.sort((a, b) => new Date(a.startedDate) <= new Date(b.startedDate) ? 1 : -1);
193
+ let processesLessThanOneMonthOld = [];
194
+ for (const process of processSortedByDate) {
195
+ const removeDate = new Date(process.startedDate);
196
+ removeDate.setMonth(removeDate.getMonth() + 1);
197
+ if (removeDate >= now) {
198
+ processesLessThanOneMonthOld.push(process);
199
+ }
200
+ else {
201
+ break;
202
+ }
203
+ }
204
+ if (this._numberRunningProcess > processesLessThanOneMonthOld.length) {
205
+ this.setNumberUnreadProcess(processesLessThanOneMonthOld.length);
206
+ }
207
+ processStorage.saveProcessList(processesLessThanOneMonthOld);
208
+ }
209
+ }
210
+ export const processProvider = new ProcessProvider();
211
+ //# sourceMappingURL=ProcessProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcessProvider.js","sourceRoot":"","sources":["../../src/loader/ProcessProvider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAE1C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAKL,aAAa,GACd,MAAM,SAAS,CAAC;AAIjB,MAAM,eAAe;IACX,OAAO,CAAqB;IAC5B,WAAW,CAA2B;IACtC,qBAAqB,CAAS;IAC9B,qBAAqB,GAA8B,EAAE,CAAC;IACtD,oBAAoB,CAAS;IAErC;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,CACxB,cAAc,CAAC,cAAc,EAAE,CAAC,GAAG,CAA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AQ,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC;YAE/C,IAAI,UAAU,IAAI,GAAG,EAAE;gBACrB,4BAA4B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;aAC5C;iBAAM;gBACL,MAAM;aACP;SACF;QAED,IAAI,IAAI,CAAC,qBAAqB,GAAG,4BAA4B,CAAC,MAAM,EAAE;YACpE,IAAI,CAAC,sBAAsB,CAAC,4BAA4B,CAAC,MAAM,CAAC,CAAC;SAClE;QAED,cAAc,CAAC,eAAe,CAAC,4BAA4B,CAAC,CAAC;IAC/D,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { Storage } from '../storage/Storage';
2
+ import { ProcessItem } from './types';
3
+ declare class ProcessStorage {
4
+ private localStorage;
5
+ private numberUnreadProcess;
6
+ private processList;
7
+ private refreshCallBacks;
8
+ constructor(localStorage: Storage);
9
+ private updateState;
10
+ register(callBack: any): void;
11
+ getNumberUnreadProcess(): number;
12
+ saveNumberUnreadProcess(value: number): void;
13
+ getProcessList(): ProcessItem[];
14
+ saveProcess(process: ProcessItem): void;
15
+ saveProcessList(_processList: ProcessItem[]): void;
16
+ }
17
+ export declare const processStorage: ProcessStorage;
18
+ export {};
@@ -0,0 +1,95 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2024 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 { storage } from '../storage/Storage';
19
+ import { deserialize, serialize } from './helpers';
20
+ const NUMBER_UNREAD_PROCESS_KEY = 'NUMBER_UNREAD_PROCESS_KEY';
21
+ const PROCESS_LIST_KEY = 'PROCESS_LIST_KEY';
22
+ class ProcessStorage {
23
+ localStorage;
24
+ numberUnreadProcess;
25
+ processList;
26
+ refreshCallBacks;
27
+ constructor(localStorage) {
28
+ this.localStorage = localStorage;
29
+ this.numberUnreadProcess = 0;
30
+ this.processList = [];
31
+ this.refreshCallBacks = [];
32
+ }
33
+ updateState() {
34
+ if (this.refreshCallBacks.length > 0) {
35
+ const state = {
36
+ processList: this.getProcessList(),
37
+ numberUnreadProcess: this.getNumberUnreadProcess(),
38
+ };
39
+ this.refreshCallBacks.forEach(callBack => callBack(state));
40
+ }
41
+ }
42
+ register(callBack) {
43
+ this.refreshCallBacks.push(callBack);
44
+ this.updateState();
45
+ }
46
+ getNumberUnreadProcess() {
47
+ if (this.numberUnreadProcess == null || this.numberUnreadProcess <= 0) {
48
+ this.numberUnreadProcess =
49
+ Number(this.localStorage.getItem(NUMBER_UNREAD_PROCESS_KEY)) || 0;
50
+ }
51
+ return this.numberUnreadProcess;
52
+ }
53
+ saveNumberUnreadProcess(value) {
54
+ if (value == null) {
55
+ return;
56
+ }
57
+ this.numberUnreadProcess = value;
58
+ this.localStorage.setItem(NUMBER_UNREAD_PROCESS_KEY, this.numberUnreadProcess.toString());
59
+ this.updateState();
60
+ }
61
+ getProcessList() {
62
+ if (this.processList == null || this.processList.length === 0) {
63
+ this.processList = deserialize(this.localStorage.getItem(PROCESS_LIST_KEY));
64
+ }
65
+ return this.processList;
66
+ }
67
+ saveProcess(process) {
68
+ if (process == null || process.key == null) {
69
+ return;
70
+ }
71
+ if (this.processList.find(item => item.key === process.key) != null) {
72
+ this.processList = this.processList.map(item => {
73
+ if (item.key === process.key) {
74
+ return { ...item, ...process };
75
+ }
76
+ return item;
77
+ });
78
+ }
79
+ else {
80
+ this.processList.push(process);
81
+ }
82
+ this.localStorage.setItem(PROCESS_LIST_KEY, serialize(this.processList));
83
+ this.updateState();
84
+ }
85
+ saveProcessList(_processList) {
86
+ if (!Array.isArray(_processList)) {
87
+ return;
88
+ }
89
+ this.processList = _processList;
90
+ this.localStorage.setItem(PROCESS_LIST_KEY, serialize(_processList));
91
+ this.updateState();
92
+ }
93
+ }
94
+ export const processStorage = new ProcessStorage(storage);
95
+ //# sourceMappingURL=ProcessStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcessStorage.js","sourceRoot":"","sources":["../../src/loader/ProcessStorage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,EAAU,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAC,WAAW,EAAE,SAAS,EAAC,MAAM,WAAW,CAAC;AAEjD,MAAM,yBAAyB,GAAG,2BAA2B,CAAC;AAC9D,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAE5C,MAAM,cAAc;IAWE;IAVZ,mBAAmB,CAAS;IAC5B,WAAW,CAAgB;IAC3B,gBAAgB,CAMV;IAEd,YAAoB,YAAqB;QAArB,iBAAY,GAAZ,YAAY,CAAS;QACvC,IAAI,CAAC,mBAAmB,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC7B,CAAC;IAEO,WAAW;QACjB,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE;YACpC,MAAM,KAAK,GAAG;gBACZ,WAAW,EAAE,IAAI,CAAC,cAAc,EAAE;gBAClC,mBAAmB,EAAE,IAAI,CAAC,sBAAsB,EAAE;aACnD,CAAC;YACF,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;SAC5D;IACH,CA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C,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;gBAC7C,IAAI,IAAI,CAAC,GAAG,KAAK,OAAO,CAAC,GAAG,EAAE;oBAC5B,OAAO,EAAC,GAAG,IAAI,EAAE,GAAG,OAAO,EAAC,CAAC;iBAC9B;gBACD,OAAO,IAAI,CAAC;YACd,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAChC;QAED,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,gBAAgB,EAAE,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;IAED,eAAe,CAAC,YAA2B;QACzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;YAChC,OAAO;SACR;QAED,IAAI,CAAC,WAAW,GAAG,YAAY,CAAC;QAChC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,gBAAgB,EAAE,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,WAAW,EAAE,CAAC;IACrB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,OAAO,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { ProcessStatus } from '../../../types';
2
+ interface ProcessCardProps {
3
+ style?: any;
4
+ processKey: string;
5
+ name: string;
6
+ status: ProcessStatus;
7
+ executed: boolean;
8
+ startedDate: string;
9
+ endDate: string;
10
+ onSuccess: () => void;
11
+ onError: () => void;
12
+ }
13
+ declare const ProcessCard: ({ style, processKey, name, status, executed, startedDate, endDate, onSuccess, onError, }: ProcessCardProps) => JSX.Element;
14
+ export default ProcessCard;
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2024 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, useMemo } from 'react';
19
+ import { StyleSheet } from 'react-native';
20
+ import { ObjectCard, useThemeColor } from '@axelor/aos-mobile-ui';
21
+ import { formatDateTime } from '../../../../utils';
22
+ import { useTranslator } from '../../../../i18n';
23
+ import { processProvider } from '../../../ProcessProvider';
24
+ import { getProcessStatusColor } from '../../../helpers';
25
+ import { ProcessStatus } from '../../../types';
26
+ const ProcessCard = ({ style, processKey, name, status, executed, startedDate, endDate, onSuccess, onError, }) => {
27
+ const I18n = useTranslator();
28
+ const Colors = useThemeColor();
29
+ const styles = useMemo(() => getStyles(getProcessStatusColor(status, Colors)?.background), [Colors, status]);
30
+ const isSuccess = useMemo(() => status === ProcessStatus.Success, [status]);
31
+ const isTouchable = useMemo(() => {
32
+ const isCompleted = isSuccess || status === ProcessStatus.Failed;
33
+ return (isCompleted &&
34
+ !executed &&
35
+ typeof onSuccess === 'function' &&
36
+ typeof onError === 'function');
37
+ }, [executed, isSuccess, onError, onSuccess, status]);
38
+ const handleOnPress = useCallback(() => {
39
+ status === ProcessStatus.Success ? onSuccess() : onError();
40
+ processProvider.resolveProcess(processKey);
41
+ }, [status, onSuccess, onError, processKey]);
42
+ return (<ObjectCard style={[styles.card, style]} showArrow={isTouchable} touchable={isTouchable} onPress={handleOnPress} upperTexts={{
43
+ items: [
44
+ { isTitle: true, displayText: name },
45
+ {
46
+ iconName: 'calendar-event',
47
+ indicatorText: I18n.t('Base_StartedOn'),
48
+ displayText: formatDateTime(startedDate, I18n.t('Base_DateTimeFormat')),
49
+ hideIf: startedDate == null,
50
+ },
51
+ {
52
+ iconName: isSuccess ? 'calendar-check' : 'calendar-x',
53
+ indicatorText: I18n.t(isSuccess ? 'Base_CompletedOn' : 'Base_FaildedOn'),
54
+ displayText: formatDateTime(endDate, I18n.t('Base_DateTimeFormat')),
55
+ hideIf: endDate == null,
56
+ },
57
+ ],
58
+ }}/>);
59
+ };
60
+ const getStyles = (color) => StyleSheet.create({
61
+ card: {
62
+ marginHorizontal: 12,
63
+ marginVertical: 4,
64
+ borderLeftWidth: 7,
65
+ borderLeftColor: color,
66
+ },
67
+ });
68
+ export default ProcessCard;
69
+ //# sourceMappingURL=ProcessCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProcessCard.js","sourceRoot":"","sources":["../../../../../src/loader/components/atoms/ProcessCard/ProcessCard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAClD,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAC,cAAc,EAAC,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAC,qBAAqB,EAAC,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAc7C,MAAM,WAAW,GAAG,CAAC,EACnB,KAAK,EACL,UAAU,EACV,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,WAAW,EACX,OAAO,EACP,SAAS,EACT,OAAO,GACU,EAAE,EAAE;IACrB,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;IAC7B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,EAAE,WAAW,EAAE,IAAI,EAAC;gBAClC;oBACE,QAAQ,EAAE,gBAAgB;oBAC1B,aAAa,EAAE,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC;oBACvC,WAAW,EAAE,cAAc,CACzB,WAAW,EACX,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAC9B;oBACD,MAAM,EAAE,WAAW,IAAI,IAAI;iBAC5B;gBACD;oBACE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,YAAY;oBACrD,aAAa,EAAE,IAAI,CAAC,CAAC,CACnB,SAAS,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,gBAAgB,CAClD;oBACD,WAAW,EAAE,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC;oBACnE,MAAM,EAAE,OAAO,IAAI,IAAI;iBACxB;aACF;SACF,CAAC,EACF,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,SAAS,GAAG,CAAC,KAAa,EAAE,EAAE,CAClC,UAAU,CAAC,MAAM,CAAC;IAChB,IAAI,EAAE;QACJ,gBAAgB,EAAE,EAAE;QACpB,cAAc,EAAE,CAAC;QACjB,eAAe,EAAE,CAAC;QAClB,eAAe,EAAE,KAAK;KACvB;CACF,CAAC,CAAC;AAEL,eAAe,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ export { default as ProcessCard } from './ProcessCard/ProcessCard';
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2024 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
+ export { default as ProcessCard } from './ProcessCard/ProcessCard';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/loader/components/atoms/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './atoms';
2
+ export * from './organisms';
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2024 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
+ export * from './atoms';
19
+ export * from './organisms';
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/loader/components/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,12 @@
1
+ interface LoaderPopupProps {
2
+ start?: boolean;
3
+ autoLeave?: boolean;
4
+ timeout?: number;
5
+ name: string;
6
+ disabled?: boolean;
7
+ process: () => Promise<any>;
8
+ onSuccess: () => void;
9
+ onError: () => void;
10
+ }
11
+ declare const LoaderPopup: ({ start, autoLeave, timeout, name, disabled, process, onSuccess, onError, }: LoaderPopupProps) => JSX.Element;
12
+ export default LoaderPopup;
@@ -0,0 +1,104 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2024 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 { ActivityIndicator, StyleSheet, View } from 'react-native';
20
+ import { Alert, Button, Label, Text, useConfig, useThemeColor, } from '@axelor/aos-mobile-ui';
21
+ import { useNavigation } from '../../../../hooks/use-navigation';
22
+ import { useTranslator } from '../../../../i18n';
23
+ import { processProvider } from '../../../ProcessProvider';
24
+ import { ProcessStatus } from '../../../types';
25
+ const LoaderPopup = ({ start = false, autoLeave = false, timeout = 1000, name, disabled = false, process, onSuccess, onError, }) => {
26
+ const I18n = useTranslator();
27
+ const Colors = useThemeColor();
28
+ const navigation = useNavigation();
29
+ const { setActivityIndicator } = useConfig();
30
+ const [loading, setLoading] = useState(false);
31
+ const [showPopup, setShowPopup] = useState(false);
32
+ const [processItem, setProcessItem] = useState();
33
+ const timeoutRef = useRef(null);
34
+ const processOptions = useMemo(() => ({
35
+ name,
36
+ disabled,
37
+ process,
38
+ onSuccess,
39
+ onError,
40
+ }), [name, disabled, process, onSuccess, onError]);
41
+ const onEndProcess = useCallback(() => {
42
+ setLoading(false);
43
+ setShowPopup(false);
44
+ }, []);
45
+ const handleNotifyMe = useCallback(() => {
46
+ setShowPopup(false);
47
+ setActivityIndicator(false);
48
+ processProvider.notifyMe(processItem.key);
49
+ navigation.goBack();
50
+ }, [navigation, processItem, setActivityIndicator]);
51
+ useEffect(() => {
52
+ if (start) {
53
+ const processKey = new Date().getTime().toString();
54
+ const _process = processProvider.registerProcess(processKey, processOptions);
55
+ setProcessItem(_process);
56
+ processProvider.on(processKey, ProcessStatus.InProgress, () => setLoading(true));
57
+ processProvider.on(processKey, ProcessStatus.Success, () => onEndProcess());
58
+ processProvider.on(processKey, ProcessStatus.Failed, () => onEndProcess());
59
+ processProvider.runProcess(processKey, I18n);
60
+ }
61
+ }, [I18n, onEndProcess, processOptions, start]);
62
+ useEffect(() => {
63
+ if (loading) {
64
+ setActivityIndicator(true);
65
+ timeoutRef.current = setTimeout(() => {
66
+ setActivityIndicator(false);
67
+ autoLeave ? handleNotifyMe() : setShowPopup(true);
68
+ }, timeout);
69
+ }
70
+ return () => {
71
+ setActivityIndicator(false);
72
+ clearTimeout(timeoutRef.current);
73
+ };
74
+ }, [
75
+ autoLeave,
76
+ handleNotifyMe,
77
+ loading,
78
+ setActivityIndicator,
79
+ setShowPopup,
80
+ timeout,
81
+ ]);
82
+ return (<Alert visible={showPopup}>
83
+ <Label type="danger" message={I18n.t('Base_Loader_DoNotCloseTheApp')} iconName="exclamation-triangle-fill"/>
84
+ <View style={styles.loadingContainer}>
85
+ <ActivityIndicator size="large" color={Colors.primaryColor.background}/>
86
+ <Text style={styles.marginLeft} writingType="title">
87
+ {I18n.t('Base_Loader_LoadingInProgress')}
88
+ </Text>
89
+ </View>
90
+ <Button iconName="check-lg" title={I18n.t('Base_Loader_NotifyMe')} onPress={handleNotifyMe}/>
91
+ </Alert>);
92
+ };
93
+ const styles = StyleSheet.create({
94
+ loadingContainer: {
95
+ flexDirection: 'row',
96
+ alignItems: 'center',
97
+ marginVertical: 15,
98
+ },
99
+ marginLeft: {
100
+ marginLeft: 10,
101
+ },
102
+ });
103
+ export default LoaderPopup;
104
+ //# sourceMappingURL=LoaderPopup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoaderPopup.js","sourceRoot":"","sources":["../../../../../src/loader/components/organisms/LoaderPopup/LoaderPopup.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,iBAAiB,EAAE,UAAU,EAAE,IAAI,EAAC,MAAM,cAAc,CAAC;AACjE,OAAO,EACL,KAAK,EACL,MAAM,EACN,KAAK,EACL,IAAI,EACJ,SAAS,EACT,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,aAAa,EAAC,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAc,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAa1D,MAAM,WAAW,GAAG,CAAC,EACnB,KAAK,GAAG,KAAK,EACb,SAAS,GAAG,KAAK,EACjB,OAAO,GAAG,IAAI,EACd,IAAI,EACJ,QAAQ,GAAG,KAAK,EAChB,OAAO,EACP,SAAS,EACT,OAAO,GACU,EAAE,EAAE;IACrB,MAAM,IAAI,GAAG,aAAa,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,aAAa,EAAE,CAAC;IAC/B,MAAM,UAAU,GAAG,aAAa,EAAE,CAAC;IACnC,MAAM,EAAC,oBAAoB,EAAC,GAAG,SAAS,EAAE,CAAC;IAE3C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IACvD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAU,KAAK,CAAC,CAAC;IAC3D,MAAM,CAAC,W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;QAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,OAAO,CACjD;UAAA,CAAC,IAAI,CAAC,CAAC,CAAC,+BAA+B,CAAC,CAC1C;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,IAAI,CACN;MAAA,CAAC,MAAM,CACL,QAAQ,CAAC,UAAU,CACnB,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CACtC,OAAO,CAAC,CAAC,cAAc,CAAC,EAE5B;IAAA,EAAE,KAAK,CAAC,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,gBAAgB,EAAE;QAChB,aAAa,EAAE,KAAK;QACpB,UAAU,EAAE,QAAQ;QACpB,cAAc,EAAE,EAAE;KACnB;IACD,UAAU,EAAE;QACV,UAAU,EAAE,EAAE;KACf;CACF,CAAC,CAAC;AAEH,eAAe,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ export { default as LoaderPopup } from './LoaderPopup/LoaderPopup';
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Axelor Business Solutions
3
+ *
4
+ * Copyright (C) 2024 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
+ export { default as LoaderPopup } from './LoaderPopup/LoaderPopup';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/loader/components/organisms/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAC,OAAO,IAAI,WAAW,EAAC,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Color, ThemeColors } from '@axelor/aos-mobile-ui';
2
+ import { ProcessItem, ProcessStatus } from './types';
3
+ export declare const serialize: (list: ProcessItem[]) => string;
4
+ export declare const deserialize: (data: string) => any[];
5
+ export declare const getProcessStatusColor: (status: ProcessStatus, Colors: ThemeColors) => Color;