@gisce/react-ooui 1.2.0-rc.4 → 1.2.0-rc.41
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/treeHelper.d.ts +1 -1
- package/dist/helpers/treeHelper.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.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 +16980 -18378
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +78 -51
- 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 -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 +2 -0
- package/dist/widgets/views/Tree.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 +94 -11
- package/src/actionbar/TreeActionBar.tsx +86 -69
- 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/treeHelper.ts +17 -5
- package/src/index.ts +2 -0
- 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/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/views/ActionView.tsx +15 -4
- 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 +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 +35 -24
- package/src/widgets/views/SearchTree.tsx +2 -0
- package/src/widgets/views/Tree.tsx +88 -25
- 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
|
@@ -79,14 +79,8 @@ type RemoveItemOptions = {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
const removeItems = async (options: RemoveItemOptions) => {
|
|
82
|
-
const {
|
|
83
|
-
|
|
84
|
-
activeId,
|
|
85
|
-
fieldName,
|
|
86
|
-
idsToRemove,
|
|
87
|
-
fields,
|
|
88
|
-
isMany2many,
|
|
89
|
-
} = options;
|
|
82
|
+
const { model, activeId, fieldName, idsToRemove, fields, isMany2many } =
|
|
83
|
+
options;
|
|
90
84
|
|
|
91
85
|
const values: any = {};
|
|
92
86
|
values[fieldName] = [];
|
|
@@ -136,4 +130,28 @@ const getNextPendingId = (items: One2manyItem[]) => {
|
|
|
136
130
|
}
|
|
137
131
|
};
|
|
138
132
|
|
|
139
|
-
|
|
133
|
+
const convertToPlain2ManyValues = (values: any, fields: any) => {
|
|
134
|
+
const result: any = {};
|
|
135
|
+
Object.keys(values).forEach((key) => {
|
|
136
|
+
if (
|
|
137
|
+
fields.hasOwnProperty(key) &&
|
|
138
|
+
(fields[key].type === "one2many" || fields[key].type === "many2many") &&
|
|
139
|
+
values[key] &&
|
|
140
|
+
values[key]?.items
|
|
141
|
+
) {
|
|
142
|
+
result[key] = values[key].items.filter(
|
|
143
|
+
(item: One2manyItem) => item.operation !== "pendingRemove"
|
|
144
|
+
);
|
|
145
|
+
} else {
|
|
146
|
+
result[key] = values[key];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return result;
|
|
150
|
+
};
|
|
151
|
+
export {
|
|
152
|
+
readObjectValues,
|
|
153
|
+
removeItems,
|
|
154
|
+
linkItem,
|
|
155
|
+
getNextPendingId,
|
|
156
|
+
convertToPlain2ManyValues,
|
|
157
|
+
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Tree as TreeOoui,
|
|
3
|
+
Selection,
|
|
4
|
+
Many2one,
|
|
5
|
+
Boolean,
|
|
6
|
+
Reference,
|
|
7
|
+
} from "@gisce/ooui";
|
|
2
8
|
import { TreeView, Column } from "@/types";
|
|
3
9
|
|
|
4
10
|
const getTree = (treeView: TreeView): TreeOoui => {
|
|
@@ -9,7 +15,11 @@ const getTree = (treeView: TreeView): TreeOoui => {
|
|
|
9
15
|
return tree;
|
|
10
16
|
};
|
|
11
17
|
|
|
12
|
-
const getTableColumns = (
|
|
18
|
+
const getTableColumns = (
|
|
19
|
+
tree: TreeOoui,
|
|
20
|
+
components: any,
|
|
21
|
+
context: any
|
|
22
|
+
): Array<Column> => {
|
|
13
23
|
const tableColumns = tree.columns.map((column) => {
|
|
14
24
|
const type = column.type;
|
|
15
25
|
const key = column.id;
|
|
@@ -18,7 +28,7 @@ const getTableColumns = (tree: TreeOoui, components: any): Array<Column> => {
|
|
|
18
28
|
|
|
19
29
|
if (component) {
|
|
20
30
|
render = (item: any) => {
|
|
21
|
-
return component(item);
|
|
31
|
+
return component(item, key, column, context);
|
|
22
32
|
};
|
|
23
33
|
}
|
|
24
34
|
|
|
@@ -54,9 +64,11 @@ const getTableItems = (treeOoui: TreeOoui, results: Array<any>): Array<any> => {
|
|
|
54
64
|
} else {
|
|
55
65
|
const widget = treeOoui.findById(key);
|
|
56
66
|
|
|
57
|
-
if (widget instanceof
|
|
67
|
+
if (widget instanceof Reference) {
|
|
68
|
+
parsedItem[key] = item[key];
|
|
69
|
+
} else if (widget instanceof Selection) {
|
|
58
70
|
const selection = widget;
|
|
59
|
-
parsedItem[key] =
|
|
71
|
+
parsedItem[key] = item[key];
|
|
60
72
|
} else if (widget instanceof Many2one) {
|
|
61
73
|
parsedItem[key] = item[key] &&
|
|
62
74
|
Array.isArray(item[key]) &&
|
package/src/index.ts
CHANGED
|
@@ -37,6 +37,7 @@ import { Image } from "@/widgets/base/Image";
|
|
|
37
37
|
import showConfirmDialog from "@/ui/ConfirmDialog";
|
|
38
38
|
import Dashboard from "@/widgets/views/Dashboard/Dashboard";
|
|
39
39
|
import { Tags } from "@/widgets/custom/Tags";
|
|
40
|
+
import { Tag } from "@/widgets/custom/Tag";
|
|
40
41
|
import { MultiCheckbox } from "./widgets/custom/MultiCheckbox";
|
|
41
42
|
import { Radio } from "@/widgets/custom/Radio";
|
|
42
43
|
import { Switch } from "@/widgets/custom/Switch";
|
|
@@ -145,6 +146,7 @@ export {
|
|
|
145
146
|
DashboardGridItem,
|
|
146
147
|
DashboardGrid,
|
|
147
148
|
Tags,
|
|
149
|
+
Tag,
|
|
148
150
|
MultiCheckbox,
|
|
149
151
|
Radio,
|
|
150
152
|
Switch,
|
package/src/locales/ca_ES.tsx
CHANGED
|
@@ -86,4 +86,8 @@ export default {
|
|
|
86
86
|
totalRegisters: "Registres totals:",
|
|
87
87
|
export: "Exportar",
|
|
88
88
|
selectAtLeastOneField: "Selecciona almenys un camp per a l'exportació",
|
|
89
|
+
printScreen: "Imprimir pantalla",
|
|
90
|
+
advancedExport: "Exportació avançada",
|
|
91
|
+
savedRegisters: "Registre guardat correctament",
|
|
92
|
+
errorWhileSavingForm: "Error en guardar el formulari",
|
|
89
93
|
};
|
package/src/locales/en_US.tsx
CHANGED
|
@@ -83,4 +83,8 @@ export default {
|
|
|
83
83
|
totalRegisters: "Total registers:",
|
|
84
84
|
export: "Export",
|
|
85
85
|
selectAtLeastOneField: "Select at least one field for the export",
|
|
86
|
+
printScreen: "Print screen",
|
|
87
|
+
advancedExport: "Advanced export",
|
|
88
|
+
savedRegisters: "Record successfully saved",
|
|
89
|
+
errorWhileSavingForm: "Error while saving form",
|
|
86
90
|
};
|
package/src/locales/es_ES.tsx
CHANGED
|
@@ -87,4 +87,8 @@ export default {
|
|
|
87
87
|
totalRegisters: "Registros totales:",
|
|
88
88
|
export: "Exportar",
|
|
89
89
|
selectAtLeastOneField: "Selecciona al menos un campo para la exportación",
|
|
90
|
+
printScreen: "Imprimir pantalla",
|
|
91
|
+
advancedExport: "Exportación avanzada",
|
|
92
|
+
savedRegisters: "Registro guardado correctamente",
|
|
93
|
+
errorWhileSavingForm: "Error al guardar el formulario",
|
|
90
94
|
};
|
|
@@ -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">
|
|
@@ -167,3 +167,30 @@ export const IconTabs = (): React.ReactElement => {
|
|
|
167
167
|
</LocaleProvider>
|
|
168
168
|
);
|
|
169
169
|
};
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
export const IconTablerTabs = (): React.ReactElement => {
|
|
173
|
+
|
|
174
|
+
const arch = `<form>
|
|
175
|
+
<notebook name="notebook">
|
|
176
|
+
<page string="Home" icon="bolt">
|
|
177
|
+
<field name="name" />
|
|
178
|
+
</page>
|
|
179
|
+
<page string="Attributes" icon="address-book">
|
|
180
|
+
<field name="surname" />
|
|
181
|
+
</page>
|
|
182
|
+
</notebook>
|
|
183
|
+
</form>`;
|
|
184
|
+
|
|
185
|
+
const formOoui = new FormOoui(fields);
|
|
186
|
+
formOoui.parse(arch);
|
|
187
|
+
const notebookOoui = formOoui.findById("notebook") as NotebookOoui;
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<LocaleProvider lang="en_US">
|
|
191
|
+
<Form>
|
|
192
|
+
<Notebook ooui={notebookOoui} />
|
|
193
|
+
</Form>
|
|
194
|
+
</LocaleProvider>
|
|
195
|
+
);
|
|
196
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { Tag as TagOoui } from "@gisce/ooui";
|
|
4
|
+
import "antd/dist/antd.css";
|
|
5
|
+
import LocaleProvider from "../../context/LocaleContext";
|
|
6
|
+
import { TagInput } from "../../widgets/custom/Tag";
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: "Components/Widgets/Custom/Tag",
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const Default = (): React.ReactElement => {
|
|
13
|
+
const ooui = new TagOoui({
|
|
14
|
+
name: "status",
|
|
15
|
+
string: "Status",
|
|
16
|
+
field: "status",
|
|
17
|
+
selection: [['draft', 'Draft'], ['open', 'Open']],
|
|
18
|
+
widget_props: '{"colors": {"draft": "blue", "open": "green"}}'
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<LocaleProvider lang="en_US">
|
|
23
|
+
<TagInput value="draft" ooui={ooui}/>
|
|
24
|
+
</LocaleProvider>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const WithoutColor = (): React.ReactElement => {
|
|
29
|
+
const ooui = new TagOoui({
|
|
30
|
+
name: "status",
|
|
31
|
+
string: "Status",
|
|
32
|
+
field: "status",
|
|
33
|
+
selection: [['draft', 'Draft'], ['open', 'Open']],
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<LocaleProvider lang="en_US">
|
|
38
|
+
<TagInput value="draft" ooui={ooui}/>
|
|
39
|
+
</LocaleProvider>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const WithColorAuto = (): React.ReactElement => {
|
|
44
|
+
const ooui = new TagOoui({
|
|
45
|
+
name: "status",
|
|
46
|
+
string: "Status",
|
|
47
|
+
field: "status",
|
|
48
|
+
selection: [['draft', 'Draft'], ['open', 'Open']],
|
|
49
|
+
widget_props: '{"colors": "auto"}'
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<LocaleProvider lang="en_US">
|
|
54
|
+
<TagInput value="draft" ooui={ooui}/>
|
|
55
|
+
</LocaleProvider>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -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: {} },
|
|
@@ -30,7 +30,7 @@ Default.args = {
|
|
|
30
30
|
lang: false,
|
|
31
31
|
name: "AGRI ENERGIA ELECTRICA, S.A.",
|
|
32
32
|
ref: "0112",
|
|
33
|
-
title:
|
|
33
|
+
title: "corp",
|
|
34
34
|
numeric: 30.1,
|
|
35
35
|
progressbar: 100,
|
|
36
36
|
},
|
|
@@ -41,7 +41,7 @@ Default.args = {
|
|
|
41
41
|
lang: false,
|
|
42
42
|
name: "Agrolait",
|
|
43
43
|
ref: false,
|
|
44
|
-
title:
|
|
44
|
+
title: "ltd",
|
|
45
45
|
numeric: 30.1,
|
|
46
46
|
progressbar: 70.434331,
|
|
47
47
|
},
|
|
@@ -85,14 +85,14 @@ Default.args = {
|
|
|
85
85
|
lang: false,
|
|
86
86
|
name: "Aragón",
|
|
87
87
|
ref: "02",
|
|
88
|
-
title:
|
|
88
|
+
title: "corp",
|
|
89
89
|
numeric: 30.1,
|
|
90
90
|
progressbar: 20.01,
|
|
91
91
|
},
|
|
92
92
|
],
|
|
93
93
|
treeView: {
|
|
94
94
|
arch:
|
|
95
|
-
|
|
95
|
+
`<tree string="Partners">\n<field name="numeric" sum="Numeric"/><field name="name"/>\n <field name="title" widget="tag" widget_props="{'colors': {'corp': 'red', 'ltd': 'green'}}"/>\n <field name="ref"/>\n <field name="city" select="2"/>\n <field name="country" select="2"/>\n <field name="lang"/>\n <field name="progressbar" string="Progress" /> </tree>`,
|
|
96
96
|
fields: {
|
|
97
97
|
progressbar: {
|
|
98
98
|
string: "Progress bar",
|
|
@@ -149,7 +149,7 @@ Default.args = {
|
|
|
149
149
|
},
|
|
150
150
|
title: {
|
|
151
151
|
selection: [
|
|
152
|
-
["
|
|
152
|
+
["corp", "Corp."],
|
|
153
153
|
["ltd", "Ltd"],
|
|
154
154
|
["", ""],
|
|
155
155
|
],
|
package/src/types/index.ts
CHANGED
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
|
}
|
|
@@ -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"
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
Radio,
|
|
30
30
|
Switch,
|
|
31
31
|
Steps,
|
|
32
|
+
Tag,
|
|
32
33
|
CodeEditor,
|
|
33
34
|
} from "@/index";
|
|
34
35
|
import { Image } from "./base/Image";
|
|
@@ -99,6 +100,8 @@ const getWidgetType = (type: string) => {
|
|
|
99
100
|
return Indicator;
|
|
100
101
|
case "tags":
|
|
101
102
|
return Tags;
|
|
103
|
+
case "tag":
|
|
104
|
+
return Tag;
|
|
102
105
|
case "multicheckbox":
|
|
103
106
|
return MultiCheckbox;
|
|
104
107
|
case "radio":
|
|
@@ -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
|
+
};
|