@gisce/react-ooui 1.2.0-rc.5 → 1.2.0-rc.50
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/actionbar/FormActionBar.d.ts.map +1 -1
- package/dist/actionbar/TreeActionBar.d.ts.map +1 -1
- package/dist/context/ActionViewContext.d.ts +5 -1
- package/dist/context/ActionViewContext.d.ts.map +1 -1
- package/dist/context/ContentRootContext.d.ts.map +1 -1
- package/dist/context/FormContext.d.ts +4 -1
- package/dist/context/FormContext.d.ts.map +1 -1
- package/dist/helpers/formHelper.d.ts +5 -3
- package/dist/helpers/formHelper.d.ts.map +1 -1
- package/dist/helpers/iconMapper.d.ts +5 -1
- package/dist/helpers/iconMapper.d.ts.map +1 -1
- package/dist/helpers/one2manyHelper.d.ts +2 -1
- package/dist/helpers/one2manyHelper.d.ts.map +1 -1
- package/dist/helpers/searchHelper.d.ts +1 -1
- package/dist/helpers/searchHelper.d.ts.map +1 -1
- package/dist/helpers/treeHelper.d.ts +1 -1
- package/dist/helpers/treeHelper.d.ts.map +1 -1
- package/dist/hooks/useExport.d.ts +39 -0
- package/dist/hooks/useExport.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/locales/ca_ES.d.ts +2 -0
- package/dist/locales/ca_ES.d.ts.map +1 -1
- package/dist/locales/en_US.d.ts +2 -0
- package/dist/locales/en_US.d.ts.map +1 -1
- package/dist/locales/es_ES.d.ts +2 -0
- package/dist/locales/es_ES.d.ts.map +1 -1
- package/dist/react-ooui.es.js +19204 -21320
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +45 -183
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/views/ActionView.d.ts.map +1 -1
- package/dist/views/RootView.d.ts.map +1 -1
- package/dist/views/actionViews/TreeActionView.d.ts.map +1 -1
- package/dist/widgets/WidgetFactory.d.ts.map +1 -1
- package/dist/widgets/base/Integer.d.ts.map +1 -1
- package/dist/widgets/base/Label.d.ts.map +1 -1
- package/dist/widgets/base/ReferenceTree.d.ts +8 -0
- package/dist/widgets/base/ReferenceTree.d.ts.map +1 -0
- package/dist/widgets/base/many2one/Many2one.d.ts.map +1 -1
- package/dist/widgets/base/many2one/Many2oneTree.d.ts +6 -0
- package/dist/widgets/base/many2one/Many2oneTree.d.ts.map +1 -0
- package/dist/widgets/base/one2many/One2manyInput.d.ts.map +1 -1
- package/dist/widgets/custom/MultiCheckbox.d.ts.map +1 -1
- package/dist/widgets/custom/Tag.d.ts +5 -0
- package/dist/widgets/custom/Tag.d.ts.map +1 -0
- package/dist/widgets/custom/Tags.d.ts.map +1 -1
- package/dist/widgets/modals/ExportModal.d.ts +2 -1
- package/dist/widgets/modals/ExportModal.d.ts.map +1 -1
- package/dist/widgets/views/Dashboard/Dashboard.d.ts.map +1 -1
- package/dist/widgets/views/Dashboard/DashboardTree.d.ts.map +1 -1
- package/dist/widgets/views/Form.d.ts.map +1 -1
- package/dist/widgets/views/Graph/GraphChart.d.ts.map +1 -1
- package/dist/widgets/views/Graph/GraphDefaults.d.ts +36 -0
- package/dist/widgets/views/Graph/GraphDefaults.d.ts.map +1 -1
- package/dist/widgets/views/SearchTree.d.ts.map +1 -1
- package/dist/widgets/views/Tree.d.ts +2 -0
- package/dist/widgets/views/Tree.d.ts.map +1 -1
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts +1 -0
- package/dist/widgets/views/searchFilter/SearchFilter.d.ts.map +1 -1
- package/package.json +6 -5
- package/src/__tests__/iconMapper.test.ts +20 -5
- package/src/actionbar/ChangeViewButton.tsx +2 -2
- package/src/actionbar/FormActionBar.tsx +82 -11
- package/src/actionbar/TreeActionBar.tsx +23 -28
- package/src/context/ActionViewContext.tsx +7 -4
- package/src/context/ContentRootContext.tsx +15 -7
- package/src/context/FormContext.tsx +1 -1
- package/src/helpers/formHelper.ts +26 -5
- package/src/helpers/iconMapper.ts +134 -107
- package/src/helpers/one2manyHelper.ts +27 -9
- package/src/helpers/searchHelper.ts +8 -7
- package/src/helpers/treeHelper.ts +17 -5
- package/src/hooks/useExport.ts +438 -0
- package/src/index.ts +2 -0
- package/src/locales/ca_ES.tsx +2 -0
- package/src/locales/en_US.tsx +2 -0
- package/src/locales/es_ES.tsx +2 -0
- package/src/stories/Label.stories.tsx +7 -8
- package/src/stories/containers/Notebook.stories.tsx +27 -0
- package/src/stories/custom/Tag.stories.tsx +57 -0
- package/src/stories/mocks/models/crm_case.ts +7 -10
- package/src/stories/views/Tree.stories.jsx +5 -5
- package/src/types/index.ts +1 -0
- package/src/ui/FavouriteButton.tsx +4 -4
- package/src/views/ActionView.tsx +3 -0
- package/src/views/RootView.tsx +7 -1
- package/src/views/actionViews/TreeActionView.tsx +10 -1
- package/src/widgets/WidgetFactory.tsx +3 -0
- package/src/widgets/base/Integer.tsx +1 -0
- package/src/widgets/base/Label.tsx +5 -9
- package/src/widgets/base/ReferenceTree.tsx +62 -0
- package/src/widgets/base/many2one/Many2one.tsx +8 -9
- package/src/widgets/base/many2one/Many2oneTree.tsx +18 -0
- package/src/widgets/base/one2many/One2manyInput.tsx +2 -0
- package/src/widgets/containers/Group.tsx +3 -3
- package/src/widgets/custom/ButtonGroup.tsx +1 -1
- package/src/widgets/custom/MultiCheckbox.tsx +1 -0
- package/src/widgets/custom/Tag.tsx +24 -0
- package/src/widgets/custom/Tags.tsx +27 -28
- package/src/widgets/modals/ExportModal.tsx +33 -134
- package/src/widgets/views/Dashboard/Dashboard.tsx +5 -1
- package/src/widgets/views/Dashboard/DashboardTree.tsx +1 -0
- package/src/widgets/views/Form.tsx +35 -24
- package/src/widgets/views/Graph/GraphChart.tsx +6 -1
- package/src/widgets/views/Graph/GraphDefaults.ts +60 -0
- package/src/widgets/views/Graph/GraphIndicator.tsx +17 -3
- package/src/widgets/views/SearchTree.tsx +3 -0
- package/src/widgets/views/Tree.tsx +88 -25
- package/src/widgets/views/searchFilter/SearchFilter.tsx +12 -6
- package/dist/helpers/icons/antd_icons.d.ts +0 -4
- package/dist/helpers/icons/antd_icons.d.ts.map +0 -1
- package/dist/helpers/icons/tabler_icons.d.ts +0 -4
- package/dist/helpers/icons/tabler_icons.d.ts.map +0 -1
- package/dist/ui/Fieldset.d.ts +0 -8
- package/dist/ui/Fieldset.d.ts.map +0 -1
- package/src/helpers/icons/antd_icons.ts +0 -1583
- package/src/helpers/icons/tabler_icons.ts +0 -5367
- package/src/ui/Fieldset.tsx +0 -31
|
@@ -3,22 +3,20 @@ import {
|
|
|
3
3
|
ExportModal as ExportModalFmg,
|
|
4
4
|
Locale,
|
|
5
5
|
} from "@gisce/react-formiga-components";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import showInfo from "@/ui/InfoDialog";
|
|
9
|
-
import { tForLang } from "@/context/LocaleContext";
|
|
10
|
-
import { getMimeType, openBase64InNewTab } from "@/helpers/filesHelper";
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { useExport } from "@/hooks/useExport";
|
|
11
8
|
|
|
12
9
|
export type ExportModalProps = {
|
|
13
10
|
visible: boolean;
|
|
14
11
|
locale: string;
|
|
15
12
|
onClose: () => void;
|
|
16
|
-
selectedRegistersToExport?:
|
|
13
|
+
selectedRegistersToExport?: any[];
|
|
17
14
|
totalRegisters: number;
|
|
18
15
|
model: string;
|
|
19
16
|
domain: any[];
|
|
20
17
|
limit?: number;
|
|
21
18
|
context?: any;
|
|
19
|
+
visibleRegisters: number;
|
|
22
20
|
};
|
|
23
21
|
|
|
24
22
|
export const ExportModal = (props: ExportModalProps) => {
|
|
@@ -32,145 +30,46 @@ export const ExportModal = (props: ExportModalProps) => {
|
|
|
32
30
|
totalRegisters,
|
|
33
31
|
domain,
|
|
34
32
|
limit,
|
|
33
|
+
visibleRegisters,
|
|
35
34
|
} = props;
|
|
36
|
-
const fields = useRef<any>({});
|
|
37
35
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
onClose();
|
|
55
|
-
|
|
56
|
-
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
57
|
-
|
|
58
|
-
const fileType: any = await getMimeType(datas);
|
|
59
|
-
openBase64InNewTab(datas, fileType.mime);
|
|
60
|
-
},
|
|
61
|
-
[locale, model, domain, limit, context, onClose]
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const onGetFields = useCallback(async () => {
|
|
65
|
-
const viewData = await ConnectionProvider.getHandler().getFields({
|
|
66
|
-
model,
|
|
67
|
-
context,
|
|
68
|
-
fields: [],
|
|
69
|
-
});
|
|
70
|
-
fields.current["/"] = viewData;
|
|
71
|
-
return convertToExportField({ fields: viewData });
|
|
72
|
-
}, [model, context, fields]);
|
|
73
|
-
|
|
74
|
-
const onGetFieldChilds = useCallback(
|
|
75
|
-
async ({ key, title }: any) => {
|
|
76
|
-
let fieldDefinition;
|
|
77
|
-
|
|
78
|
-
const sanitizedKey =
|
|
79
|
-
key.split("/")[key.split("/").length - 1] === "id"
|
|
80
|
-
? key.split("/").slice(0, -1).join("/")
|
|
81
|
-
: key;
|
|
82
|
-
|
|
83
|
-
if (sanitizedKey.indexOf("/") === -1) {
|
|
84
|
-
fieldDefinition = fields.current["/"];
|
|
85
|
-
} else {
|
|
86
|
-
fieldDefinition = fields.current[getParentKey(sanitizedKey)];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const optsForField = fieldDefinition[getChildKey(sanitizedKey)];
|
|
90
|
-
const relation = optsForField.relation;
|
|
91
|
-
const viewData = await ConnectionProvider.getHandler().getFields({
|
|
92
|
-
model: relation,
|
|
93
|
-
context,
|
|
94
|
-
fields: [],
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
fields.current[sanitizedKey] = viewData;
|
|
98
|
-
|
|
99
|
-
return convertToExportField({
|
|
100
|
-
fields: viewData,
|
|
101
|
-
parentTitle: title,
|
|
102
|
-
parentKey: sanitizedKey,
|
|
103
|
-
});
|
|
104
|
-
},
|
|
105
|
-
[fields, model, context]
|
|
106
|
-
);
|
|
36
|
+
const {
|
|
37
|
+
onExport,
|
|
38
|
+
onGetFieldChilds,
|
|
39
|
+
onGetFields,
|
|
40
|
+
onGetPredefinedExports,
|
|
41
|
+
onSavePredefinedExport,
|
|
42
|
+
onRemovePredefinedExport,
|
|
43
|
+
} = useExport({
|
|
44
|
+
model,
|
|
45
|
+
context,
|
|
46
|
+
domain,
|
|
47
|
+
limit,
|
|
48
|
+
selectedRegistersToExport,
|
|
49
|
+
onClose,
|
|
50
|
+
locale,
|
|
51
|
+
});
|
|
107
52
|
|
|
108
53
|
return (
|
|
109
54
|
<ExportModalFmg
|
|
110
55
|
visible={visible}
|
|
111
56
|
locale={locale as Locale}
|
|
112
|
-
onSucceed={
|
|
57
|
+
onSucceed={onExport}
|
|
113
58
|
onCancel={onClose}
|
|
114
|
-
selectedRegistersToExport={
|
|
59
|
+
selectedRegistersToExport={
|
|
60
|
+
selectedRegistersToExport &&
|
|
61
|
+
selectedRegistersToExport.length &&
|
|
62
|
+
selectedRegistersToExport.length > 0
|
|
63
|
+
? selectedRegistersToExport.length
|
|
64
|
+
: undefined
|
|
65
|
+
}
|
|
115
66
|
totalRegisters={totalRegisters}
|
|
116
67
|
onGetFieldChilds={onGetFieldChilds}
|
|
117
68
|
onGetFields={onGetFields}
|
|
69
|
+
visibleRegisters={visibleRegisters}
|
|
70
|
+
onGetPredefinedExports={onGetPredefinedExports}
|
|
71
|
+
onSavePredefinedExport={onSavePredefinedExport}
|
|
72
|
+
onRemovePredefinedExport={onRemovePredefinedExport}
|
|
118
73
|
/>
|
|
119
74
|
);
|
|
120
75
|
};
|
|
121
|
-
|
|
122
|
-
const convertToExportField = ({
|
|
123
|
-
fields,
|
|
124
|
-
parentKey,
|
|
125
|
-
parentTitle,
|
|
126
|
-
}: {
|
|
127
|
-
fields: any;
|
|
128
|
-
parentTitle?: string;
|
|
129
|
-
parentKey?: string;
|
|
130
|
-
}) => {
|
|
131
|
-
const exportFields = [];
|
|
132
|
-
|
|
133
|
-
for (const key of Object.keys(fields)) {
|
|
134
|
-
const valuesForField = fields[key];
|
|
135
|
-
|
|
136
|
-
if (valuesForField.relation && valuesForField.is_function === true) {
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const relationField =
|
|
141
|
-
valuesForField.type === "many2one" ||
|
|
142
|
-
valuesForField.type === "one2many" ||
|
|
143
|
-
valuesForField.type === "many2many";
|
|
144
|
-
|
|
145
|
-
let newKey = `${parentKey ? parentKey + "/" : ""}${key}`;
|
|
146
|
-
|
|
147
|
-
if (relationField) {
|
|
148
|
-
newKey += "/id";
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
exportFields.push({
|
|
152
|
-
key: newKey,
|
|
153
|
-
title: `${parentTitle ? parentTitle + "/" : ""}${valuesForField.string}`,
|
|
154
|
-
tooltip: valuesForField.help,
|
|
155
|
-
required: valuesForField.required,
|
|
156
|
-
isLeaf: !relationField,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
return exportFields;
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
const getParentKey = (key: string) => {
|
|
163
|
-
if (key.indexOf("/") === -1) {
|
|
164
|
-
return key;
|
|
165
|
-
}
|
|
166
|
-
const items = key.split("/");
|
|
167
|
-
return items.slice(0, -1).join("/");
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const getChildKey = (key: string) => {
|
|
171
|
-
if (key.indexOf("/") === -1) {
|
|
172
|
-
return key;
|
|
173
|
-
}
|
|
174
|
-
const items = key.split("/");
|
|
175
|
-
return items[items.length - 1];
|
|
176
|
-
};
|
|
@@ -308,6 +308,10 @@ function Dashboard(props: DashboardProps, ref: any) {
|
|
|
308
308
|
/>
|
|
309
309
|
);
|
|
310
310
|
} else if (initialView !== undefined) {
|
|
311
|
+
const formattedInitialView =
|
|
312
|
+
initialView && Array.isArray(initialView.id)
|
|
313
|
+
? { ...initialView, id: initialView.id[0] }
|
|
314
|
+
: initialView;
|
|
311
315
|
childContent = (
|
|
312
316
|
<ActionView
|
|
313
317
|
action_id={actionId}
|
|
@@ -319,7 +323,7 @@ function Dashboard(props: DashboardProps, ref: any) {
|
|
|
319
323
|
context={context}
|
|
320
324
|
domain={domain}
|
|
321
325
|
setCanWeClose={() => {}}
|
|
322
|
-
initialView={
|
|
326
|
+
initialView={formattedInitialView}
|
|
323
327
|
limit={limit}
|
|
324
328
|
/>
|
|
325
329
|
);
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
Row,
|
|
16
16
|
Alert,
|
|
17
17
|
Spin,
|
|
18
|
+
message,
|
|
18
19
|
} from "antd";
|
|
19
20
|
import Measure from "react-measure";
|
|
20
21
|
import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
|
|
@@ -54,6 +55,7 @@ import {
|
|
|
54
55
|
ContentRootContextType,
|
|
55
56
|
} from "@/context/ContentRootContext";
|
|
56
57
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
58
|
+
import { convertToPlain2ManyValues } from "@/helpers/one2manyHelper";
|
|
57
59
|
|
|
58
60
|
export type FormProps = {
|
|
59
61
|
model: string;
|
|
@@ -105,7 +107,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
105
107
|
defaultValues,
|
|
106
108
|
forcedValues = {},
|
|
107
109
|
} = props;
|
|
108
|
-
const { lang } = useContext(LocaleContext) as LocaleContextType;
|
|
110
|
+
const { t, lang } = useContext(LocaleContext) as LocaleContextType;
|
|
109
111
|
|
|
110
112
|
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
|
|
111
113
|
const [error, setError] = useState<string>();
|
|
@@ -126,7 +128,8 @@ function Form(props: FormProps, ref: any) {
|
|
|
126
128
|
const responsiveBehaviour = containerWidth < WIDTH_BREAKPOINT;
|
|
127
129
|
|
|
128
130
|
const formContext = useContext(FormContext) as FormContextType;
|
|
129
|
-
const { activeId: parentId } =
|
|
131
|
+
const { activeId: parentId, getPlainValues: getParentPlainValues } =
|
|
132
|
+
formContext || {};
|
|
130
133
|
|
|
131
134
|
const actionViewContext = useContext(
|
|
132
135
|
ActionViewContext
|
|
@@ -137,6 +140,8 @@ function Form(props: FormProps, ref: any) {
|
|
|
137
140
|
setCurrentId = undefined,
|
|
138
141
|
setFormIsLoading = undefined,
|
|
139
142
|
setAttachments = undefined,
|
|
143
|
+
title = undefined,
|
|
144
|
+
setTitle = undefined,
|
|
140
145
|
} = (rootForm ? actionViewContext : {}) || {};
|
|
141
146
|
|
|
142
147
|
const contentRootContext = useContext(
|
|
@@ -342,6 +347,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
342
347
|
await antForm.validateFields();
|
|
343
348
|
return false;
|
|
344
349
|
} catch (verror) {
|
|
350
|
+
message.error(t("fillRequiredFields"));
|
|
345
351
|
return true;
|
|
346
352
|
}
|
|
347
353
|
}
|
|
@@ -398,13 +404,11 @@ function Form(props: FormProps, ref: any) {
|
|
|
398
404
|
if (valuesProps) {
|
|
399
405
|
values = valuesProps;
|
|
400
406
|
} else {
|
|
401
|
-
({
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
arch: _arch!,
|
|
407
|
-
}));
|
|
407
|
+
({ values, defaultGetCalled: hasDefaultGetCalled } =
|
|
408
|
+
await fetchValuesFromApi({
|
|
409
|
+
fields: _fields,
|
|
410
|
+
arch: _arch!,
|
|
411
|
+
}));
|
|
408
412
|
}
|
|
409
413
|
|
|
410
414
|
if (actionDomain) {
|
|
@@ -455,15 +459,13 @@ function Form(props: FormProps, ref: any) {
|
|
|
455
459
|
|
|
456
460
|
const getFormView = async (): Promise<FormView> => {
|
|
457
461
|
if (getDataFromAction) {
|
|
458
|
-
const action =
|
|
459
|
-
model
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
{
|
|
462
|
+
const action =
|
|
463
|
+
await ConnectionProvider.getHandler().getActionStringForModel(model);
|
|
464
|
+
const viewsForAction =
|
|
465
|
+
await ConnectionProvider.getHandler().getViewsForAction({
|
|
463
466
|
action,
|
|
464
467
|
context: parentContext,
|
|
465
|
-
}
|
|
466
|
-
);
|
|
468
|
+
});
|
|
467
469
|
return viewsForAction.views.get("form");
|
|
468
470
|
}
|
|
469
471
|
|
|
@@ -609,13 +611,13 @@ function Form(props: FormProps, ref: any) {
|
|
|
609
611
|
formSubmitting.current = false;
|
|
610
612
|
setFormHasChanges?.(false);
|
|
611
613
|
onCancel?.();
|
|
612
|
-
return true;
|
|
614
|
+
return { succeed: true, id: getCurrentId()! };
|
|
613
615
|
}
|
|
614
616
|
|
|
615
617
|
if (await checkIfFormHasErrors()) {
|
|
616
618
|
formSubmitting.current = false;
|
|
617
619
|
formErrorsDialog(lang);
|
|
618
|
-
return false;
|
|
620
|
+
return { succeed: false, id: getCurrentId()! };
|
|
619
621
|
}
|
|
620
622
|
|
|
621
623
|
setIsSubmitting(true);
|
|
@@ -640,6 +642,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
640
642
|
setIsSubmitting(false);
|
|
641
643
|
setFormIsSaving?.(false);
|
|
642
644
|
onSubmitError?.(err);
|
|
645
|
+
message.error(t("errorWhileSavingForm"));
|
|
643
646
|
setError(err?.message ? err.message : err);
|
|
644
647
|
} finally {
|
|
645
648
|
formSubmitting.current = false;
|
|
@@ -647,7 +650,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
647
650
|
setIsSubmitting(false);
|
|
648
651
|
}
|
|
649
652
|
|
|
650
|
-
return submitSucceed;
|
|
653
|
+
return { succeed: submitSucceed, id: getCurrentId()! };
|
|
651
654
|
};
|
|
652
655
|
|
|
653
656
|
const parseForm = ({
|
|
@@ -663,13 +666,20 @@ function Form(props: FormProps, ref: any) {
|
|
|
663
666
|
// TODO: Here we must inject `values` to the ooui parser in order to evaluate arch+values and get the new form container
|
|
664
667
|
ooui.parse(arch, {
|
|
665
668
|
readOnly,
|
|
666
|
-
values:
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
669
|
+
values: convertToPlain2ManyValues(
|
|
670
|
+
{
|
|
671
|
+
...values,
|
|
672
|
+
...getAdditionalValues(),
|
|
673
|
+
},
|
|
674
|
+
fields
|
|
675
|
+
),
|
|
670
676
|
});
|
|
671
677
|
setFormOoui(ooui);
|
|
672
678
|
|
|
679
|
+
if (ooui.string && ooui.string !== title) {
|
|
680
|
+
setTitle?.(ooui.string);
|
|
681
|
+
}
|
|
682
|
+
|
|
673
683
|
if (formModalContext && ooui.string)
|
|
674
684
|
formModalContext.setTitle?.(ooui.string);
|
|
675
685
|
};
|
|
@@ -695,7 +705,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
695
705
|
if (
|
|
696
706
|
checkFieldsType({
|
|
697
707
|
changedFields,
|
|
698
|
-
|
|
708
|
+
formOoui: formOoui!,
|
|
699
709
|
types: [
|
|
700
710
|
"text",
|
|
701
711
|
"codeeditor",
|
|
@@ -756,6 +766,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
756
766
|
...formOoui?.context,
|
|
757
767
|
},
|
|
758
768
|
},
|
|
769
|
+
parentValues: getParentPlainValues?.(),
|
|
759
770
|
onChangeFieldActionArgs: onChangeFieldAction.args,
|
|
760
771
|
});
|
|
761
772
|
|
|
@@ -57,7 +57,12 @@ export const GraphChart = (props: GraphChartProps) => {
|
|
|
57
57
|
return (
|
|
58
58
|
<div style={{ padding: "1rem" }}>
|
|
59
59
|
<p style={{ textAlign: "right" }}>
|
|
60
|
-
{`${t("totalRegisters")} ${evaluatedEntries?.length
|
|
60
|
+
{`${t("totalRegisters")} ${evaluatedEntries?.length?.toLocaleString(
|
|
61
|
+
"es-ES",
|
|
62
|
+
{
|
|
63
|
+
useGrouping: true,
|
|
64
|
+
}
|
|
65
|
+
)}`}
|
|
61
66
|
</p>
|
|
62
67
|
<Chart
|
|
63
68
|
{...getGraphProps({
|
|
@@ -1,13 +1,57 @@
|
|
|
1
|
+
const formatter = (graphType: "pie" | "default" | "barGrouped") => {
|
|
2
|
+
return (object: any) => {
|
|
3
|
+
const formattedValue = object.value.toLocaleString("es-ES", {
|
|
4
|
+
useGrouping: true,
|
|
5
|
+
});
|
|
6
|
+
const name = graphType === "pie" ? object.x : object.type;
|
|
7
|
+
return { name, value: formattedValue };
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const axisFormatter = (value: any) => {
|
|
12
|
+
if (typeof value === "string" && stringIsValidNumeric(value)) {
|
|
13
|
+
return parseFloat(value).toLocaleString("es-ES", {
|
|
14
|
+
useGrouping: true,
|
|
15
|
+
});
|
|
16
|
+
} else if (isNumber(value)) {
|
|
17
|
+
return value.toLocaleString("es-ES", {
|
|
18
|
+
useGrouping: true,
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const stringIsValidNumeric = (value: string) => {
|
|
26
|
+
const regex = /^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/;
|
|
27
|
+
return regex.test(value);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const isNumber = (value: any) => {
|
|
31
|
+
return typeof value === "number" && !isNaN(value);
|
|
32
|
+
};
|
|
33
|
+
|
|
1
34
|
const DefaultGraphOptions = {
|
|
2
35
|
default: {
|
|
3
36
|
padding: "auto",
|
|
4
37
|
xAxis: {
|
|
5
38
|
tickCount: 5,
|
|
39
|
+
label: {
|
|
40
|
+
formatter: axisFormatter,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
yAxis: {
|
|
44
|
+
label: {
|
|
45
|
+
formatter: axisFormatter,
|
|
46
|
+
},
|
|
6
47
|
},
|
|
7
48
|
legend: {
|
|
8
49
|
maxWidthRatio: 0.5,
|
|
9
50
|
maxItemWidth: 1000,
|
|
10
51
|
},
|
|
52
|
+
tooltip: {
|
|
53
|
+
formatter: formatter("default"),
|
|
54
|
+
},
|
|
11
55
|
},
|
|
12
56
|
pie: {
|
|
13
57
|
appendPadding: 10,
|
|
@@ -25,6 +69,9 @@ const DefaultGraphOptions = {
|
|
|
25
69
|
maxWidthRatio: 0.5,
|
|
26
70
|
maxItemWidth: 1000,
|
|
27
71
|
},
|
|
72
|
+
tooltip: {
|
|
73
|
+
formatter: formatter("pie"),
|
|
74
|
+
},
|
|
28
75
|
interactions: [
|
|
29
76
|
{
|
|
30
77
|
type: "element-active",
|
|
@@ -37,6 +84,19 @@ const DefaultGraphOptions = {
|
|
|
37
84
|
maxWidthRatio: 0.5,
|
|
38
85
|
maxItemWidth: 1000,
|
|
39
86
|
},
|
|
87
|
+
tooltip: {
|
|
88
|
+
formatter: formatter("barGrouped"),
|
|
89
|
+
},
|
|
90
|
+
xAxis: {
|
|
91
|
+
label: {
|
|
92
|
+
formatter: axisFormatter,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
yAxis: {
|
|
96
|
+
label: {
|
|
97
|
+
formatter: axisFormatter,
|
|
98
|
+
},
|
|
99
|
+
},
|
|
40
100
|
label: {
|
|
41
101
|
position: "middle",
|
|
42
102
|
layout: [
|
|
@@ -273,7 +273,11 @@ function CommonIndicator({
|
|
|
273
273
|
? minFontSize
|
|
274
274
|
: height * fontGrowFactor;
|
|
275
275
|
|
|
276
|
-
|
|
276
|
+
const localeValue = value?.toLocaleString("es-ES", {
|
|
277
|
+
useGrouping: true,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
let finalValue = total ? `${localeValue}/${total}` : `${localeValue}`;
|
|
277
281
|
|
|
278
282
|
if (suffix) {
|
|
279
283
|
finalValue += " " + suffix;
|
|
@@ -342,13 +346,23 @@ function PercentageIndicator({
|
|
|
342
346
|
? minFontSize
|
|
343
347
|
: twoLinesHeight * fontGrowFactor;
|
|
344
348
|
|
|
345
|
-
|
|
349
|
+
const localeValue = value?.toLocaleString("es-ES", {
|
|
350
|
+
useGrouping: true,
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
let finalValue = total
|
|
354
|
+
? `${localeValue}/${total?.toLocaleString("es-ES", {
|
|
355
|
+
useGrouping: true,
|
|
356
|
+
})}`
|
|
357
|
+
: `${localeValue}`;
|
|
346
358
|
|
|
347
359
|
if (suffix) {
|
|
348
360
|
finalValue += " " + suffix;
|
|
349
361
|
}
|
|
350
362
|
|
|
351
|
-
const percentValue = `${percent
|
|
363
|
+
const percentValue = `${percent?.toLocaleString("es-ES", {
|
|
364
|
+
useGrouping: true,
|
|
365
|
+
})}%`;
|
|
352
366
|
|
|
353
367
|
let tw = getTextWidth(
|
|
354
368
|
percentValue,
|
|
@@ -295,6 +295,7 @@ function SearchTree(props: Props, ref: any) {
|
|
|
295
295
|
formView.search_fields,
|
|
296
296
|
treeView.search_fields,
|
|
297
297
|
])}
|
|
298
|
+
formXml={formView.arch}
|
|
298
299
|
onClear={clear}
|
|
299
300
|
limit={limit}
|
|
300
301
|
offset={offset}
|
|
@@ -307,6 +308,7 @@ function SearchTree(props: Props, ref: any) {
|
|
|
307
308
|
searchValues={searchValues}
|
|
308
309
|
/>
|
|
309
310
|
<Tree
|
|
311
|
+
context={parentContext}
|
|
310
312
|
total={totalItems}
|
|
311
313
|
limit={limit}
|
|
312
314
|
page={page}
|
|
@@ -327,6 +329,7 @@ function SearchTree(props: Props, ref: any) {
|
|
|
327
329
|
treeView.isExpandable ? fetchChildrenForRecord : undefined
|
|
328
330
|
}
|
|
329
331
|
childField={treeView.field_parent}
|
|
332
|
+
rootTree={rootTree}
|
|
330
333
|
/>
|
|
331
334
|
</>
|
|
332
335
|
);
|