@gisce/react-ooui 1.2.0-rc.3 → 1.2.0-rc.31
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 +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 +14707 -12706
- 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 +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/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/Dashboard/DashboardTree.d.ts.map +1 -1
- package/dist/widgets/views/Form.d.ts.map +1 -1
- package/dist/widgets/views/SearchTree.d.ts.map +1 -1
- package/dist/widgets/views/Tree.d.ts +1 -0
- 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 +16 -4
- 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 +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/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/Dashboard/DashboardTree.tsx +1 -0
- package/src/widgets/views/Form.tsx +18 -17
- package/src/widgets/views/SearchTree.tsx +1 -0
- package/src/widgets/views/Tree.tsx +45 -23
- package/dist/ui/Fieldset.d.ts +0 -8
- package/dist/ui/Fieldset.d.ts.map +0 -1
- package/src/ui/Fieldset.tsx +0 -31
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
export const Default = (): React.ReactElement => {
|
|
13
13
|
const ooui = new LabelOoui({
|
|
14
14
|
name: "field",
|
|
15
|
-
string: "Lorem ipsum",
|
|
15
|
+
string: "<b>Lorem ipsum</b>",
|
|
16
16
|
});
|
|
17
17
|
return (
|
|
18
18
|
<LocaleProvider lang="en_US">
|
|
@@ -25,7 +25,7 @@ export const LabelSecondary = (): React.ReactElement => {
|
|
|
25
25
|
const ooui = new LabelOoui({
|
|
26
26
|
name: "field",
|
|
27
27
|
string: "Lorem ipsum",
|
|
28
|
-
widget_props: "{'label_type': 'secondary'}"
|
|
28
|
+
widget_props: "{'label_type': 'secondary'}",
|
|
29
29
|
});
|
|
30
30
|
return (
|
|
31
31
|
<LocaleProvider lang="en_US">
|
|
@@ -38,7 +38,7 @@ export const LabelWaning = (): React.ReactElement => {
|
|
|
38
38
|
const ooui = new LabelOoui({
|
|
39
39
|
name: "field",
|
|
40
40
|
string: "Lorem ipsum",
|
|
41
|
-
widget_props: "{'label_type': 'warning'}"
|
|
41
|
+
widget_props: "{'label_type': 'warning'}",
|
|
42
42
|
});
|
|
43
43
|
return (
|
|
44
44
|
<LocaleProvider lang="en_US">
|
|
@@ -51,7 +51,7 @@ export const LabelDanger = (): React.ReactElement => {
|
|
|
51
51
|
const ooui = new LabelOoui({
|
|
52
52
|
name: "field",
|
|
53
53
|
string: "Lorem ipsum",
|
|
54
|
-
widget_props: "{'label_type': 'danger'}"
|
|
54
|
+
widget_props: "{'label_type': 'danger'}",
|
|
55
55
|
});
|
|
56
56
|
return (
|
|
57
57
|
<LocaleProvider lang="en_US">
|
|
@@ -64,7 +64,7 @@ export const LabelSuccess = (): React.ReactElement => {
|
|
|
64
64
|
const ooui = new LabelOoui({
|
|
65
65
|
name: "field",
|
|
66
66
|
string: "Lorem ipsum",
|
|
67
|
-
widget_props: "{'label_type': 'success'}"
|
|
67
|
+
widget_props: "{'label_type': 'success'}",
|
|
68
68
|
});
|
|
69
69
|
return (
|
|
70
70
|
<LocaleProvider lang="en_US">
|
|
@@ -73,12 +73,11 @@ export const LabelSuccess = (): React.ReactElement => {
|
|
|
73
73
|
);
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
-
|
|
77
76
|
export const LabelH1 = (): React.ReactElement => {
|
|
78
77
|
const ooui = new LabelOoui({
|
|
79
78
|
name: "field",
|
|
80
79
|
string: "Lorem ipsum",
|
|
81
|
-
widget_props: "{'label_size': 'h1'}"
|
|
80
|
+
widget_props: "{'label_size': 'h1'}",
|
|
82
81
|
});
|
|
83
82
|
return (
|
|
84
83
|
<LocaleProvider lang="en_US">
|
|
@@ -91,7 +90,7 @@ export const LabelH2Warning = (): React.ReactElement => {
|
|
|
91
90
|
const ooui = new LabelOoui({
|
|
92
91
|
name: "field",
|
|
93
92
|
string: "Lorem ipsum",
|
|
94
|
-
widget_props: "{'label_size': 'h1', 'label_type': 'warning'}"
|
|
93
|
+
widget_props: "{'label_size': 'h1', 'label_type': 'warning'}",
|
|
95
94
|
});
|
|
96
95
|
return (
|
|
97
96
|
<LocaleProvider lang="en_US">
|
|
@@ -39,13 +39,14 @@ export default {
|
|
|
39
39
|
task_id: false,
|
|
40
40
|
user_id: [1, "Administrator"],
|
|
41
41
|
workdones_ids: [],
|
|
42
|
+
integer: 40003.23,
|
|
42
43
|
},
|
|
43
44
|
form: {
|
|
44
|
-
arch:
|
|
45
|
-
'<form string="Casos">\n <group col="8" colspan="4">\n <field colspan="4" name="partner_id" on_change="onchange_partner_id(partner_id, email_from)" select="1"/>\n <field colspan="3" name="partner_address_id" on_change="onchange_partner_address_id(partner_address_id, email_from)" select="2"/>\n \n <field colspan="3" name="email_from" select="2"/>\n <button name="remind_partner" states="open,pending" string="Envia notificaci\u00f3" type="object"/>\n <field name="user_id" select="1" domain="[(\'id\',\'!=\', 0)]"/>\n <button name="autoassign" string="Assigna-me\'l" type="object"/>\n <button name="remind_user" states="open,pending" string="Envia notificaci\u00f3" type="object"/>\n </group><field name="state" select="1"/></form>',
|
|
45
|
+
arch: '<form string="Casos">\n <field name="integer" /> <group col="8" colspan="4">\n <field colspan="4" name="partner_id" on_change="onchange_partner_id(partner_id, email_from)" select="1"/>\n <field colspan="3" name="partner_address_id" on_change="onchange_partner_address_id(partner_address_id, email_from)" select="2"/>\n \n <field colspan="3" name="email_from" select="2"/>\n <button name="remind_partner" states="open,pending" string="Envia notificaci\u00f3" type="object"/>\n <field name="user_id" select="1" domain="[(\'id\',\'!=\', 0)]"/>\n <button name="autoassign" string="Assigna-me\'l" type="object"/>\n <button name="remind_user" states="open,pending" string="Envia notificaci\u00f3" type="object"/>\n </group><field name="state" select="1"/></form>',
|
|
46
46
|
|
|
47
47
|
field_parent: false,
|
|
48
48
|
fields: {
|
|
49
|
+
integer: { string: "Integer", type: "integer" },
|
|
49
50
|
active: { string: "Actiu", type: "boolean", views: {} },
|
|
50
51
|
canal_id: {
|
|
51
52
|
context: "",
|
|
@@ -138,8 +139,7 @@ export default {
|
|
|
138
139
|
type: "one2many",
|
|
139
140
|
views: {
|
|
140
141
|
form: {
|
|
141
|
-
arch:
|
|
142
|
-
'<form string="Historial de comunicació">\n <group col="6" colspan="4">\n <field name="date" select="1"/>\n <field name="email" select="1"/>\n <field name="canal_id" select="2"/>\n </group>\n <newline/>\n <field colspan="4" name="description" nolabel="1" select="2"/>\n </form>\n ',
|
|
142
|
+
arch: '<form string="Historial de comunicació">\n <group col="6" colspan="4">\n <field name="date" select="1"/>\n <field name="email" select="1"/>\n <field name="canal_id" select="2"/>\n </group>\n <newline/>\n <field colspan="4" name="description" nolabel="1" select="2"/>\n </form>\n ',
|
|
143
143
|
fields: {
|
|
144
144
|
canal_id: {
|
|
145
145
|
context: "",
|
|
@@ -160,8 +160,7 @@ export default {
|
|
|
160
160
|
},
|
|
161
161
|
},
|
|
162
162
|
tree: {
|
|
163
|
-
arch:
|
|
164
|
-
'<tree string="Historial de comunicació">\n <field name="note"/>\n </tree>\n ',
|
|
163
|
+
arch: '<tree string="Historial de comunicació">\n <field name="note"/>\n </tree>\n ',
|
|
165
164
|
fields: {
|
|
166
165
|
note: {
|
|
167
166
|
digits: [16, 2],
|
|
@@ -185,8 +184,7 @@ export default {
|
|
|
185
184
|
type: "one2many",
|
|
186
185
|
views: {
|
|
187
186
|
form: {
|
|
188
|
-
arch:
|
|
189
|
-
'<form string="Accions">\n <separator colspan="4" string="Informaci\u00f3 de l\'acci\u00f3"/>\n <field colspan="4" name="name"/>\n <field name="date" select="2"/>\n <field name="fefe_id" select="2"/>\n <field name="som" select="2"/>\n <field name="canal_id"/>\n </form>\n ',
|
|
187
|
+
arch: '<form string="Accions">\n <separator colspan="4" string="Informaci\u00f3 de l\'acci\u00f3"/>\n <field colspan="4" name="name"/>\n <field name="date" select="2"/>\n <field name="fefe_id" select="2"/>\n <field name="som" select="2"/>\n <field name="canal_id"/>\n </form>\n ',
|
|
190
188
|
fields: {
|
|
191
189
|
canal_id: {
|
|
192
190
|
context: "",
|
|
@@ -389,8 +387,7 @@ export default {
|
|
|
389
387
|
type: "one2many",
|
|
390
388
|
views: {
|
|
391
389
|
tree: {
|
|
392
|
-
arch:
|
|
393
|
-
'<tree editable="top">\n <field name="date"/>\n <field name="type_id"/>\n <field name="hours" sum="Time spent" widget="float_time"/>\n \n <field name="name"/> \n </tree>\n ',
|
|
390
|
+
arch: '<tree editable="top">\n <field name="date"/>\n <field name="type_id"/>\n <field name="hours" sum="Time spent" widget="float_time"/>\n \n <field name="name"/> \n </tree>\n ',
|
|
394
391
|
fields: {
|
|
395
392
|
date: { string: "Data", type: "datetime", views: {} },
|
|
396
393
|
hours: { string: "Temps dedicat", type: "float", views: {} },
|
package/src/types/index.ts
CHANGED
|
@@ -41,6 +41,7 @@ type TreeView = BaseView & {
|
|
|
41
41
|
search_fields?: SearchFields;
|
|
42
42
|
isExpandable?: boolean;
|
|
43
43
|
field_parent?: string;
|
|
44
|
+
toolbar?: any;
|
|
44
45
|
};
|
|
45
46
|
|
|
46
47
|
type FormView = TreeView & {
|
|
@@ -223,6 +224,7 @@ type EvalDomainRequest = {
|
|
|
223
224
|
domain: string;
|
|
224
225
|
values: any;
|
|
225
226
|
context?: any;
|
|
227
|
+
fields?: any;
|
|
226
228
|
};
|
|
227
229
|
|
|
228
230
|
type IsShortcutFavoriteOptions = {
|
package/src/views/ActionView.tsx
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
29
29
|
import { GoToResourceModal } from "@/ui/GoToResourceModal";
|
|
30
30
|
import showInfo from "@/ui/InfoDialog";
|
|
31
|
+
import showErrorDialog from "@/ui/ActionErrorDialog";
|
|
31
32
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
32
33
|
import { GraphActionView } from "@/views/actionViews/GraphActionView";
|
|
33
34
|
import { FormActionView } from "./actionViews/FormActionView";
|
|
@@ -191,6 +192,7 @@ function ActionView(props: Props, ref: any) {
|
|
|
191
192
|
case "form": {
|
|
192
193
|
viewDataRetrieved.push({
|
|
193
194
|
...(viewInfo as FormView),
|
|
195
|
+
type: viewType,
|
|
194
196
|
});
|
|
195
197
|
break;
|
|
196
198
|
}
|
|
@@ -198,12 +200,14 @@ function ActionView(props: Props, ref: any) {
|
|
|
198
200
|
viewDataRetrieved.push({
|
|
199
201
|
...(viewInfo as TreeView),
|
|
200
202
|
isExpandable: treeExpandable,
|
|
203
|
+
type: viewType,
|
|
201
204
|
});
|
|
202
205
|
break;
|
|
203
206
|
}
|
|
204
207
|
case "graph": {
|
|
205
208
|
viewDataRetrieved.push({
|
|
206
209
|
...(viewInfo as GraphView),
|
|
210
|
+
type: viewType,
|
|
207
211
|
});
|
|
208
212
|
break;
|
|
209
213
|
}
|
|
@@ -211,18 +215,18 @@ function ActionView(props: Props, ref: any) {
|
|
|
211
215
|
break;
|
|
212
216
|
}
|
|
213
217
|
}
|
|
218
|
+
let currentViewToAssign = undefined;
|
|
214
219
|
|
|
215
220
|
if (!initialView && viewDataRetrieved.find((v) => v.type === "tree")) {
|
|
216
221
|
const treeView: TreeView = viewDataRetrieved.find(
|
|
217
222
|
(v) => v.type === "tree"
|
|
218
223
|
) as TreeView;
|
|
219
|
-
|
|
224
|
+
currentViewToAssign = treeView;
|
|
220
225
|
} else if (!initialView) {
|
|
221
226
|
const formView: TreeView = viewDataRetrieved.find(
|
|
222
227
|
(v) => v.type === "form"
|
|
223
228
|
) as TreeView;
|
|
224
|
-
|
|
225
|
-
setCurrentView(formView);
|
|
229
|
+
currentViewToAssign = formView;
|
|
226
230
|
} else {
|
|
227
231
|
const view = viewDataRetrieved.find((v) => {
|
|
228
232
|
if (!initialView.id) {
|
|
@@ -231,9 +235,16 @@ function ActionView(props: Props, ref: any) {
|
|
|
231
235
|
return v.type === initialView.type && v.view_id === initialView.id;
|
|
232
236
|
}
|
|
233
237
|
});
|
|
234
|
-
|
|
238
|
+
currentViewToAssign = view;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (!currentViewToAssign) {
|
|
242
|
+
showErrorDialog(
|
|
243
|
+
"Error determining the first view to show.\nPlease, make sure the view ids on the fields_view_get responses are the same as the ones defined in the action"
|
|
244
|
+
);
|
|
235
245
|
}
|
|
236
246
|
|
|
247
|
+
setCurrentView(currentViewToAssign);
|
|
237
248
|
setAvailableViews(viewDataRetrieved);
|
|
238
249
|
setIsLoading(false);
|
|
239
250
|
};
|
package/src/views/RootView.tsx
CHANGED
|
@@ -250,6 +250,7 @@ function RootView(props: RootViewProps, ref: any) {
|
|
|
250
250
|
fields,
|
|
251
251
|
values: { ...values, ...globalValues },
|
|
252
252
|
}),
|
|
253
|
+
fields,
|
|
253
254
|
context: { ...rootContext, ...parsedContext },
|
|
254
255
|
})
|
|
255
256
|
: [];
|
|
@@ -437,6 +438,11 @@ function RootView(props: RootViewProps, ref: any) {
|
|
|
437
438
|
},
|
|
438
439
|
});
|
|
439
440
|
} else {
|
|
441
|
+
const formattedInitialView =
|
|
442
|
+
initialView && Array.isArray(initialView.id)
|
|
443
|
+
? { ...initialView, id: initialView.id[0] }
|
|
444
|
+
: initialView;
|
|
445
|
+
|
|
440
446
|
addNewTab({
|
|
441
447
|
title,
|
|
442
448
|
action: {
|
|
@@ -454,7 +460,7 @@ function RootView(props: RootViewProps, ref: any) {
|
|
|
454
460
|
context={{ ...rootContext, ...context }}
|
|
455
461
|
domain={domain}
|
|
456
462
|
setCanWeClose={registerViewCloseFn}
|
|
457
|
-
initialView={
|
|
463
|
+
initialView={formattedInitialView}
|
|
458
464
|
res_id={res_id}
|
|
459
465
|
formDefaultValues={values}
|
|
460
466
|
formForcedValues={forced_values}
|
|
@@ -2,7 +2,11 @@ import TreeActionBar from "@/actionbar/TreeActionBar";
|
|
|
2
2
|
import { FormView, TreeView, View } from "@/types";
|
|
3
3
|
import TitleHeader from "@/ui/TitleHeader";
|
|
4
4
|
import SearchTree from "@/widgets/views/SearchTree";
|
|
5
|
-
import React from "react";
|
|
5
|
+
import React, { useContext } from "react";
|
|
6
|
+
import {
|
|
7
|
+
ActionViewContext,
|
|
8
|
+
ActionViewContextType,
|
|
9
|
+
} from "@/context/ActionViewContext";
|
|
6
10
|
|
|
7
11
|
export type TreeActionViewProps = {
|
|
8
12
|
formView?: FormView;
|
|
@@ -38,6 +42,10 @@ export const TreeActionView = (props: TreeActionViewProps) => {
|
|
|
38
42
|
searchTreeNameSearch,
|
|
39
43
|
} = props;
|
|
40
44
|
|
|
45
|
+
const { currentView, setPreviousView } = useContext(
|
|
46
|
+
ActionViewContext
|
|
47
|
+
) as ActionViewContextType;
|
|
48
|
+
|
|
41
49
|
if (!visible) {
|
|
42
50
|
return null;
|
|
43
51
|
}
|
|
@@ -46,7 +54,7 @@ export const TreeActionView = (props: TreeActionViewProps) => {
|
|
|
46
54
|
<>
|
|
47
55
|
<TitleHeader>
|
|
48
56
|
<TreeActionBar
|
|
49
|
-
toolbar={
|
|
57
|
+
toolbar={treeView?.toolbar}
|
|
50
58
|
parentContext={context}
|
|
51
59
|
treeExpandable={treeView?.isExpandable || false}
|
|
52
60
|
/>
|
|
@@ -66,6 +74,7 @@ export const TreeActionView = (props: TreeActionViewProps) => {
|
|
|
66
74
|
const itemIndex = results.findIndex((item: any) => {
|
|
67
75
|
return item.id === id;
|
|
68
76
|
});
|
|
77
|
+
setPreviousView?.(currentView);
|
|
69
78
|
setCurrentItemIndex(itemIndex);
|
|
70
79
|
const formView = availableViews.find(
|
|
71
80
|
(v) => v.type === "form"
|
|
@@ -3,6 +3,7 @@ import { Tooltip, Typography } from "antd";
|
|
|
3
3
|
import { WidgetProps } from "@/types";
|
|
4
4
|
import { QuestionCircleOutlined } from "@ant-design/icons";
|
|
5
5
|
import { Label as LabelOoui } from "@gisce/ooui";
|
|
6
|
+
import { Interweave } from "interweave";
|
|
6
7
|
const { Text, Title } = Typography;
|
|
7
8
|
|
|
8
9
|
type Props = WidgetProps & {
|
|
@@ -18,13 +19,8 @@ const alignClass = {
|
|
|
18
19
|
|
|
19
20
|
const Label = (props: Props) => {
|
|
20
21
|
const { ooui, align, responsiveBehaviour } = props;
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
tooltip,
|
|
24
|
-
fieldForLabel,
|
|
25
|
-
labelSize,
|
|
26
|
-
labelType,
|
|
27
|
-
} = ooui as LabelOoui;
|
|
22
|
+
const { label, tooltip, fieldForLabel, labelSize, labelType } =
|
|
23
|
+
ooui as LabelOoui;
|
|
28
24
|
const addColon = fieldForLabel !== null ? true : false;
|
|
29
25
|
const labelText = addColon && label.length > 1 ? label + " :" : label;
|
|
30
26
|
const responsiveAlign = responsiveBehaviour ? "left" : "right";
|
|
@@ -43,10 +39,10 @@ const Label = (props: Props) => {
|
|
|
43
39
|
)}
|
|
44
40
|
<span className="pr-2">
|
|
45
41
|
<TextType
|
|
46
|
-
level={labelSize !== "text" ? (
|
|
42
|
+
level={labelSize !== "text" ? (labelSize as string as any) : null}
|
|
47
43
|
type={labelType as any}
|
|
48
44
|
>
|
|
49
|
-
{labelText}
|
|
45
|
+
<Interweave content={labelText} />
|
|
50
46
|
</TextType>
|
|
51
47
|
</span>
|
|
52
48
|
</div>
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import ConnectionProvider from "@/ConnectionProvider";
|
|
2
|
+
import { Space } from "antd";
|
|
3
|
+
import React, { useCallback, useEffect, useState } from "react";
|
|
4
|
+
import { Many2oneSuffix } from "./many2one/Many2oneSuffix";
|
|
5
|
+
import { LoadingOutlined } from "@ant-design/icons";
|
|
6
|
+
|
|
7
|
+
export type ReferenceTreeProps = {
|
|
8
|
+
value: string;
|
|
9
|
+
context?: any;
|
|
10
|
+
selectionValues?: any;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const ReferenceTree = (
|
|
14
|
+
props: ReferenceTreeProps
|
|
15
|
+
): React.ReactElement => {
|
|
16
|
+
const { value, context, selectionValues } = props;
|
|
17
|
+
const [name, setName] = useState();
|
|
18
|
+
const [loading, setLoading] = useState(false);
|
|
19
|
+
|
|
20
|
+
const [model, id] = value ? value.split(",") : [];
|
|
21
|
+
const intId = parseInt(id);
|
|
22
|
+
|
|
23
|
+
const fetchName = useCallback(async () => {
|
|
24
|
+
if (!value) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (value && name) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
setLoading(true);
|
|
31
|
+
const nameResponse = await ConnectionProvider.getHandler().execute({
|
|
32
|
+
action: "name_get",
|
|
33
|
+
payload: [intId],
|
|
34
|
+
model,
|
|
35
|
+
context,
|
|
36
|
+
});
|
|
37
|
+
setName(nameResponse[0][1]);
|
|
38
|
+
setLoading(false);
|
|
39
|
+
}, [value, name]);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
fetchName();
|
|
43
|
+
}, [value]);
|
|
44
|
+
|
|
45
|
+
if (!value && !loading) {
|
|
46
|
+
return <></>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (loading) {
|
|
50
|
+
return <LoadingOutlined />;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const selectionDescription = selectionValues.get(model);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<Space>
|
|
57
|
+
<>{`${selectionDescription}:`}</>
|
|
58
|
+
<>{name}</>
|
|
59
|
+
<Many2oneSuffix id={intId} model={model} />
|
|
60
|
+
</Space>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
@@ -132,13 +132,12 @@ export const Many2oneInput: React.FC<Many2oneInputProps> = (
|
|
|
132
132
|
if (transformedDomain.current && transformedDomain.current.length > 0) {
|
|
133
133
|
tryFetchFirstResultOrShowSearch(inputTextRef.current as string);
|
|
134
134
|
} else {
|
|
135
|
-
const results: any[] =
|
|
136
|
-
{
|
|
135
|
+
const results: any[] =
|
|
136
|
+
await ConnectionProvider.getHandler().nameSearch({
|
|
137
137
|
model: relation,
|
|
138
138
|
payload: inputTextRef.current as string,
|
|
139
139
|
context: { ...getContext?.(), ...context },
|
|
140
|
-
}
|
|
141
|
-
);
|
|
140
|
+
});
|
|
142
141
|
|
|
143
142
|
if (results.length === 1) {
|
|
144
143
|
inputTextRef.current = undefined;
|
|
@@ -207,16 +206,16 @@ export const Many2oneInput: React.FC<Many2oneInputProps> = (
|
|
|
207
206
|
|
|
208
207
|
async function parseDomain() {
|
|
209
208
|
if (widgetDomain) {
|
|
210
|
-
transformedDomain.current =
|
|
211
|
-
{
|
|
209
|
+
transformedDomain.current =
|
|
210
|
+
await ConnectionProvider.getHandler().evalDomain({
|
|
212
211
|
domain: widgetDomain,
|
|
213
212
|
values: transformPlainMany2Ones({
|
|
214
213
|
fields: getFields(),
|
|
215
214
|
values: getValues(),
|
|
216
215
|
}),
|
|
216
|
+
fields: getFields(),
|
|
217
217
|
context: getContext(),
|
|
218
|
-
}
|
|
219
|
-
);
|
|
218
|
+
});
|
|
220
219
|
}
|
|
221
220
|
|
|
222
221
|
if (domain && domain.length > 0) {
|
|
@@ -232,7 +231,7 @@ export const Many2oneInput: React.FC<Many2oneInputProps> = (
|
|
|
232
231
|
}
|
|
233
232
|
|
|
234
233
|
async function onKeyDown(event: any) {
|
|
235
|
-
if (event.
|
|
234
|
+
if (event.keyCode === 13) {
|
|
236
235
|
event.preventDefault();
|
|
237
236
|
event.stopPropagation();
|
|
238
237
|
await onElementLostFocus();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Space } from "antd";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Many2oneSuffix } from "./Many2oneSuffix";
|
|
4
|
+
|
|
5
|
+
export type Many2oneTreeProps = { m2oField: any };
|
|
6
|
+
|
|
7
|
+
export const Many2oneTree = (props: Many2oneTreeProps): React.ReactElement => {
|
|
8
|
+
const { m2oField } = props;
|
|
9
|
+
if (!m2oField) {
|
|
10
|
+
return <></>;
|
|
11
|
+
}
|
|
12
|
+
return (
|
|
13
|
+
<Space>
|
|
14
|
+
<>{m2oField.value}</>
|
|
15
|
+
<Many2oneSuffix id={m2oField.id} model={m2oField.model} />
|
|
16
|
+
</Space>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
@@ -168,6 +168,7 @@ const One2manyInput: React.FC<One2manyInputProps> = (
|
|
|
168
168
|
fields: getFields(),
|
|
169
169
|
values: getValues(),
|
|
170
170
|
}),
|
|
171
|
+
fields: getFields(),
|
|
171
172
|
context: getContext(),
|
|
172
173
|
}),
|
|
173
174
|
widgetFieldName: fieldName,
|
|
@@ -573,6 +574,7 @@ const One2manyInput: React.FC<One2manyInputProps> = (
|
|
|
573
574
|
}}
|
|
574
575
|
sorter={sorter}
|
|
575
576
|
onChangeSort={setSorter}
|
|
577
|
+
context={{ ...getContext?.(), ...context }}
|
|
576
578
|
/>
|
|
577
579
|
);
|
|
578
580
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Group as GroupOoui } from "@gisce/ooui";
|
|
3
3
|
import Container from "./Container";
|
|
4
|
-
import
|
|
4
|
+
import { FieldSet } from "@gisce/react-formiga-components";
|
|
5
5
|
|
|
6
6
|
type Props = {
|
|
7
7
|
ooui: GroupOoui;
|
|
@@ -15,12 +15,12 @@ function Group(props: Props): React.ReactElement {
|
|
|
15
15
|
return (
|
|
16
16
|
<>
|
|
17
17
|
{ooui.label && showLabel ? (
|
|
18
|
-
<
|
|
18
|
+
<FieldSet label={ooui.label}>
|
|
19
19
|
<Container
|
|
20
20
|
container={ooui!.container}
|
|
21
21
|
responsiveBehaviour={responsiveBehaviour}
|
|
22
22
|
/>
|
|
23
|
-
</
|
|
23
|
+
</FieldSet>
|
|
24
24
|
) : (
|
|
25
25
|
<Container
|
|
26
26
|
container={ooui!.container}
|
|
@@ -62,6 +62,7 @@ export const MultiCheckboxInput = (props: MultiCheckboxInputProps) => {
|
|
|
62
62
|
fields: formContext?.getFields(),
|
|
63
63
|
values: formContext.getPlainValues(),
|
|
64
64
|
}),
|
|
65
|
+
fields: formContext?.getFields(),
|
|
65
66
|
context: formContext.getContext(),
|
|
66
67
|
});
|
|
67
68
|
params = [...params, ...evaluatedDomain];
|
|
@@ -23,7 +23,7 @@ export const Tags = (props: TagsProps) => {
|
|
|
23
23
|
|
|
24
24
|
return (
|
|
25
25
|
<Field type={"array"} {...props}>
|
|
26
|
-
<TagsInput ooui={ooui}
|
|
26
|
+
<TagsInput ooui={ooui} />
|
|
27
27
|
</Field>
|
|
28
28
|
);
|
|
29
29
|
};
|
|
@@ -31,16 +31,15 @@ export const Tags = (props: TagsProps) => {
|
|
|
31
31
|
export const TagsInput = (props: TagsInputProps) => {
|
|
32
32
|
const { value, ooui, onChange } = props;
|
|
33
33
|
const { items = [] } = value || {};
|
|
34
|
-
const itemsToShow = items
|
|
35
|
-
(item) => item.operation !== "pendingRemove"
|
|
36
|
-
|
|
34
|
+
const itemsToShow = items
|
|
35
|
+
.filter((item) => item.operation !== "pendingRemove")
|
|
36
|
+
.map((item) => item.id) as number[];
|
|
37
37
|
|
|
38
38
|
const [options, setOptions] = useState<any[]>([]);
|
|
39
39
|
const [error, setError] = useState<string>();
|
|
40
40
|
const [isLoadingOptions, setIsLoadingOptions] = useState<boolean>(false);
|
|
41
41
|
const { relation, context, readOnly, field } = ooui;
|
|
42
42
|
|
|
43
|
-
|
|
44
43
|
const formContext = useContext(FormContext) as FormContextType;
|
|
45
44
|
const { getContext } = formContext || {};
|
|
46
45
|
|
|
@@ -62,16 +61,16 @@ export const TagsInput = (props: TagsInputProps) => {
|
|
|
62
61
|
params = [["id", "in", itemsToShow]];
|
|
63
62
|
}
|
|
64
63
|
if (ooui.domain) {
|
|
65
|
-
const evaluatedDomain =
|
|
66
|
-
{
|
|
64
|
+
const evaluatedDomain =
|
|
65
|
+
await ConnectionProvider.getHandler().evalDomain({
|
|
67
66
|
domain: ooui.domain,
|
|
68
67
|
values: transformPlainMany2Ones({
|
|
69
68
|
fields: formContext?.getFields(),
|
|
70
69
|
values: formContext.getPlainValues(),
|
|
71
70
|
}),
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
fields: formContext?.getFields(),
|
|
72
|
+
context: formContext.getContext(),
|
|
73
|
+
});
|
|
75
74
|
params = [...params, ...evaluatedDomain];
|
|
76
75
|
}
|
|
77
76
|
|
|
@@ -81,18 +80,17 @@ export const TagsInput = (props: TagsInputProps) => {
|
|
|
81
80
|
fields: [field],
|
|
82
81
|
context: { ...getContext?.(), ...context },
|
|
83
82
|
});
|
|
84
|
-
const options = optionsRead.map((item:any) => {
|
|
83
|
+
const options = optionsRead.map((item: any) => {
|
|
85
84
|
const value = item[field];
|
|
86
85
|
let formattedValue = value;
|
|
87
86
|
if (Array.isArray(value)) {
|
|
88
87
|
formattedValue = value[1];
|
|
89
88
|
}
|
|
90
|
-
return {label: formattedValue, value: item.id}
|
|
89
|
+
return { label: formattedValue, value: item.id };
|
|
91
90
|
});
|
|
92
91
|
setOptions(options);
|
|
93
|
-
|
|
94
92
|
} catch (err) {
|
|
95
|
-
setError(err as any)
|
|
93
|
+
setError(err as any);
|
|
96
94
|
} finally {
|
|
97
95
|
setIsLoadingOptions(false);
|
|
98
96
|
}
|
|
@@ -104,19 +102,21 @@ export const TagsInput = (props: TagsInputProps) => {
|
|
|
104
102
|
if (item.operation == "pendingRemove") {
|
|
105
103
|
return {
|
|
106
104
|
...item,
|
|
107
|
-
operation: "pendingLink"
|
|
108
|
-
}
|
|
105
|
+
operation: "pendingLink",
|
|
106
|
+
};
|
|
109
107
|
} else {
|
|
110
|
-
return item
|
|
108
|
+
return item;
|
|
111
109
|
}
|
|
112
110
|
} else {
|
|
113
|
-
return {id: item.id, operation:
|
|
111
|
+
return { id: item.id, operation: "pendingRemove" };
|
|
114
112
|
}
|
|
115
|
-
})
|
|
116
|
-
const currentIds = newItems.map(item => item.id)
|
|
117
|
-
ids.filter(id => !currentIds.includes(id)).map((id) => {
|
|
118
|
-
newItems.push({id, operation: 'pendingLink'});
|
|
119
113
|
});
|
|
114
|
+
const currentIds = newItems.map((item) => item.id);
|
|
115
|
+
ids
|
|
116
|
+
.filter((id) => !currentIds.includes(id))
|
|
117
|
+
.map((id) => {
|
|
118
|
+
newItems.push({ id, operation: "pendingLink" });
|
|
119
|
+
});
|
|
120
120
|
triggerChange(newItems);
|
|
121
121
|
};
|
|
122
122
|
|
|
@@ -130,10 +130,11 @@ export const TagsInput = (props: TagsInputProps) => {
|
|
|
130
130
|
<AntTag
|
|
131
131
|
color={colorFromString(label)}
|
|
132
132
|
onMouseDown={onPreventMouseDown}
|
|
133
|
-
style={{margin:
|
|
133
|
+
style={{ margin: "5px" }}
|
|
134
134
|
closable={closable}
|
|
135
|
-
onClose={onClose}
|
|
136
|
-
|
|
135
|
+
onClose={onClose}
|
|
136
|
+
>
|
|
137
|
+
{label}
|
|
137
138
|
</AntTag>
|
|
138
139
|
);
|
|
139
140
|
};
|
|
@@ -154,10 +155,8 @@ export const TagsInput = (props: TagsInputProps) => {
|
|
|
154
155
|
options={options}
|
|
155
156
|
onChange={onChangeSelected}
|
|
156
157
|
loading={isLoadingOptions}
|
|
157
|
-
|
|
158
|
-
</Select>
|
|
158
|
+
></Select>
|
|
159
159
|
</div>
|
|
160
160
|
</>
|
|
161
161
|
);
|
|
162
|
-
|
|
163
162
|
};
|