@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.
Files changed (121) hide show
  1. package/dist/actionbar/FormActionBar.d.ts.map +1 -1
  2. package/dist/actionbar/TreeActionBar.d.ts.map +1 -1
  3. package/dist/context/ActionViewContext.d.ts +5 -1
  4. package/dist/context/ActionViewContext.d.ts.map +1 -1
  5. package/dist/context/ContentRootContext.d.ts.map +1 -1
  6. package/dist/context/FormContext.d.ts +4 -1
  7. package/dist/context/FormContext.d.ts.map +1 -1
  8. package/dist/helpers/formHelper.d.ts +5 -3
  9. package/dist/helpers/formHelper.d.ts.map +1 -1
  10. package/dist/helpers/iconMapper.d.ts +5 -1
  11. package/dist/helpers/iconMapper.d.ts.map +1 -1
  12. package/dist/helpers/one2manyHelper.d.ts +2 -1
  13. package/dist/helpers/one2manyHelper.d.ts.map +1 -1
  14. package/dist/helpers/searchHelper.d.ts +1 -1
  15. package/dist/helpers/searchHelper.d.ts.map +1 -1
  16. package/dist/helpers/treeHelper.d.ts +1 -1
  17. package/dist/helpers/treeHelper.d.ts.map +1 -1
  18. package/dist/hooks/useExport.d.ts +39 -0
  19. package/dist/hooks/useExport.d.ts.map +1 -0
  20. package/dist/index.d.ts +2 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/locales/ca_ES.d.ts +2 -0
  23. package/dist/locales/ca_ES.d.ts.map +1 -1
  24. package/dist/locales/en_US.d.ts +2 -0
  25. package/dist/locales/en_US.d.ts.map +1 -1
  26. package/dist/locales/es_ES.d.ts +2 -0
  27. package/dist/locales/es_ES.d.ts.map +1 -1
  28. package/dist/react-ooui.es.js +19204 -21320
  29. package/dist/react-ooui.es.js.map +1 -1
  30. package/dist/react-ooui.umd.js +45 -183
  31. package/dist/react-ooui.umd.js.map +1 -1
  32. package/dist/types/index.d.ts +1 -0
  33. package/dist/types/index.d.ts.map +1 -1
  34. package/dist/views/ActionView.d.ts.map +1 -1
  35. package/dist/views/RootView.d.ts.map +1 -1
  36. package/dist/views/actionViews/TreeActionView.d.ts.map +1 -1
  37. package/dist/widgets/WidgetFactory.d.ts.map +1 -1
  38. package/dist/widgets/base/Integer.d.ts.map +1 -1
  39. package/dist/widgets/base/Label.d.ts.map +1 -1
  40. package/dist/widgets/base/ReferenceTree.d.ts +8 -0
  41. package/dist/widgets/base/ReferenceTree.d.ts.map +1 -0
  42. package/dist/widgets/base/many2one/Many2one.d.ts.map +1 -1
  43. package/dist/widgets/base/many2one/Many2oneTree.d.ts +6 -0
  44. package/dist/widgets/base/many2one/Many2oneTree.d.ts.map +1 -0
  45. package/dist/widgets/base/one2many/One2manyInput.d.ts.map +1 -1
  46. package/dist/widgets/custom/MultiCheckbox.d.ts.map +1 -1
  47. package/dist/widgets/custom/Tag.d.ts +5 -0
  48. package/dist/widgets/custom/Tag.d.ts.map +1 -0
  49. package/dist/widgets/custom/Tags.d.ts.map +1 -1
  50. package/dist/widgets/modals/ExportModal.d.ts +2 -1
  51. package/dist/widgets/modals/ExportModal.d.ts.map +1 -1
  52. package/dist/widgets/views/Dashboard/Dashboard.d.ts.map +1 -1
  53. package/dist/widgets/views/Dashboard/DashboardTree.d.ts.map +1 -1
  54. package/dist/widgets/views/Form.d.ts.map +1 -1
  55. package/dist/widgets/views/Graph/GraphChart.d.ts.map +1 -1
  56. package/dist/widgets/views/Graph/GraphDefaults.d.ts +36 -0
  57. package/dist/widgets/views/Graph/GraphDefaults.d.ts.map +1 -1
  58. package/dist/widgets/views/SearchTree.d.ts.map +1 -1
  59. package/dist/widgets/views/Tree.d.ts +2 -0
  60. package/dist/widgets/views/Tree.d.ts.map +1 -1
  61. package/dist/widgets/views/searchFilter/SearchFilter.d.ts +1 -0
  62. package/dist/widgets/views/searchFilter/SearchFilter.d.ts.map +1 -1
  63. package/package.json +6 -5
  64. package/src/__tests__/iconMapper.test.ts +20 -5
  65. package/src/actionbar/ChangeViewButton.tsx +2 -2
  66. package/src/actionbar/FormActionBar.tsx +82 -11
  67. package/src/actionbar/TreeActionBar.tsx +23 -28
  68. package/src/context/ActionViewContext.tsx +7 -4
  69. package/src/context/ContentRootContext.tsx +15 -7
  70. package/src/context/FormContext.tsx +1 -1
  71. package/src/helpers/formHelper.ts +26 -5
  72. package/src/helpers/iconMapper.ts +134 -107
  73. package/src/helpers/one2manyHelper.ts +27 -9
  74. package/src/helpers/searchHelper.ts +8 -7
  75. package/src/helpers/treeHelper.ts +17 -5
  76. package/src/hooks/useExport.ts +438 -0
  77. package/src/index.ts +2 -0
  78. package/src/locales/ca_ES.tsx +2 -0
  79. package/src/locales/en_US.tsx +2 -0
  80. package/src/locales/es_ES.tsx +2 -0
  81. package/src/stories/Label.stories.tsx +7 -8
  82. package/src/stories/containers/Notebook.stories.tsx +27 -0
  83. package/src/stories/custom/Tag.stories.tsx +57 -0
  84. package/src/stories/mocks/models/crm_case.ts +7 -10
  85. package/src/stories/views/Tree.stories.jsx +5 -5
  86. package/src/types/index.ts +1 -0
  87. package/src/ui/FavouriteButton.tsx +4 -4
  88. package/src/views/ActionView.tsx +3 -0
  89. package/src/views/RootView.tsx +7 -1
  90. package/src/views/actionViews/TreeActionView.tsx +10 -1
  91. package/src/widgets/WidgetFactory.tsx +3 -0
  92. package/src/widgets/base/Integer.tsx +1 -0
  93. package/src/widgets/base/Label.tsx +5 -9
  94. package/src/widgets/base/ReferenceTree.tsx +62 -0
  95. package/src/widgets/base/many2one/Many2one.tsx +8 -9
  96. package/src/widgets/base/many2one/Many2oneTree.tsx +18 -0
  97. package/src/widgets/base/one2many/One2manyInput.tsx +2 -0
  98. package/src/widgets/containers/Group.tsx +3 -3
  99. package/src/widgets/custom/ButtonGroup.tsx +1 -1
  100. package/src/widgets/custom/MultiCheckbox.tsx +1 -0
  101. package/src/widgets/custom/Tag.tsx +24 -0
  102. package/src/widgets/custom/Tags.tsx +27 -28
  103. package/src/widgets/modals/ExportModal.tsx +33 -134
  104. package/src/widgets/views/Dashboard/Dashboard.tsx +5 -1
  105. package/src/widgets/views/Dashboard/DashboardTree.tsx +1 -0
  106. package/src/widgets/views/Form.tsx +35 -24
  107. package/src/widgets/views/Graph/GraphChart.tsx +6 -1
  108. package/src/widgets/views/Graph/GraphDefaults.ts +60 -0
  109. package/src/widgets/views/Graph/GraphIndicator.tsx +17 -3
  110. package/src/widgets/views/SearchTree.tsx +3 -0
  111. package/src/widgets/views/Tree.tsx +88 -25
  112. package/src/widgets/views/searchFilter/SearchFilter.tsx +12 -6
  113. package/dist/helpers/icons/antd_icons.d.ts +0 -4
  114. package/dist/helpers/icons/antd_icons.d.ts.map +0 -1
  115. package/dist/helpers/icons/tabler_icons.d.ts +0 -4
  116. package/dist/helpers/icons/tabler_icons.d.ts.map +0 -1
  117. package/dist/ui/Fieldset.d.ts +0 -8
  118. package/dist/ui/Fieldset.d.ts.map +0 -1
  119. package/src/helpers/icons/antd_icons.ts +0 -1583
  120. package/src/helpers/icons/tabler_icons.ts +0 -5367
  121. package/src/ui/Fieldset.tsx +0 -31
