@gisce/react-ooui 2.0.0-alpha.62 → 2.0.0-alpha.64
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/dist/react-ooui.es.js +1 -1
- package/dist/react-ooui.es.js.map +1 -1
- package/package.json +7 -9
- package/src/ConnectionProvider.ts +0 -16
- package/src/__tests__/iconMapper.test.ts +0 -30
- package/src/__tests__/searchFilterHelper.spec.ts +0 -386
- package/src/actionbar/ActionButton.tsx +0 -40
- package/src/actionbar/AttachmentsButton.tsx +0 -132
- package/src/actionbar/AttachmentsButtonWrapper.tsx +0 -157
- package/src/actionbar/ButtonWithBadge.tsx +0 -44
- package/src/actionbar/ChangeViewButton.tsx +0 -137
- package/src/actionbar/DashboardActionBar.tsx +0 -63
- package/src/actionbar/DropdownButton.tsx +0 -124
- package/src/actionbar/FormActionBar.tsx +0 -491
- package/src/actionbar/GraphActionBar.tsx +0 -67
- package/src/actionbar/NewButton.tsx +0 -46
- package/src/actionbar/SearchBar.tsx +0 -73
- package/src/actionbar/TreeActionBar.tsx +0 -383
- package/src/common/ButtonWithTooltip.tsx +0 -18
- package/src/common/DatePicker.tsx +0 -98
- package/src/common/Field.tsx +0 -93
- package/src/common/SelectAllRecordsRow.tsx +0 -94
- package/src/common/TimePicker.tsx +0 -38
- package/src/context/ActionViewContext.tsx +0 -213
- package/src/context/ConfigContext.tsx +0 -28
- package/src/context/ContentRootContext.tsx +0 -461
- package/src/context/DashboardActionContext.tsx +0 -44
- package/src/context/FormContext.tsx +0 -79
- package/src/context/FormModalContext.tsx +0 -28
- package/src/context/LocaleContext.tsx +0 -50
- package/src/context/One2manyContext.tsx +0 -45
- package/src/context/TabManagerContext.tsx +0 -117
- package/src/helpers/containerHelper.ts +0 -145
- package/src/helpers/dayjs.ts +0 -21
- package/src/helpers/dynamicColumnsHelper.ts +0 -73
- package/src/helpers/errorHelper.ts +0 -27
- package/src/helpers/filesHelper.ts +0 -41
- package/src/helpers/formHelper.ts +0 -301
- package/src/helpers/iconMapper.ts +0 -164
- package/src/helpers/logInfoHelper.tsx +0 -30
- package/src/helpers/one2manyHelper.ts +0 -194
- package/src/helpers/searchHelper.ts +0 -196
- package/src/helpers/timeHelper.ts +0 -58
- package/src/helpers/treeHelper.tsx +0 -226
- package/src/helpers/viewHelper.ts +0 -23
- package/src/hooks/useEffectDebugger.ts +0 -43
- package/src/hooks/useExport.ts +0 -439
- package/src/hooks/useFetchViews.ts +0 -0
- package/src/hooks/useSearch.ts +0 -434
- package/src/hooks/useWindowDimensions.ts +0 -33
- package/src/index.ts +0 -168
- package/src/locales/ca_ES.tsx +0 -99
- package/src/locales/en_US.tsx +0 -96
- package/src/locales/es_ES.tsx +0 -101
- package/src/stories/Binary.stories.tsx +0 -23
- package/src/stories/Boolean.stories.tsx +0 -22
- package/src/stories/Button.stories.tsx +0 -130
- package/src/stories/Char.stories.tsx +0 -76
- package/src/stories/FiberGrid.stories.tsx +0 -109
- package/src/stories/Float.stories.tsx +0 -22
- package/src/stories/FloatTime.stories.tsx +0 -32
- package/src/stories/Image.stories.tsx +0 -25
- package/src/stories/Integer.stories.tsx +0 -22
- package/src/stories/Label.stories.tsx +0 -100
- package/src/stories/Many2one.stories.tsx +0 -31
- package/src/stories/One2many.stories.tsx +0 -288
- package/src/stories/ProgressBar.stories.tsx +0 -22
- package/src/stories/Reference.stories.tsx +0 -43
- package/src/stories/Selection.stories.tsx +0 -34
- package/src/stories/Separator.stories.tsx +0 -53
- package/src/stories/Text.stories.tsx +0 -35
- package/src/stories/Time.stories.tsx +0 -31
- package/src/stories/Utils.stories.tsx +0 -14
- package/src/stories/containers/Group.stories.tsx +0 -84
- package/src/stories/containers/NewLine.stories.tsx +0 -52
- package/src/stories/containers/Notebook.stories.tsx +0 -188
- package/src/stories/custom/Avatar.stories.tsx +0 -22
- package/src/stories/custom/ButtonGroup.stories.tsx +0 -74
- package/src/stories/custom/CodeEditor.stories.tsx +0 -25
- package/src/stories/custom/Comments.stories.tsx +0 -197
- package/src/stories/custom/Indicator.stories.tsx +0 -36
- package/src/stories/custom/Markdown.stories.tsx +0 -38
- package/src/stories/custom/MultiCheckbox.stories.tsx +0 -60
- package/src/stories/custom/Radio.stories.tsx +0 -68
- package/src/stories/custom/Steps.stories.tsx +0 -43
- package/src/stories/custom/Switch.stories.tsx +0 -23
- package/src/stories/custom/Tag.stories.tsx +0 -66
- package/src/stories/custom/Tags.stories.tsx +0 -74
- package/src/stories/dashboard/Dashboard.stories.tsx +0 -23
- package/src/stories/dashboard/DashboardGrid.stories.tsx +0 -43
- package/src/stories/forms/ActivacioContracteForm.stories.tsx +0 -25
- package/src/stories/forms/Attachment.stories.tsx +0 -24
- package/src/stories/forms/CUPSForm.stories.tsx +0 -25
- package/src/stories/forms/Company.stories.tsx +0 -25
- package/src/stories/forms/CrmCaseForm.stories.tsx +0 -25
- package/src/stories/forms/Documents.stories.tsx +0 -25
- package/src/stories/forms/FormWithGridFiber.stories.tsx +0 -25
- package/src/stories/forms/FormWithLinks.stories.tsx +0 -30
- package/src/stories/forms/Lead.stories.tsx +0 -25
- package/src/stories/forms/ModContractForm.stories.tsx +0 -26
- package/src/stories/forms/PartnersForm.stories.tsx +0 -25
- package/src/stories/forms/PolissaForm.stories.tsx +0 -25
- package/src/stories/forms/PreferencesForm.stories.tsx +0 -691
- package/src/stories/forms/Signatures.stories.tsx +0 -25
- package/src/stories/forms/Switching.stories.tsx +0 -25
- package/src/stories/graphs/GraphIndicator.stories.tsx +0 -20
- package/src/stories/graphs/PieGraph.stories.tsx +0 -78
- package/src/stories/mocks/index.ts +0 -46
- package/src/stories/mocks/mockProvider.ts +0 -189
- package/src/stories/mocks/models/activacioContracte.ts +0 -112
- package/src/stories/mocks/models/attachment.ts +0 -1326
- package/src/stories/mocks/models/butlleti.ts +0 -296
- package/src/stories/mocks/models/company.ts +0 -135
- package/src/stories/mocks/models/crm_case.ts +0 -595
- package/src/stories/mocks/models/cups.ts +0 -937
- package/src/stories/mocks/models/document.ts +0 -223
- package/src/stories/mocks/models/factura.ts +0 -2713
- package/src/stories/mocks/models/form_with_gridfiber.ts +0 -141
- package/src/stories/mocks/models/hist_autoconsum.ts +0 -146
- package/src/stories/mocks/models/lead.ts +0 -2101
- package/src/stories/mocks/models/modcontractual.ts +0 -952
- package/src/stories/mocks/models/partner.ts +0 -1340
- package/src/stories/mocks/models/polissa.ts +0 -3127
- package/src/stories/mocks/models/res_partner_category.ts +0 -15
- package/src/stories/mocks/models/signatura.ts +0 -558
- package/src/stories/mocks/models/switching.ts +0 -767
- package/src/stories/modals/FormModal.stories.tsx +0 -36
- package/src/stories/modals/SearchModal.stories.tsx +0 -37
- package/src/stories/trees/FacturesTree.stories.tsx +0 -16
- package/src/stories/ui/ActionBar.stories.tsx +0 -21
- package/src/stories/ui/FavouriteButton.stories.tsx +0 -16
- package/src/stories/ui/GoToResourceModal.stories.tsx +0 -25
- package/src/stories/views/ActionView.stories.tsx +0 -28
- package/src/stories/views/SearchTree.stories.tsx +0 -1064
- package/src/stories/views/Tab.stories.tsx +0 -93
- package/src/stories/views/TabsAndContent.stories.tsx +0 -88
- package/src/stories/views/Tree.stories.jsx +0 -178
- package/src/stories/views/searchFilter/DateRangePicker.stories.tsx +0 -22
- package/src/stories/views/searchFilter/DateTimeRangePicker.stories.tsx +0 -23
- package/src/stories/views/searchFilter/PairFields.stories.tsx +0 -23
- package/src/stories/views/searchFilter/SearchFilter.stories.tsx +0 -165
- package/src/stories/views/searchFilter/examples/PartnersSearchFilter.stories.tsx +0 -409
- package/src/types/index.ts +0 -392
- package/src/ui/ActionErrorDialog.tsx +0 -24
- package/src/ui/ConfirmDialog.tsx +0 -28
- package/src/ui/ErrorAlert.tsx +0 -37
- package/src/ui/FavouriteButton.tsx +0 -271
- package/src/ui/FormErrorsDialog.tsx +0 -17
- package/src/ui/GenericErrorDialog.tsx +0 -16
- package/src/ui/GoToResourceModal.tsx +0 -76
- package/src/ui/InfoDialog.tsx +0 -13
- package/src/ui/RefreshItemDialog.tsx +0 -29
- package/src/ui/RemoveItemDialog.tsx +0 -20
- package/src/ui/TitleHeader.tsx +0 -117
- package/src/ui/UnlinkItemDialog.tsx +0 -20
- package/src/ui/UnsavedChangesDialog.tsx +0 -29
- package/src/ui/WarningDialog.tsx +0 -17
- package/src/views/ActionView.tsx +0 -526
- package/src/views/CurrentTabContent.tsx +0 -21
- package/src/views/RootView.tsx +0 -509
- package/src/views/TabContent.tsx +0 -31
- package/src/views/TabSelector.tsx +0 -31
- package/src/views/Welcome.tsx +0 -18
- package/src/views/actionViews/DashboardActionView.tsx +0 -52
- package/src/views/actionViews/FormActionView.tsx +0 -70
- package/src/views/actionViews/GraphActionView.tsx +0 -152
- package/src/views/actionViews/TreeActionView.tsx +0 -87
- package/src/views/tabs/Tab.tsx +0 -82
- package/src/widgets/WidgetFactory.tsx +0 -142
- package/src/widgets/base/Binary.tsx +0 -145
- package/src/widgets/base/Boolean.tsx +0 -44
- package/src/widgets/base/Button.tsx +0 -77
- package/src/widgets/base/Char.tsx +0 -157
- package/src/widgets/base/Date.tsx +0 -12
- package/src/widgets/base/DateTime.tsx +0 -12
- package/src/widgets/base/Email.tsx +0 -27
- package/src/widgets/base/Float.tsx +0 -38
- package/src/widgets/base/FloatTime.tsx +0 -73
- package/src/widgets/base/Image.tsx +0 -120
- package/src/widgets/base/Integer.tsx +0 -55
- package/src/widgets/base/Label.tsx +0 -56
- package/src/widgets/base/LinkInput.tsx +0 -106
- package/src/widgets/base/MultiSelection.tsx +0 -90
- package/src/widgets/base/ProgressBar.tsx +0 -38
- package/src/widgets/base/Reference.tsx +0 -115
- package/src/widgets/base/ReferenceTree.tsx +0 -62
- package/src/widgets/base/Selection.tsx +0 -71
- package/src/widgets/base/Separator.tsx +0 -25
- package/src/widgets/base/Text.tsx +0 -162
- package/src/widgets/base/Time.tsx +0 -40
- package/src/widgets/base/Url.tsx +0 -26
- package/src/widgets/base/many2one/Many2one.tsx +0 -322
- package/src/widgets/base/many2one/Many2oneSuffix.tsx +0 -232
- package/src/widgets/base/many2one/Many2oneSuffixModal.tsx +0 -42
- package/src/widgets/base/many2one/Many2oneTree.tsx +0 -18
- package/src/widgets/base/one2many/One2many.tsx +0 -100
- package/src/widgets/base/one2many/One2manyInput.tsx +0 -724
- package/src/widgets/base/one2many/One2manyTopBar.tsx +0 -158
- package/src/widgets/containers/Container.tsx +0 -99
- package/src/widgets/containers/Group.tsx +0 -37
- package/src/widgets/containers/Notebook.tsx +0 -52
- package/src/widgets/custom/Avatar.tsx +0 -40
- package/src/widgets/custom/ButtonGroup.tsx +0 -169
- package/src/widgets/custom/CodeEditor.tsx +0 -32
- package/src/widgets/custom/Comments.tsx +0 -147
- package/src/widgets/custom/FiberGrid.tsx +0 -48
- package/src/widgets/custom/Indicator.tsx +0 -66
- package/src/widgets/custom/Markdown.tsx +0 -32
- package/src/widgets/custom/MultiCheckbox.tsx +0 -165
- package/src/widgets/custom/Radio.tsx +0 -47
- package/src/widgets/custom/Steps.tsx +0 -56
- package/src/widgets/custom/Switch.tsx +0 -26
- package/src/widgets/custom/Tag.tsx +0 -53
- package/src/widgets/custom/Tags.tsx +0 -164
- package/src/widgets/custom/Timeline.tsx +0 -196
- package/src/widgets/modals/ExportModal.tsx +0 -75
- package/src/widgets/modals/FormModal.tsx +0 -125
- package/src/widgets/modals/SearchModal.tsx +0 -130
- package/src/widgets/modals/TranslationModal.tsx +0 -202
- package/src/widgets/views/Dashboard/Dashboard.tsx +0 -381
- package/src/widgets/views/Dashboard/DashboardForm.tsx +0 -30
- package/src/widgets/views/Dashboard/DashboardTree.tsx +0 -238
- package/src/widgets/views/Dashboard/dashboardHelper.ts +0 -79
- package/src/widgets/views/DashboardGrid/DashboardGrid.tsx +0 -53
- package/src/widgets/views/DashboardGrid/DashboardGrid.types.ts +0 -4
- package/src/widgets/views/DashboardGrid/DashboardGridItem.tsx +0 -62
- package/src/widgets/views/DashboardGrid/DashboardGridItem.types.ts +0 -10
- package/src/widgets/views/DashboardGrid/index.ts +0 -4
- package/src/widgets/views/Form.tsx +0 -1152
- package/src/widgets/views/Graph/Graph.tsx +0 -145
- package/src/widgets/views/Graph/GraphChart.tsx +0 -113
- package/src/widgets/views/Graph/GraphDefaults.ts +0 -170
- package/src/widgets/views/Graph/GraphIndicator.tsx +0 -421
- package/src/widgets/views/Graph/useGraphData.tsx +0 -176
- package/src/widgets/views/SearchTree.tsx +0 -367
- package/src/widgets/views/Tree/Tree.tsx +0 -295
- package/src/widgets/views/Tree/index.ts +0 -1
- package/src/widgets/views/Tree/treeComponents.tsx +0 -283
- package/src/widgets/views/searchFilter/DateRangePicker.tsx +0 -16
- package/src/widgets/views/searchFilter/DateTimeRangePicker.tsx +0 -87
- package/src/widgets/views/searchFilter/PairFields.tsx +0 -56
- package/src/widgets/views/searchFilter/SearchBottomBar.tsx +0 -54
- package/src/widgets/views/searchFilter/SearchField.tsx +0 -63
- package/src/widgets/views/searchFilter/SearchFilter.tsx +0 -160
- package/src/widgets/views/searchFilter/SearchParams.tsx +0 -35
|
@@ -1,461 +0,0 @@
|
|
|
1
|
-
import { FormView, GenerateReportOptions, ViewType } from "@/types";
|
|
2
|
-
import React, {
|
|
3
|
-
useContext,
|
|
4
|
-
useRef,
|
|
5
|
-
useState,
|
|
6
|
-
forwardRef,
|
|
7
|
-
useImperativeHandle,
|
|
8
|
-
} from "react";
|
|
9
|
-
import showErrorDialog from "@/ui/ActionErrorDialog";
|
|
10
|
-
import { openBase64InNewTab, getMimeType } from "@/helpers/filesHelper";
|
|
11
|
-
import { parseContext } from "@gisce/ooui";
|
|
12
|
-
import ConnectionProvider from "@/ConnectionProvider";
|
|
13
|
-
import { Modal, Spin } from "antd";
|
|
14
|
-
import {
|
|
15
|
-
TabManagerContext,
|
|
16
|
-
TabManagerContextType,
|
|
17
|
-
} from "@/context/TabManagerContext";
|
|
18
|
-
import { FormModal } from "@/widgets/modals/FormModal";
|
|
19
|
-
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
20
|
-
import { transformPlainMany2Ones, stringFormat } from "@/helpers/formHelper";
|
|
21
|
-
|
|
22
|
-
export type ContentRootContextType = {
|
|
23
|
-
processAction: ({
|
|
24
|
-
actionData,
|
|
25
|
-
fields,
|
|
26
|
-
values,
|
|
27
|
-
context,
|
|
28
|
-
}: {
|
|
29
|
-
actionData: any;
|
|
30
|
-
fields: any;
|
|
31
|
-
values: any;
|
|
32
|
-
context?: any;
|
|
33
|
-
onRefreshParentValues?: () => void;
|
|
34
|
-
}) => Promise<any>;
|
|
35
|
-
globalValues?: any;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
type ActionModalOpts = {
|
|
39
|
-
model?: string;
|
|
40
|
-
domain?: any;
|
|
41
|
-
context: any;
|
|
42
|
-
formView?: FormView;
|
|
43
|
-
actionData?: any;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const ContentRootContext =
|
|
47
|
-
React.createContext<ContentRootContextType | null>(null);
|
|
48
|
-
|
|
49
|
-
type ContentRootProviderProps = {
|
|
50
|
-
children: React.ReactNode;
|
|
51
|
-
globalValues?: any;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const callRefreshValues = async (fns: any[]) => {
|
|
55
|
-
for (let i = 0; i < fns.length; i++) {
|
|
56
|
-
await fns?.[i]?.();
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const ContentRootProvider = (
|
|
61
|
-
props: ContentRootProviderProps,
|
|
62
|
-
ref: any,
|
|
63
|
-
): any => {
|
|
64
|
-
const { children, globalValues = {} } = props;
|
|
65
|
-
const reportInProgressInterval = useRef<any>();
|
|
66
|
-
const waitingForReport = useRef<boolean>();
|
|
67
|
-
const [reportGenerating, setReportGenerating] = useState<boolean>(false);
|
|
68
|
-
const tabManagerContext = useContext(
|
|
69
|
-
TabManagerContext,
|
|
70
|
-
) as TabManagerContextType;
|
|
71
|
-
const { openAction } = tabManagerContext || {};
|
|
72
|
-
const onRefreshParentValues = useRef<any>([]);
|
|
73
|
-
const { t } = useContext(LocaleContext) as LocaleContextType;
|
|
74
|
-
|
|
75
|
-
useImperativeHandle(ref, () => ({
|
|
76
|
-
openActionModal,
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
// Action modal state
|
|
80
|
-
const [actionModalVisible, setActionModalVisible] = useState<boolean>(false);
|
|
81
|
-
|
|
82
|
-
const [actionModalOptions, setActionModalOptions] = useState<ActionModalOpts>(
|
|
83
|
-
{
|
|
84
|
-
context: {},
|
|
85
|
-
},
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
async function generateReport(options: GenerateReportOptions) {
|
|
89
|
-
const { reportData, fields, values, context = {} } = options;
|
|
90
|
-
|
|
91
|
-
const {
|
|
92
|
-
context: reportContext,
|
|
93
|
-
model,
|
|
94
|
-
datas = {},
|
|
95
|
-
report_name,
|
|
96
|
-
type,
|
|
97
|
-
} = reportData;
|
|
98
|
-
|
|
99
|
-
if (type !== "ir.actions.report.xml") {
|
|
100
|
-
showErrorDialog(`${type} action not supported`);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const { ids } = datas || {};
|
|
105
|
-
|
|
106
|
-
const idsToExecute = ids || [];
|
|
107
|
-
|
|
108
|
-
const reportContextParsed =
|
|
109
|
-
typeof reportContext === "string"
|
|
110
|
-
? parseContext({
|
|
111
|
-
context: reportContext,
|
|
112
|
-
fields,
|
|
113
|
-
values,
|
|
114
|
-
})
|
|
115
|
-
: reportContext;
|
|
116
|
-
|
|
117
|
-
try {
|
|
118
|
-
const newReportId = await ConnectionProvider.getHandler().createReport({
|
|
119
|
-
model,
|
|
120
|
-
name: report_name,
|
|
121
|
-
datas,
|
|
122
|
-
ids: idsToExecute,
|
|
123
|
-
context: { ...context, ...reportContextParsed },
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
setReportGenerating(true);
|
|
127
|
-
|
|
128
|
-
waitingForReport.current = true;
|
|
129
|
-
reportInProgressInterval.current = setInterval(() => {
|
|
130
|
-
evaluateReportStatus(newReportId);
|
|
131
|
-
}, 1000);
|
|
132
|
-
} catch (err) {
|
|
133
|
-
waitingForReport.current = false;
|
|
134
|
-
clearInterval(reportInProgressInterval.current);
|
|
135
|
-
showErrorDialog(err);
|
|
136
|
-
setReportGenerating(false);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
async function evaluateReportStatus(id: any) {
|
|
141
|
-
let reportState;
|
|
142
|
-
try {
|
|
143
|
-
reportState = await ConnectionProvider.getHandler().getReport({
|
|
144
|
-
id,
|
|
145
|
-
});
|
|
146
|
-
if (reportState.state && waitingForReport.current === true) {
|
|
147
|
-
waitingForReport.current = false;
|
|
148
|
-
clearInterval(reportInProgressInterval.current);
|
|
149
|
-
setReportGenerating(false);
|
|
150
|
-
const fileType: any = await getMimeType(reportState.result);
|
|
151
|
-
openBase64InNewTab(reportState.result, fileType.mime);
|
|
152
|
-
}
|
|
153
|
-
} catch (error) {
|
|
154
|
-
waitingForReport.current = false;
|
|
155
|
-
clearInterval(reportInProgressInterval.current);
|
|
156
|
-
setReportGenerating(false);
|
|
157
|
-
showErrorDialog(error.exception || error);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
async function processAction({
|
|
162
|
-
actionData,
|
|
163
|
-
fields,
|
|
164
|
-
values,
|
|
165
|
-
context,
|
|
166
|
-
onRefreshParentValues: onRefreshParentValuesFn,
|
|
167
|
-
}: {
|
|
168
|
-
actionData: any;
|
|
169
|
-
fields: any;
|
|
170
|
-
values: any;
|
|
171
|
-
context?: any;
|
|
172
|
-
onRefreshParentValues?: any;
|
|
173
|
-
}) {
|
|
174
|
-
const { type } = actionData;
|
|
175
|
-
onRefreshParentValues.current.push(onRefreshParentValuesFn);
|
|
176
|
-
|
|
177
|
-
if (type === "ir.actions.report.xml") {
|
|
178
|
-
return await generateReport({
|
|
179
|
-
reportData: actionData,
|
|
180
|
-
fields,
|
|
181
|
-
values,
|
|
182
|
-
context,
|
|
183
|
-
});
|
|
184
|
-
} else if (type === "ir.actions.act_window") {
|
|
185
|
-
return await runAction({ actionData, fields, values, context });
|
|
186
|
-
} else if (type === "ir.actions.act_url") {
|
|
187
|
-
window.open(
|
|
188
|
-
stringFormat(actionData.url, { ...values, context }),
|
|
189
|
-
"_blank",
|
|
190
|
-
);
|
|
191
|
-
} else {
|
|
192
|
-
showErrorDialog(`${type} action not supported`);
|
|
193
|
-
return {};
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
async function runAction({
|
|
198
|
-
actionData: _actionData,
|
|
199
|
-
fields = {},
|
|
200
|
-
values = {},
|
|
201
|
-
context = {},
|
|
202
|
-
}: {
|
|
203
|
-
actionData: any;
|
|
204
|
-
fields?: any;
|
|
205
|
-
values?: any;
|
|
206
|
-
context?: any;
|
|
207
|
-
}) {
|
|
208
|
-
let actionData = _actionData;
|
|
209
|
-
|
|
210
|
-
if (!_actionData.res_model) {
|
|
211
|
-
actionData = (
|
|
212
|
-
await ConnectionProvider.getHandler().readObjects({
|
|
213
|
-
model: "ir.actions.act_window",
|
|
214
|
-
ids: [parseInt(_actionData.id)],
|
|
215
|
-
context,
|
|
216
|
-
})
|
|
217
|
-
)[0];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
const responseContext =
|
|
221
|
-
typeof actionData?.context === "string"
|
|
222
|
-
? parseContext({
|
|
223
|
-
context: actionData.context,
|
|
224
|
-
fields,
|
|
225
|
-
values: { ...values, ...globalValues },
|
|
226
|
-
})
|
|
227
|
-
: actionData.context;
|
|
228
|
-
|
|
229
|
-
const mergedContext = {
|
|
230
|
-
...context,
|
|
231
|
-
...responseContext,
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
let parsedDomain = [];
|
|
235
|
-
|
|
236
|
-
if (actionData.domain) {
|
|
237
|
-
parsedDomain = await ConnectionProvider.getHandler().evalDomain({
|
|
238
|
-
domain: actionData.domain,
|
|
239
|
-
values: transformPlainMany2Ones({
|
|
240
|
-
fields,
|
|
241
|
-
values: { ...values, ...globalValues },
|
|
242
|
-
}),
|
|
243
|
-
fields,
|
|
244
|
-
context: mergedContext,
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// -- Possible values for target property --
|
|
249
|
-
// * new ==> modal
|
|
250
|
-
// * current ==> new tab
|
|
251
|
-
// * undefined ==> new tab
|
|
252
|
-
if (actionData.target === "new") {
|
|
253
|
-
const formView = (await ConnectionProvider.getHandler().getView({
|
|
254
|
-
model: actionData.res_model,
|
|
255
|
-
type: "form",
|
|
256
|
-
id: actionData?.view_id?.[0] || undefined,
|
|
257
|
-
context: mergedContext,
|
|
258
|
-
})) as FormView;
|
|
259
|
-
|
|
260
|
-
openActionModal({
|
|
261
|
-
domain: parsedDomain,
|
|
262
|
-
model: actionData.res_model,
|
|
263
|
-
formView,
|
|
264
|
-
context: mergedContext,
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
return {};
|
|
268
|
-
} else {
|
|
269
|
-
const { initialView, views } = await getViewsAndInitialView({
|
|
270
|
-
model: actionData.res_model,
|
|
271
|
-
context: mergedContext,
|
|
272
|
-
view_mode: actionData.view_mode,
|
|
273
|
-
views: actionData.views,
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
openAction?.({
|
|
277
|
-
target: "current",
|
|
278
|
-
context: mergedContext,
|
|
279
|
-
domain: parsedDomain,
|
|
280
|
-
model: actionData.res_model,
|
|
281
|
-
views,
|
|
282
|
-
title: actionData.name,
|
|
283
|
-
initialView,
|
|
284
|
-
action_id: actionData.id,
|
|
285
|
-
action_type: actionData.type,
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
return { closeParent: true };
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function openActionModal({
|
|
293
|
-
domain,
|
|
294
|
-
model,
|
|
295
|
-
formView,
|
|
296
|
-
context,
|
|
297
|
-
actionData,
|
|
298
|
-
}: {
|
|
299
|
-
domain: any;
|
|
300
|
-
model: string;
|
|
301
|
-
formView: FormView;
|
|
302
|
-
context: any;
|
|
303
|
-
actionData?: any;
|
|
304
|
-
}) {
|
|
305
|
-
if (actionModalVisible) {
|
|
306
|
-
openNewActionModal({ domain, model, formView, context, actionData });
|
|
307
|
-
} else {
|
|
308
|
-
setActionModalOptions({ domain, model, context, formView, actionData });
|
|
309
|
-
setActionModalVisible(true);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
async function openNewActionModal({
|
|
314
|
-
domain,
|
|
315
|
-
model,
|
|
316
|
-
formView,
|
|
317
|
-
context,
|
|
318
|
-
actionData,
|
|
319
|
-
}: {
|
|
320
|
-
domain: any;
|
|
321
|
-
model: string;
|
|
322
|
-
formView: FormView;
|
|
323
|
-
context: any;
|
|
324
|
-
actionData?: any;
|
|
325
|
-
}) {
|
|
326
|
-
setActionModalOptions({
|
|
327
|
-
domain: undefined,
|
|
328
|
-
model: undefined,
|
|
329
|
-
context: {},
|
|
330
|
-
formView: undefined,
|
|
331
|
-
actionData: undefined,
|
|
332
|
-
});
|
|
333
|
-
setActionModalVisible(false);
|
|
334
|
-
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
335
|
-
setActionModalOptions({ domain, model, context, formView, actionData });
|
|
336
|
-
setActionModalVisible(true);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
async function onFormModalSucceed() {
|
|
340
|
-
callRefreshValues(onRefreshParentValues.current);
|
|
341
|
-
onRefreshParentValues.current = [];
|
|
342
|
-
setActionModalVisible(false);
|
|
343
|
-
setActionModalOptions({
|
|
344
|
-
domain: undefined,
|
|
345
|
-
model: undefined,
|
|
346
|
-
context: {},
|
|
347
|
-
formView: undefined,
|
|
348
|
-
actionData: undefined,
|
|
349
|
-
});
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
return (
|
|
353
|
-
<>
|
|
354
|
-
<ContentRootContext.Provider
|
|
355
|
-
value={{
|
|
356
|
-
processAction,
|
|
357
|
-
globalValues,
|
|
358
|
-
}}
|
|
359
|
-
>
|
|
360
|
-
<>
|
|
361
|
-
{children}
|
|
362
|
-
<Modal
|
|
363
|
-
title={t("generatingReport")}
|
|
364
|
-
open={reportGenerating}
|
|
365
|
-
footer={null}
|
|
366
|
-
closable={false}
|
|
367
|
-
centered
|
|
368
|
-
maskClosable={false}
|
|
369
|
-
>
|
|
370
|
-
<Spin />
|
|
371
|
-
</Modal>
|
|
372
|
-
<FormModal
|
|
373
|
-
buttonModal
|
|
374
|
-
parentContext={actionModalOptions.context}
|
|
375
|
-
model={actionModalOptions.model!}
|
|
376
|
-
formView={actionModalOptions.formView}
|
|
377
|
-
visible={actionModalVisible}
|
|
378
|
-
onSubmitSucceed={onFormModalSucceed}
|
|
379
|
-
onCancel={() => {
|
|
380
|
-
callRefreshValues(onRefreshParentValues.current);
|
|
381
|
-
onRefreshParentValues.current = [];
|
|
382
|
-
setActionModalVisible(false);
|
|
383
|
-
setActionModalOptions({
|
|
384
|
-
domain: undefined,
|
|
385
|
-
model: undefined,
|
|
386
|
-
context: {},
|
|
387
|
-
formView: undefined,
|
|
388
|
-
actionData: undefined,
|
|
389
|
-
});
|
|
390
|
-
}}
|
|
391
|
-
showFooter={false}
|
|
392
|
-
actionDomain={actionModalOptions.domain}
|
|
393
|
-
isMenuAction={actionModalOptions?.actionData !== undefined}
|
|
394
|
-
actionData={actionModalOptions?.actionData}
|
|
395
|
-
/>
|
|
396
|
-
</>
|
|
397
|
-
</ContentRootContext.Provider>
|
|
398
|
-
</>
|
|
399
|
-
);
|
|
400
|
-
};
|
|
401
|
-
|
|
402
|
-
async function getViewsAndInitialView({
|
|
403
|
-
views,
|
|
404
|
-
view_mode,
|
|
405
|
-
model,
|
|
406
|
-
context,
|
|
407
|
-
view_id,
|
|
408
|
-
}: {
|
|
409
|
-
views: any[];
|
|
410
|
-
view_mode: string;
|
|
411
|
-
model: string;
|
|
412
|
-
context: any;
|
|
413
|
-
view_id?: number;
|
|
414
|
-
}) {
|
|
415
|
-
const retriedViewData = [];
|
|
416
|
-
let initialView;
|
|
417
|
-
|
|
418
|
-
if (views) {
|
|
419
|
-
for (const view of views) {
|
|
420
|
-
const viewData = await ConnectionProvider.getHandler().getView({
|
|
421
|
-
model,
|
|
422
|
-
type: view[1],
|
|
423
|
-
id: view[0],
|
|
424
|
-
context,
|
|
425
|
-
});
|
|
426
|
-
retriedViewData.push([viewData.view_id, view[1]]);
|
|
427
|
-
}
|
|
428
|
-
} else {
|
|
429
|
-
const viewTypes = view_mode.split(",");
|
|
430
|
-
for (const viewType of viewTypes) {
|
|
431
|
-
const viewData = await ConnectionProvider.getHandler().getView({
|
|
432
|
-
model,
|
|
433
|
-
type: viewType as ViewType,
|
|
434
|
-
context,
|
|
435
|
-
});
|
|
436
|
-
retriedViewData.push([viewData.view_id, viewType]);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
if (views && views.length > 0) {
|
|
440
|
-
const [id, type] = views[0];
|
|
441
|
-
initialView = {
|
|
442
|
-
id,
|
|
443
|
-
type,
|
|
444
|
-
};
|
|
445
|
-
} else if (!view_id) {
|
|
446
|
-
const type = view_mode.split(",")[0];
|
|
447
|
-
const [retrievedViewId] = retriedViewData.find(
|
|
448
|
-
([_, viewType]) => viewType === type,
|
|
449
|
-
)!;
|
|
450
|
-
initialView = { id: retrievedViewId, type };
|
|
451
|
-
} else {
|
|
452
|
-
initialView = {
|
|
453
|
-
id: view_id,
|
|
454
|
-
type: view_mode.split(",")[0],
|
|
455
|
-
};
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
return { views: retriedViewData, initialView };
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
export default forwardRef(ContentRootProvider);
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ShortcutApi } from "@/ui/FavouriteButton";
|
|
2
|
-
import React, { useState } from "react";
|
|
3
|
-
|
|
4
|
-
export type DashboardActionContextType = {
|
|
5
|
-
isLoading: boolean;
|
|
6
|
-
setIsLoading: (value: boolean) => void;
|
|
7
|
-
dashboardRef: any;
|
|
8
|
-
openAction: (action?: ShortcutApi) => void;
|
|
9
|
-
moveItemsEnabled: boolean;
|
|
10
|
-
setMoveItemsEnabled: (value: boolean) => void;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const DashboardActionContext =
|
|
14
|
-
React.createContext<DashboardActionContextType | null>(null);
|
|
15
|
-
|
|
16
|
-
type DashboardActionProviderProps = {
|
|
17
|
-
children: React.ReactNode;
|
|
18
|
-
dashboardRef: any;
|
|
19
|
-
openAction: (action?: ShortcutApi) => void;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const DashboardActionProvider = (props: DashboardActionProviderProps): any => {
|
|
23
|
-
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
24
|
-
const [moveItemsEnabled, setMoveItemsEnabled] = useState<boolean>(false);
|
|
25
|
-
|
|
26
|
-
const { children, dashboardRef, openAction } = props;
|
|
27
|
-
|
|
28
|
-
return (
|
|
29
|
-
<DashboardActionContext.Provider
|
|
30
|
-
value={{
|
|
31
|
-
isLoading,
|
|
32
|
-
setIsLoading,
|
|
33
|
-
dashboardRef,
|
|
34
|
-
openAction,
|
|
35
|
-
moveItemsEnabled,
|
|
36
|
-
setMoveItemsEnabled,
|
|
37
|
-
}}
|
|
38
|
-
>
|
|
39
|
-
{children}
|
|
40
|
-
</DashboardActionContext.Provider>
|
|
41
|
-
);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export default DashboardActionProvider;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState } from "react";
|
|
2
|
-
|
|
3
|
-
export type FormContextType = {
|
|
4
|
-
activeId?: number;
|
|
5
|
-
activeModel: string;
|
|
6
|
-
setFieldValue: (field: string, value?: string) => void;
|
|
7
|
-
getFieldValue: (field: string) => string;
|
|
8
|
-
executeButtonAction: ({
|
|
9
|
-
type,
|
|
10
|
-
action,
|
|
11
|
-
context,
|
|
12
|
-
}: {
|
|
13
|
-
type: string;
|
|
14
|
-
action: string;
|
|
15
|
-
context?: any;
|
|
16
|
-
}) => Promise<void>;
|
|
17
|
-
getContext: () => Promise<any>;
|
|
18
|
-
getValues: () => Promise<any>;
|
|
19
|
-
getPlainValues: () => { [key: string]: any };
|
|
20
|
-
getFields: () => Promise<any>;
|
|
21
|
-
domain: any[];
|
|
22
|
-
submitForm?: (options?: {
|
|
23
|
-
callOnSubmitSucceed?: boolean;
|
|
24
|
-
}) => Promise<{ succeed: boolean; id: number }>;
|
|
25
|
-
fetchValues?: () => void;
|
|
26
|
-
formHasChanges?: () => boolean;
|
|
27
|
-
elementHasLostFocus?: () => void;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const FormContext = React.createContext<FormContextType | null>(null);
|
|
31
|
-
|
|
32
|
-
type FormProviderProps = FormContextType & {
|
|
33
|
-
children: React.ReactNode;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const FormProvider = (props: FormProviderProps): any => {
|
|
37
|
-
const {
|
|
38
|
-
children,
|
|
39
|
-
activeId,
|
|
40
|
-
activeModel,
|
|
41
|
-
setFieldValue,
|
|
42
|
-
getFieldValue,
|
|
43
|
-
executeButtonAction,
|
|
44
|
-
getContext,
|
|
45
|
-
getValues,
|
|
46
|
-
getPlainValues,
|
|
47
|
-
domain,
|
|
48
|
-
submitForm,
|
|
49
|
-
fetchValues,
|
|
50
|
-
formHasChanges,
|
|
51
|
-
elementHasLostFocus,
|
|
52
|
-
getFields,
|
|
53
|
-
} = props;
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<FormContext.Provider
|
|
57
|
-
value={{
|
|
58
|
-
domain,
|
|
59
|
-
getValues,
|
|
60
|
-
getPlainValues,
|
|
61
|
-
getFields,
|
|
62
|
-
activeId,
|
|
63
|
-
activeModel,
|
|
64
|
-
setFieldValue,
|
|
65
|
-
getFieldValue,
|
|
66
|
-
executeButtonAction,
|
|
67
|
-
getContext,
|
|
68
|
-
submitForm,
|
|
69
|
-
fetchValues,
|
|
70
|
-
formHasChanges,
|
|
71
|
-
elementHasLostFocus,
|
|
72
|
-
}}
|
|
73
|
-
>
|
|
74
|
-
{children}
|
|
75
|
-
</FormContext.Provider>
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export default FormProvider;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
export type FormModalContextType = {
|
|
4
|
-
setTitle?: (title: string) => void;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const FormModalContext =
|
|
8
|
-
React.createContext<FormModalContextType | null>(null);
|
|
9
|
-
|
|
10
|
-
type FormModalProviderProps = FormModalContextType & {
|
|
11
|
-
children: React.ReactNode;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const FormModalProvider = (props: FormModalProviderProps): any => {
|
|
15
|
-
const { children, setTitle } = props;
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<FormModalContext.Provider
|
|
19
|
-
value={{
|
|
20
|
-
setTitle,
|
|
21
|
-
}}
|
|
22
|
-
>
|
|
23
|
-
{children}
|
|
24
|
-
</FormModalContext.Provider>
|
|
25
|
-
);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export default FormModalProvider;
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ca_ES from "@/locales/ca_ES";
|
|
3
|
-
import en_US from "@/locales/en_US";
|
|
4
|
-
import es_ES from "@/locales/es_ES";
|
|
5
|
-
|
|
6
|
-
const localeStrings: any = {
|
|
7
|
-
ca_ES,
|
|
8
|
-
en_US,
|
|
9
|
-
es_ES,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type LocaleContextType = {
|
|
13
|
-
lang: string;
|
|
14
|
-
t: (key: string) => string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const LocaleContext = React.createContext<LocaleContextType | null>(
|
|
18
|
-
null,
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
type LocaleContextProps = {
|
|
22
|
-
children: React.ReactNode;
|
|
23
|
-
lang: string;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const LocaleContextProvider = (props: LocaleContextProps): any => {
|
|
27
|
-
const { children, lang } = props;
|
|
28
|
-
|
|
29
|
-
function t(key: string): string {
|
|
30
|
-
return tForLang(key, lang);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<LocaleContext.Provider
|
|
35
|
-
value={{
|
|
36
|
-
lang,
|
|
37
|
-
t,
|
|
38
|
-
}}
|
|
39
|
-
>
|
|
40
|
-
{children}
|
|
41
|
-
</LocaleContext.Provider>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const tForLang = (key: string, lang: string) => {
|
|
46
|
-
const translated = localeStrings[lang]?.[key];
|
|
47
|
-
return translated || key;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default LocaleContextProvider;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ViewType } from "@/types";
|
|
2
|
-
import React, { useState } from "react";
|
|
3
|
-
|
|
4
|
-
export type One2manyContextType = {
|
|
5
|
-
currentView: ViewType;
|
|
6
|
-
setCurrentView: (view: ViewType) => void;
|
|
7
|
-
itemIndex: number;
|
|
8
|
-
setItemIndex: (value: number) => void;
|
|
9
|
-
manualTriggerChange: boolean;
|
|
10
|
-
setManualTriggerChange: (value: boolean) => void;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const One2manyContext = React.createContext<One2manyContextType | null>(
|
|
14
|
-
null,
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
const One2manyProvider = ({
|
|
18
|
-
children,
|
|
19
|
-
initialView,
|
|
20
|
-
}: {
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
initialView: ViewType;
|
|
23
|
-
}): any => {
|
|
24
|
-
const [currentView, setCurrentView] = useState<ViewType>(initialView);
|
|
25
|
-
const [itemIndex, setItemIndex] = useState<number>(0);
|
|
26
|
-
const [manualTriggerChange, setManualTriggerChange] =
|
|
27
|
-
useState<boolean>(false);
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<One2manyContext.Provider
|
|
31
|
-
value={{
|
|
32
|
-
currentView,
|
|
33
|
-
setCurrentView,
|
|
34
|
-
itemIndex,
|
|
35
|
-
setItemIndex,
|
|
36
|
-
manualTriggerChange,
|
|
37
|
-
setManualTriggerChange,
|
|
38
|
-
}}
|
|
39
|
-
>
|
|
40
|
-
{children}
|
|
41
|
-
</One2manyContext.Provider>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export default One2manyProvider;
|