@gisce/react-ooui 1.2.0-rc.3 → 1.2.0-rc.30
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/ContentRootContext.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/treeHelper.d.ts.map +1 -1
- package/dist/locales/ca_ES.d.ts +4 -0
- package/dist/locales/ca_ES.d.ts.map +1 -1
- package/dist/locales/en_US.d.ts +4 -0
- package/dist/locales/en_US.d.ts.map +1 -1
- package/dist/locales/es_ES.d.ts +4 -0
- package/dist/locales/es_ES.d.ts.map +1 -1
- package/dist/react-ooui.es.js +14600 -12618
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +74 -47
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/types/index.d.ts +2 -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/base/Integer.d.ts.map +1 -1
- package/dist/widgets/base/Label.d.ts.map +1 -1
- package/dist/widgets/base/ReferenceTree.d.ts +7 -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/Tags.d.ts.map +1 -1
- package/dist/widgets/modals/ExportModal.d.ts +2 -2
- 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/Form.d.ts.map +1 -1
- package/dist/widgets/views/Tree.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/actionbar/ChangeViewButton.tsx +2 -2
- package/src/actionbar/FormActionBar.tsx +11 -3
- package/src/actionbar/TreeActionBar.tsx +71 -19
- package/src/context/ContentRootContext.tsx +15 -7
- package/src/helpers/formHelper.ts +26 -5
- package/src/helpers/treeHelper.ts +10 -2
- package/src/locales/ca_ES.tsx +4 -0
- package/src/locales/en_US.tsx +4 -0
- package/src/locales/es_ES.tsx +4 -0
- package/src/stories/Label.stories.tsx +7 -8
- package/src/stories/mocks/models/crm_case.ts +7 -10
- package/src/types/index.ts +2 -0
- package/src/views/ActionView.tsx +15 -4
- package/src/views/RootView.tsx +7 -1
- package/src/views/actionViews/TreeActionView.tsx +11 -2
- package/src/widgets/base/Integer.tsx +1 -0
- package/src/widgets/base/Label.tsx +5 -9
- package/src/widgets/base/ReferenceTree.tsx +55 -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 +1 -0
- package/src/widgets/containers/Group.tsx +3 -3
- package/src/widgets/custom/MultiCheckbox.tsx +1 -0
- package/src/widgets/custom/Tags.tsx +27 -28
- package/src/widgets/modals/ExportModal.tsx +53 -15
- package/src/widgets/views/Dashboard/Dashboard.tsx +5 -1
- package/src/widgets/views/Form.tsx +18 -17
- package/src/widgets/views/Tree.tsx +14 -11
- package/dist/ui/Fieldset.d.ts +0 -8
- package/dist/ui/Fieldset.d.ts.map +0 -1
- package/src/ui/Fieldset.tsx +0 -31
|
@@ -13,13 +13,13 @@ export type ExportModalProps = {
|
|
|
13
13
|
visible: boolean;
|
|
14
14
|
locale: string;
|
|
15
15
|
onClose: () => void;
|
|
16
|
-
selectedRegistersToExport?:
|
|
16
|
+
selectedRegistersToExport?: any[];
|
|
17
17
|
totalRegisters: number;
|
|
18
18
|
model: string;
|
|
19
19
|
domain: any[];
|
|
20
20
|
limit?: number;
|
|
21
|
-
treeFields?: any;
|
|
22
21
|
context?: any;
|
|
22
|
+
visibleRegisters: number;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export const ExportModal = (props: ExportModalProps) => {
|
|
@@ -29,26 +29,40 @@ export const ExportModal = (props: ExportModalProps) => {
|
|
|
29
29
|
onClose,
|
|
30
30
|
model,
|
|
31
31
|
context,
|
|
32
|
-
treeFields,
|
|
33
32
|
selectedRegistersToExport,
|
|
34
33
|
totalRegisters,
|
|
35
34
|
domain,
|
|
36
35
|
limit,
|
|
36
|
+
visibleRegisters,
|
|
37
37
|
} = props;
|
|
38
38
|
const fields = useRef<any>({});
|
|
39
39
|
|
|
40
40
|
const onSucceed = useCallback(
|
|
41
41
|
async (options: ExportOptions) => {
|
|
42
|
-
if (
|
|
42
|
+
if (
|
|
43
|
+
options.selectedKeys === undefined ||
|
|
44
|
+
options.selectedKeys.length === 0
|
|
45
|
+
) {
|
|
43
46
|
showInfo(tForLang("selectAtLeastOneField", locale));
|
|
44
47
|
return;
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
let exportDomain = domain;
|
|
51
|
+
|
|
52
|
+
if (
|
|
53
|
+
options.registersAmount === "selected" &&
|
|
54
|
+
selectedRegistersToExport?.length !== 0
|
|
55
|
+
) {
|
|
56
|
+
exportDomain = [
|
|
57
|
+
["id", "in", selectedRegistersToExport?.map((r) => r.id)],
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
|
|
47
61
|
const { datas } = await ConnectionProvider.getHandler().exportData({
|
|
48
62
|
model,
|
|
49
63
|
fields: options.selectedKeys,
|
|
50
|
-
domain:
|
|
51
|
-
limit: options.registersAmount === "all" ?
|
|
64
|
+
domain: exportDomain,
|
|
65
|
+
limit: options.registersAmount === "all" ? 0 : limit,
|
|
52
66
|
context,
|
|
53
67
|
format: options.exportType,
|
|
54
68
|
});
|
|
@@ -77,13 +91,18 @@ export const ExportModal = (props: ExportModalProps) => {
|
|
|
77
91
|
async ({ key, title }: any) => {
|
|
78
92
|
let fieldDefinition;
|
|
79
93
|
|
|
80
|
-
|
|
94
|
+
const sanitizedKey =
|
|
95
|
+
key.split("/")[key.split("/").length - 1] === "id"
|
|
96
|
+
? key.split("/").slice(0, -1).join("/")
|
|
97
|
+
: key;
|
|
98
|
+
|
|
99
|
+
if (sanitizedKey.indexOf("/") === -1) {
|
|
81
100
|
fieldDefinition = fields.current["/"];
|
|
82
101
|
} else {
|
|
83
|
-
fieldDefinition = fields.current[getParentKey(
|
|
102
|
+
fieldDefinition = fields.current[getParentKey(sanitizedKey)];
|
|
84
103
|
}
|
|
85
104
|
|
|
86
|
-
const optsForField = fieldDefinition[getChildKey(
|
|
105
|
+
const optsForField = fieldDefinition[getChildKey(sanitizedKey)];
|
|
87
106
|
const relation = optsForField.relation;
|
|
88
107
|
const viewData = await ConnectionProvider.getHandler().getFields({
|
|
89
108
|
model: relation,
|
|
@@ -91,12 +110,12 @@ export const ExportModal = (props: ExportModalProps) => {
|
|
|
91
110
|
fields: [],
|
|
92
111
|
});
|
|
93
112
|
|
|
94
|
-
fields.current[
|
|
113
|
+
fields.current[sanitizedKey] = viewData;
|
|
95
114
|
|
|
96
115
|
return convertToExportField({
|
|
97
116
|
fields: viewData,
|
|
98
117
|
parentTitle: title,
|
|
99
|
-
parentKey:
|
|
118
|
+
parentKey: sanitizedKey,
|
|
100
119
|
});
|
|
101
120
|
},
|
|
102
121
|
[fields, model, context]
|
|
@@ -108,11 +127,17 @@ export const ExportModal = (props: ExportModalProps) => {
|
|
|
108
127
|
locale={locale as Locale}
|
|
109
128
|
onSucceed={onSucceed}
|
|
110
129
|
onCancel={onClose}
|
|
111
|
-
selectedRegistersToExport={
|
|
130
|
+
selectedRegistersToExport={
|
|
131
|
+
selectedRegistersToExport &&
|
|
132
|
+
selectedRegistersToExport.length &&
|
|
133
|
+
selectedRegistersToExport.length > 0
|
|
134
|
+
? selectedRegistersToExport.length
|
|
135
|
+
: undefined
|
|
136
|
+
}
|
|
112
137
|
totalRegisters={totalRegisters}
|
|
113
138
|
onGetFieldChilds={onGetFieldChilds}
|
|
114
139
|
onGetFields={onGetFields}
|
|
115
|
-
|
|
140
|
+
visibleRegisters={visibleRegisters}
|
|
116
141
|
/>
|
|
117
142
|
);
|
|
118
143
|
};
|
|
@@ -130,14 +155,27 @@ const convertToExportField = ({
|
|
|
130
155
|
|
|
131
156
|
for (const key of Object.keys(fields)) {
|
|
132
157
|
const valuesForField = fields[key];
|
|
158
|
+
|
|
159
|
+
if (valuesForField.relation && valuesForField.is_function === true) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
|
|
133
163
|
const relationField =
|
|
134
164
|
valuesForField.type === "many2one" ||
|
|
135
165
|
valuesForField.type === "one2many" ||
|
|
136
166
|
valuesForField.type === "many2many";
|
|
137
167
|
|
|
168
|
+
let newKey = `${parentKey ? parentKey + "/" : ""}${key}`;
|
|
169
|
+
|
|
170
|
+
if (relationField) {
|
|
171
|
+
newKey += "/id";
|
|
172
|
+
}
|
|
173
|
+
|
|
138
174
|
exportFields.push({
|
|
139
|
-
key:
|
|
140
|
-
title: `${parentTitle ? parentTitle + "
|
|
175
|
+
key: newKey,
|
|
176
|
+
title: `${parentTitle ? parentTitle + " → " : ""}${
|
|
177
|
+
valuesForField.string
|
|
178
|
+
}`,
|
|
141
179
|
tooltip: valuesForField.help,
|
|
142
180
|
required: valuesForField.required,
|
|
143
181
|
isLeaf: !relationField,
|
|
@@ -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";
|
|
@@ -105,7 +106,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
105
106
|
defaultValues,
|
|
106
107
|
forcedValues = {},
|
|
107
108
|
} = props;
|
|
108
|
-
const { lang } = useContext(LocaleContext) as LocaleContextType;
|
|
109
|
+
const { t, lang } = useContext(LocaleContext) as LocaleContextType;
|
|
109
110
|
|
|
110
111
|
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
|
|
111
112
|
const [error, setError] = useState<string>();
|
|
@@ -126,7 +127,8 @@ function Form(props: FormProps, ref: any) {
|
|
|
126
127
|
const responsiveBehaviour = containerWidth < WIDTH_BREAKPOINT;
|
|
127
128
|
|
|
128
129
|
const formContext = useContext(FormContext) as FormContextType;
|
|
129
|
-
const { activeId: parentId } =
|
|
130
|
+
const { activeId: parentId, getPlainValues: getParentPlainValues } =
|
|
131
|
+
formContext || {};
|
|
130
132
|
|
|
131
133
|
const actionViewContext = useContext(
|
|
132
134
|
ActionViewContext
|
|
@@ -342,6 +344,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
342
344
|
await antForm.validateFields();
|
|
343
345
|
return false;
|
|
344
346
|
} catch (verror) {
|
|
347
|
+
message.error(t("fillRequiredFields"));
|
|
345
348
|
return true;
|
|
346
349
|
}
|
|
347
350
|
}
|
|
@@ -398,13 +401,11 @@ function Form(props: FormProps, ref: any) {
|
|
|
398
401
|
if (valuesProps) {
|
|
399
402
|
values = valuesProps;
|
|
400
403
|
} else {
|
|
401
|
-
({
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
arch: _arch!,
|
|
407
|
-
}));
|
|
404
|
+
({ values, defaultGetCalled: hasDefaultGetCalled } =
|
|
405
|
+
await fetchValuesFromApi({
|
|
406
|
+
fields: _fields,
|
|
407
|
+
arch: _arch!,
|
|
408
|
+
}));
|
|
408
409
|
}
|
|
409
410
|
|
|
410
411
|
if (actionDomain) {
|
|
@@ -455,15 +456,13 @@ function Form(props: FormProps, ref: any) {
|
|
|
455
456
|
|
|
456
457
|
const getFormView = async (): Promise<FormView> => {
|
|
457
458
|
if (getDataFromAction) {
|
|
458
|
-
const action =
|
|
459
|
-
model
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
{
|
|
459
|
+
const action =
|
|
460
|
+
await ConnectionProvider.getHandler().getActionStringForModel(model);
|
|
461
|
+
const viewsForAction =
|
|
462
|
+
await ConnectionProvider.getHandler().getViewsForAction({
|
|
463
463
|
action,
|
|
464
464
|
context: parentContext,
|
|
465
|
-
}
|
|
466
|
-
);
|
|
465
|
+
});
|
|
467
466
|
return viewsForAction.views.get("form");
|
|
468
467
|
}
|
|
469
468
|
|
|
@@ -640,6 +639,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
640
639
|
setIsSubmitting(false);
|
|
641
640
|
setFormIsSaving?.(false);
|
|
642
641
|
onSubmitError?.(err);
|
|
642
|
+
message.error(t("errorWhileSavingForm"));
|
|
643
643
|
setError(err?.message ? err.message : err);
|
|
644
644
|
} finally {
|
|
645
645
|
formSubmitting.current = false;
|
|
@@ -695,7 +695,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
695
695
|
if (
|
|
696
696
|
checkFieldsType({
|
|
697
697
|
changedFields,
|
|
698
|
-
|
|
698
|
+
formOoui: formOoui!,
|
|
699
699
|
types: [
|
|
700
700
|
"text",
|
|
701
701
|
"codeeditor",
|
|
@@ -756,6 +756,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
756
756
|
...formOoui?.context,
|
|
757
757
|
},
|
|
758
758
|
},
|
|
759
|
+
parentValues: getParentPlainValues?.(),
|
|
759
760
|
onChangeFieldActionArgs: onChangeFieldAction.args,
|
|
760
761
|
});
|
|
761
762
|
|
|
@@ -16,6 +16,9 @@ import {
|
|
|
16
16
|
LoadingOutlined,
|
|
17
17
|
} from "@ant-design/icons";
|
|
18
18
|
import { One2manyValue } from "../base/one2many/One2manyInput";
|
|
19
|
+
import { Interweave } from "interweave";
|
|
20
|
+
import { Many2oneTree } from "../base/many2one/Many2oneTree";
|
|
21
|
+
import { ReferenceTree } from "../base/ReferenceTree";
|
|
19
22
|
|
|
20
23
|
type Props = {
|
|
21
24
|
total?: number;
|
|
@@ -51,18 +54,11 @@ const booleanComponentFn = (value: boolean): React.ReactElement => {
|
|
|
51
54
|
};
|
|
52
55
|
|
|
53
56
|
const many2OneComponentFn = (m2oField: any): React.ReactElement => {
|
|
54
|
-
|
|
55
|
-
return <></>;
|
|
56
|
-
}
|
|
57
|
-
return (
|
|
58
|
-
<Space>
|
|
59
|
-
<>{m2oField.value}</>
|
|
60
|
-
<Many2oneSuffix id={m2oField.id} model={m2oField.model} />
|
|
61
|
-
</Space>
|
|
62
|
-
);
|
|
57
|
+
return <Many2oneTree m2oField={m2oField} />;
|
|
63
58
|
};
|
|
59
|
+
|
|
64
60
|
const textComponentFn = (value: any): React.ReactElement => {
|
|
65
|
-
return <
|
|
61
|
+
return <Interweave content={value?.replace(/(?:\r\n|\r|\n)/g, "<br>")} />;
|
|
66
62
|
};
|
|
67
63
|
|
|
68
64
|
const one2ManyComponentFn = (value: One2manyValue): React.ReactElement => {
|
|
@@ -91,6 +87,10 @@ const imageComponent = (value: string): React.ReactElement => {
|
|
|
91
87
|
);
|
|
92
88
|
};
|
|
93
89
|
|
|
90
|
+
const referenceComponent = (value: any): React.ReactElement => {
|
|
91
|
+
return <ReferenceTree value={value} />;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
94
|
function Tree(props: Props): React.ReactElement {
|
|
95
95
|
const {
|
|
96
96
|
page = 1,
|
|
@@ -135,6 +135,7 @@ function Tree(props: Props): React.ReactElement {
|
|
|
135
135
|
image: imageComponent,
|
|
136
136
|
integer: numberComponent,
|
|
137
137
|
float: numberComponent,
|
|
138
|
+
reference: referenceComponent,
|
|
138
139
|
});
|
|
139
140
|
|
|
140
141
|
setColumns(columns);
|
|
@@ -171,7 +172,9 @@ function Tree(props: Props): React.ReactElement {
|
|
|
171
172
|
<Col span={12}>
|
|
172
173
|
<Pagination
|
|
173
174
|
total={total}
|
|
174
|
-
pageSize={
|
|
175
|
+
pageSize={
|
|
176
|
+
internalLimit.current === 0 ? total : internalLimit.current
|
|
177
|
+
}
|
|
175
178
|
current={page}
|
|
176
179
|
showSizeChanger={false}
|
|
177
180
|
onChange={onRequestPageChange}
|
package/dist/ui/Fieldset.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Fieldset.d.ts","sourceRoot":"","sources":["Fieldset.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,aAAK,KAAK,GAAG;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,GAAG,CAAC;CACf,CAAC;AAEF,QAAA,MAAM,QAAQ,UAAW,KAAK,KAAG,MAAM,YAqBtC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
package/src/ui/Fieldset.tsx
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
type Props = {
|
|
4
|
-
label: string;
|
|
5
|
-
children: any;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const Fieldset = (props: Props): React.ReactElement => {
|
|
9
|
-
const { label, children } = props;
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
// TODO: change in-line styles to TailWind classes
|
|
13
|
-
<fieldset className="p-2 border-gray-400 border border-solid font-sans">
|
|
14
|
-
<legend
|
|
15
|
-
style={{
|
|
16
|
-
all: "initial",
|
|
17
|
-
marginLeft: "1em",
|
|
18
|
-
paddingLeft: "0.5em",
|
|
19
|
-
paddingRight: "0.5em",
|
|
20
|
-
fontFamily:
|
|
21
|
-
"system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'",
|
|
22
|
-
}}
|
|
23
|
-
>
|
|
24
|
-
{label}
|
|
25
|
-
</legend>
|
|
26
|
-
{children}
|
|
27
|
-
</fieldset>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export default Fieldset;
|