@@ -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&#xF3;">\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&#xF3;">\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&#xF3;">\n <field name="note"/>\n </tree>\n ',
163
+ arch: '<tree string="Historial de comunicaci&#xF3;">\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: false,
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: false,
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: false,
88
+ title: "corp",
89
89
  numeric: 30.1,
90
90
  progressbar: 20.01,
91
91
  },
92
92
  ],
93
93
  treeView: {
94
94
  arch:
95
- '<tree string="Partners">\n<field name="numeric" sum="Numeric"/><field name="name"/>\n <field name="title"/>\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>',
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
- ["Corp.", "Corp."],
152
+ ["corp", "Corp."],
153
153
  ["ltd", "Ltd"],
154
154
  ["", ""],
155
155
  ],
@@ -224,6 +224,7 @@ type EvalDomainRequest = {
224
224
  domain: string;
225
225
  values: any;
226
226
  context?: any;
227
+ fields?: any;
227
228
  };
228
229
 
229
230
  type IsShortcutFavoriteOptions = {
@@ -55,7 +55,7 @@ const FavouriteButton = (props: Props) => {
55
55
  const [shortcuts, setShortcuts] = useState<ShortcutApi[]>([]);
56
56
  const [loading, setLoading] = useState(true);
57
57
  const [currentShortcutId, setCurrentShortcutId] = useState<number>();
58
- const { t } = useContext(LocaleContext) as LocaleContextType;
58
+ const { t } = (useContext(LocaleContext) as LocaleContextType) || {};
59
59
 
60
60
  const tabManagerContext = useContext(
61
61
  TabManagerContext
@@ -150,10 +150,10 @@ const FavouriteButton = (props: Props) => {
150
150
  <Menu onClick={handleMenuClick}>
151
151
  <div style={{ width: 300, padding: 5, display: "flex" }}>
152
152
  <div style={{ paddingLeft: 15, color: "#ccc" }}>
153
- {t("favorites").toUpperCase()}
153
+ {t?.("favorites").toUpperCase()}
154
154
  </div>
155
155
  <div style={{ flexGrow: 1, paddingLeft: 10 }}>
156
- <Tooltip title={t("edit_favorites")}>
156
+ <Tooltip title={t?.("edit_favorites")}>
157
157
  <EditOutlined
158
158
  style={{ color: "#1890FF", cursor: "pointer" }}
159
159
  onClick={editFavourites}
@@ -177,7 +177,7 @@ const FavouriteButton = (props: Props) => {
177
177
  </>
178
178
  ) : (
179
179
  <div style={{ width: 300, padding: 5, paddingLeft: 15 }}>
180
- {t("no_favorites")}
180
+ {t?.("no_favorites")}
181
181
  </div>
182
182
  )}
183
183
  </Menu>
@@ -192,6 +192,7 @@ function ActionView(props: Props, ref: any) {
192
192
  case "form": {
193
193
  viewDataRetrieved.push({
194
194
  ...(viewInfo as FormView),
195
+ type: viewType,
195
196
  });
196
197
  break;
197
198
  }
@@ -199,12 +200,14 @@ function ActionView(props: Props, ref: any) {
199
200
  viewDataRetrieved.push({
200
201
  ...(viewInfo as TreeView),
201
202
  isExpandable: treeExpandable,
203
+ type: viewType,
202
204
  });
203
205
  break;
204
206
  }
205
207
  case "graph": {
206
208
  viewDataRetrieved.push({
207
209
  ...(viewInfo as GraphView),
210
+ type: viewType,
208
211
  });
209
212
  break;
210
213
  }
@@ -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={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":
@@ -32,6 +32,7 @@ export const Integer = (props: IntegerProps) => {
32
32
  }}
33
33
  defaultValue={0}
34
34
  onBlur={elementHasLostFocus}
35
+ precision={0}
35
36
  />
36
37
  </Field>
37
38
  );
@@ -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
- label,
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" ? ((labelSize as string) as any) : null}
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[] = await ConnectionProvider.getHandler().nameSearch(
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 = await ConnectionProvider.getHandler().evalDomain(
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.code === "Enter") {
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 Fieldset from "@/ui/Fieldset";
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
- <Fieldset label={ooui.label}>
18
+ <FieldSet label={ooui.label}>
19
19
  <Container
20
20
  container={ooui!.container}
21
21
  responsiveBehaviour={responsiveBehaviour}
22
22
  />
23
- </Fieldset>
23
+ </FieldSet>
24
24
  ) : (
25
25
  <Container
26
26
  container={ooui!.container}
@@ -83,7 +83,7 @@ export const ButtonGroup = (props: ButtonGroupProps) => {
83
83
  type={primary ? "primary" : undefined}
84
84
  //danger={danger ? true : undefined} This works but typescript
85
85
  // doesn't accept
86
- overlay={<Items ooui={secondaryButtons} />}
86
+ overlay={Items({ooui: secondaryButtons})}
87
87
  >
88
88
  {getButtonIcon()}
89
89
  {caption}
@@ -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];
@@ -0,0 +1,24 @@
1
+ import Field from "@/common/Field";
2
+ import { WidgetProps } from "@/types";
3
+ import { Tag as AntdTag } from 'antd';
4
+ import { colorFromString } from "@/helpers/formHelper";
5
+
6
+
7
+ export const Tag = (props: WidgetProps) => {
8
+ return (
9
+ <Field {...props}>
10
+ <TagInput {...props}/>
11
+ </Field>
12
+ );
13
+ };
14
+
15
+ export const TagInput = (props) => {
16
+ const {ooui, value} = props;
17
+ if (!value) {
18
+ return null
19
+ }
20
+ const color = ooui.colors === "auto" ? colorFromString(value) : ooui.colors[value]
21
+ return (
22
+ <AntdTag color={color}>{ooui.selectionValues.get(value)}</AntdTag>
23
+ );
24
+ }
@@ -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.filter(
35
- (item) => item.operation !== "pendingRemove"
36
- ).map((item) => item.id) as number[];
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 = await ConnectionProvider.getHandler().evalDomain(
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
- context: formContext.getContext(),
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: 'pendingRemove'}
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: '5px'}}
133
+ style={{ margin: "5px" }}
134
134
  closable={closable}
135
- onClose={onClose}>
136
- {label}
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
  };