@gisce/react-ooui 2.0.0-alpha.62 → 2.0.0-alpha.63

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 (245) hide show
  1. package/dist/react-ooui.es.js +1 -1
  2. package/dist/react-ooui.es.js.map +1 -1
  3. package/package.json +6 -8
  4. package/src/ConnectionProvider.ts +0 -16
  5. package/src/__tests__/iconMapper.test.ts +0 -30
  6. package/src/__tests__/searchFilterHelper.spec.ts +0 -386
  7. package/src/actionbar/ActionButton.tsx +0 -40
  8. package/src/actionbar/AttachmentsButton.tsx +0 -132
  9. package/src/actionbar/AttachmentsButtonWrapper.tsx +0 -157
  10. package/src/actionbar/ButtonWithBadge.tsx +0 -44
  11. package/src/actionbar/ChangeViewButton.tsx +0 -137
  12. package/src/actionbar/DashboardActionBar.tsx +0 -63
  13. package/src/actionbar/DropdownButton.tsx +0 -124
  14. package/src/actionbar/FormActionBar.tsx +0 -491
  15. package/src/actionbar/GraphActionBar.tsx +0 -67
  16. package/src/actionbar/NewButton.tsx +0 -46
  17. package/src/actionbar/SearchBar.tsx +0 -73
  18. package/src/actionbar/TreeActionBar.tsx +0 -383
  19. package/src/common/ButtonWithTooltip.tsx +0 -18
  20. package/src/common/DatePicker.tsx +0 -98
  21. package/src/common/Field.tsx +0 -93
  22. package/src/common/SelectAllRecordsRow.tsx +0 -94
  23. package/src/common/TimePicker.tsx +0 -38
  24. package/src/context/ActionViewContext.tsx +0 -213
  25. package/src/context/ConfigContext.tsx +0 -28
  26. package/src/context/ContentRootContext.tsx +0 -461
  27. package/src/context/DashboardActionContext.tsx +0 -44
  28. package/src/context/FormContext.tsx +0 -79
  29. package/src/context/FormModalContext.tsx +0 -28
  30. package/src/context/LocaleContext.tsx +0 -50
  31. package/src/context/One2manyContext.tsx +0 -45
  32. package/src/context/TabManagerContext.tsx +0 -117
  33. package/src/helpers/containerHelper.ts +0 -145
  34. package/src/helpers/dayjs.ts +0 -21
  35. package/src/helpers/dynamicColumnsHelper.ts +0 -73
  36. package/src/helpers/errorHelper.ts +0 -27
  37. package/src/helpers/filesHelper.ts +0 -41
  38. package/src/helpers/formHelper.ts +0 -301
  39. package/src/helpers/iconMapper.ts +0 -164
  40. package/src/helpers/logInfoHelper.tsx +0 -30
  41. package/src/helpers/one2manyHelper.ts +0 -194
  42. package/src/helpers/searchHelper.ts +0 -196
  43. package/src/helpers/timeHelper.ts +0 -58
  44. package/src/helpers/treeHelper.tsx +0 -226
  45. package/src/helpers/viewHelper.ts +0 -23
  46. package/src/hooks/useEffectDebugger.ts +0 -43
  47. package/src/hooks/useExport.ts +0 -439
  48. package/src/hooks/useFetchViews.ts +0 -0
  49. package/src/hooks/useSearch.ts +0 -434
  50. package/src/hooks/useWindowDimensions.ts +0 -33
  51. package/src/index.ts +0 -168
  52. package/src/locales/ca_ES.tsx +0 -99
  53. package/src/locales/en_US.tsx +0 -96
  54. package/src/locales/es_ES.tsx +0 -101
  55. package/src/stories/Binary.stories.tsx +0 -23
  56. package/src/stories/Boolean.stories.tsx +0 -22
  57. package/src/stories/Button.stories.tsx +0 -130
  58. package/src/stories/Char.stories.tsx +0 -76
  59. package/src/stories/FiberGrid.stories.tsx +0 -109
  60. package/src/stories/Float.stories.tsx +0 -22
  61. package/src/stories/FloatTime.stories.tsx +0 -32
  62. package/src/stories/Image.stories.tsx +0 -25
  63. package/src/stories/Integer.stories.tsx +0 -22
  64. package/src/stories/Label.stories.tsx +0 -100
  65. package/src/stories/Many2one.stories.tsx +0 -31
  66. package/src/stories/One2many.stories.tsx +0 -288
  67. package/src/stories/ProgressBar.stories.tsx +0 -22
  68. package/src/stories/Reference.stories.tsx +0 -43
  69. package/src/stories/Selection.stories.tsx +0 -34
  70. package/src/stories/Separator.stories.tsx +0 -53
  71. package/src/stories/Text.stories.tsx +0 -35
  72. package/src/stories/Time.stories.tsx +0 -31
  73. package/src/stories/Utils.stories.tsx +0 -14
  74. package/src/stories/containers/Group.stories.tsx +0 -84
  75. package/src/stories/containers/NewLine.stories.tsx +0 -52
  76. package/src/stories/containers/Notebook.stories.tsx +0 -188
  77. package/src/stories/custom/Avatar.stories.tsx +0 -22
  78. package/src/stories/custom/ButtonGroup.stories.tsx +0 -74
  79. package/src/stories/custom/CodeEditor.stories.tsx +0 -25
  80. package/src/stories/custom/Comments.stories.tsx +0 -197
  81. package/src/stories/custom/Indicator.stories.tsx +0 -36
  82. package/src/stories/custom/Markdown.stories.tsx +0 -38
  83. package/src/stories/custom/MultiCheckbox.stories.tsx +0 -60
  84. package/src/stories/custom/Radio.stories.tsx +0 -68
  85. package/src/stories/custom/Steps.stories.tsx +0 -43
  86. package/src/stories/custom/Switch.stories.tsx +0 -23
  87. package/src/stories/custom/Tag.stories.tsx +0 -66
  88. package/src/stories/custom/Tags.stories.tsx +0 -74
  89. package/src/stories/dashboard/Dashboard.stories.tsx +0 -23
  90. package/src/stories/dashboard/DashboardGrid.stories.tsx +0 -43
  91. package/src/stories/forms/ActivacioContracteForm.stories.tsx +0 -25
  92. package/src/stories/forms/Attachment.stories.tsx +0 -24
  93. package/src/stories/forms/CUPSForm.stories.tsx +0 -25
  94. package/src/stories/forms/Company.stories.tsx +0 -25
  95. package/src/stories/forms/CrmCaseForm.stories.tsx +0 -25
  96. package/src/stories/forms/Documents.stories.tsx +0 -25
  97. package/src/stories/forms/FormWithGridFiber.stories.tsx +0 -25
  98. package/src/stories/forms/FormWithLinks.stories.tsx +0 -30
  99. package/src/stories/forms/Lead.stories.tsx +0 -25
  100. package/src/stories/forms/ModContractForm.stories.tsx +0 -26
  101. package/src/stories/forms/PartnersForm.stories.tsx +0 -25
  102. package/src/stories/forms/PolissaForm.stories.tsx +0 -25
  103. package/src/stories/forms/PreferencesForm.stories.tsx +0 -691
  104. package/src/stories/forms/Signatures.stories.tsx +0 -25
  105. package/src/stories/forms/Switching.stories.tsx +0 -25
  106. package/src/stories/graphs/GraphIndicator.stories.tsx +0 -20
  107. package/src/stories/graphs/PieGraph.stories.tsx +0 -78
  108. package/src/stories/mocks/index.ts +0 -46
  109. package/src/stories/mocks/mockProvider.ts +0 -189
  110. package/src/stories/mocks/models/activacioContracte.ts +0 -112
  111. package/src/stories/mocks/models/attachment.ts +0 -1326
  112. package/src/stories/mocks/models/butlleti.ts +0 -296
  113. package/src/stories/mocks/models/company.ts +0 -135
  114. package/src/stories/mocks/models/crm_case.ts +0 -595
  115. package/src/stories/mocks/models/cups.ts +0 -937
  116. package/src/stories/mocks/models/document.ts +0 -223
  117. package/src/stories/mocks/models/factura.ts +0 -2713
  118. package/src/stories/mocks/models/form_with_gridfiber.ts +0 -141
  119. package/src/stories/mocks/models/hist_autoconsum.ts +0 -146
  120. package/src/stories/mocks/models/lead.ts +0 -2101
  121. package/src/stories/mocks/models/modcontractual.ts +0 -952
  122. package/src/stories/mocks/models/partner.ts +0 -1340
  123. package/src/stories/mocks/models/polissa.ts +0 -3127
  124. package/src/stories/mocks/models/res_partner_category.ts +0 -15
  125. package/src/stories/mocks/models/signatura.ts +0 -558
  126. package/src/stories/mocks/models/switching.ts +0 -767
  127. package/src/stories/modals/FormModal.stories.tsx +0 -36
  128. package/src/stories/modals/SearchModal.stories.tsx +0 -37
  129. package/src/stories/trees/FacturesTree.stories.tsx +0 -16
  130. package/src/stories/ui/ActionBar.stories.tsx +0 -21
  131. package/src/stories/ui/FavouriteButton.stories.tsx +0 -16
  132. package/src/stories/ui/GoToResourceModal.stories.tsx +0 -25
  133. package/src/stories/views/ActionView.stories.tsx +0 -28
  134. package/src/stories/views/SearchTree.stories.tsx +0 -1064
  135. package/src/stories/views/Tab.stories.tsx +0 -93
  136. package/src/stories/views/TabsAndContent.stories.tsx +0 -88
  137. package/src/stories/views/Tree.stories.jsx +0 -178
  138. package/src/stories/views/searchFilter/DateRangePicker.stories.tsx +0 -22
  139. package/src/stories/views/searchFilter/DateTimeRangePicker.stories.tsx +0 -23
  140. package/src/stories/views/searchFilter/PairFields.stories.tsx +0 -23
  141. package/src/stories/views/searchFilter/SearchFilter.stories.tsx +0 -165
  142. package/src/stories/views/searchFilter/examples/PartnersSearchFilter.stories.tsx +0 -409
  143. package/src/types/index.ts +0 -392
  144. package/src/ui/ActionErrorDialog.tsx +0 -24
  145. package/src/ui/ConfirmDialog.tsx +0 -28
  146. package/src/ui/ErrorAlert.tsx +0 -37
  147. package/src/ui/FavouriteButton.tsx +0 -271
  148. package/src/ui/FormErrorsDialog.tsx +0 -17
  149. package/src/ui/GenericErrorDialog.tsx +0 -16
  150. package/src/ui/GoToResourceModal.tsx +0 -76
  151. package/src/ui/InfoDialog.tsx +0 -13
  152. package/src/ui/RefreshItemDialog.tsx +0 -29
  153. package/src/ui/RemoveItemDialog.tsx +0 -20
  154. package/src/ui/TitleHeader.tsx +0 -117
  155. package/src/ui/UnlinkItemDialog.tsx +0 -20
  156. package/src/ui/UnsavedChangesDialog.tsx +0 -29
  157. package/src/ui/WarningDialog.tsx +0 -17
  158. package/src/views/ActionView.tsx +0 -526
  159. package/src/views/CurrentTabContent.tsx +0 -21
  160. package/src/views/RootView.tsx +0 -509
  161. package/src/views/TabContent.tsx +0 -31
  162. package/src/views/TabSelector.tsx +0 -31
  163. package/src/views/Welcome.tsx +0 -18
  164. package/src/views/actionViews/DashboardActionView.tsx +0 -52
  165. package/src/views/actionViews/FormActionView.tsx +0 -70
  166. package/src/views/actionViews/GraphActionView.tsx +0 -152
  167. package/src/views/actionViews/TreeActionView.tsx +0 -87
  168. package/src/views/tabs/Tab.tsx +0 -82
  169. package/src/widgets/WidgetFactory.tsx +0 -142
  170. package/src/widgets/base/Binary.tsx +0 -145
  171. package/src/widgets/base/Boolean.tsx +0 -44
  172. package/src/widgets/base/Button.tsx +0 -77
  173. package/src/widgets/base/Char.tsx +0 -157
  174. package/src/widgets/base/Date.tsx +0 -12
  175. package/src/widgets/base/DateTime.tsx +0 -12
  176. package/src/widgets/base/Email.tsx +0 -27
  177. package/src/widgets/base/Float.tsx +0 -38
  178. package/src/widgets/base/FloatTime.tsx +0 -73
  179. package/src/widgets/base/Image.tsx +0 -120
  180. package/src/widgets/base/Integer.tsx +0 -55
  181. package/src/widgets/base/Label.tsx +0 -56
  182. package/src/widgets/base/LinkInput.tsx +0 -106
  183. package/src/widgets/base/MultiSelection.tsx +0 -90
  184. package/src/widgets/base/ProgressBar.tsx +0 -38
  185. package/src/widgets/base/Reference.tsx +0 -115
  186. package/src/widgets/base/ReferenceTree.tsx +0 -62
  187. package/src/widgets/base/Selection.tsx +0 -71
  188. package/src/widgets/base/Separator.tsx +0 -25
  189. package/src/widgets/base/Text.tsx +0 -162
  190. package/src/widgets/base/Time.tsx +0 -40
  191. package/src/widgets/base/Url.tsx +0 -26
  192. package/src/widgets/base/many2one/Many2one.tsx +0 -322
  193. package/src/widgets/base/many2one/Many2oneSuffix.tsx +0 -232
  194. package/src/widgets/base/many2one/Many2oneSuffixModal.tsx +0 -42
  195. package/src/widgets/base/many2one/Many2oneTree.tsx +0 -18
  196. package/src/widgets/base/one2many/One2many.tsx +0 -100
  197. package/src/widgets/base/one2many/One2manyInput.tsx +0 -724
  198. package/src/widgets/base/one2many/One2manyTopBar.tsx +0 -158
  199. package/src/widgets/containers/Container.tsx +0 -99
  200. package/src/widgets/containers/Group.tsx +0 -37
  201. package/src/widgets/containers/Notebook.tsx +0 -52
  202. package/src/widgets/custom/Avatar.tsx +0 -40
  203. package/src/widgets/custom/ButtonGroup.tsx +0 -169
  204. package/src/widgets/custom/CodeEditor.tsx +0 -32
  205. package/src/widgets/custom/Comments.tsx +0 -147
  206. package/src/widgets/custom/FiberGrid.tsx +0 -48
  207. package/src/widgets/custom/Indicator.tsx +0 -66
  208. package/src/widgets/custom/Markdown.tsx +0 -32
  209. package/src/widgets/custom/MultiCheckbox.tsx +0 -165
  210. package/src/widgets/custom/Radio.tsx +0 -47
  211. package/src/widgets/custom/Steps.tsx +0 -56
  212. package/src/widgets/custom/Switch.tsx +0 -26
  213. package/src/widgets/custom/Tag.tsx +0 -53
  214. package/src/widgets/custom/Tags.tsx +0 -164
  215. package/src/widgets/custom/Timeline.tsx +0 -196
  216. package/src/widgets/modals/ExportModal.tsx +0 -75
  217. package/src/widgets/modals/FormModal.tsx +0 -125
  218. package/src/widgets/modals/SearchModal.tsx +0 -130
  219. package/src/widgets/modals/TranslationModal.tsx +0 -202
  220. package/src/widgets/views/Dashboard/Dashboard.tsx +0 -381
  221. package/src/widgets/views/Dashboard/DashboardForm.tsx +0 -30
  222. package/src/widgets/views/Dashboard/DashboardTree.tsx +0 -238
  223. package/src/widgets/views/Dashboard/dashboardHelper.ts +0 -79
  224. package/src/widgets/views/DashboardGrid/DashboardGrid.tsx +0 -53
  225. package/src/widgets/views/DashboardGrid/DashboardGrid.types.ts +0 -4
  226. package/src/widgets/views/DashboardGrid/DashboardGridItem.tsx +0 -62
  227. package/src/widgets/views/DashboardGrid/DashboardGridItem.types.ts +0 -10
  228. package/src/widgets/views/DashboardGrid/index.ts +0 -4
  229. package/src/widgets/views/Form.tsx +0 -1152
  230. package/src/widgets/views/Graph/Graph.tsx +0 -145
  231. package/src/widgets/views/Graph/GraphChart.tsx +0 -113
  232. package/src/widgets/views/Graph/GraphDefaults.ts +0 -170
  233. package/src/widgets/views/Graph/GraphIndicator.tsx +0 -421
  234. package/src/widgets/views/Graph/useGraphData.tsx +0 -176
  235. package/src/widgets/views/SearchTree.tsx +0 -367
  236. package/src/widgets/views/Tree/Tree.tsx +0 -295
  237. package/src/widgets/views/Tree/index.ts +0 -1
  238. package/src/widgets/views/Tree/treeComponents.tsx +0 -283
  239. package/src/widgets/views/searchFilter/DateRangePicker.tsx +0 -16
  240. package/src/widgets/views/searchFilter/DateTimeRangePicker.tsx +0 -87
  241. package/src/widgets/views/searchFilter/PairFields.tsx +0 -56
  242. package/src/widgets/views/searchFilter/SearchBottomBar.tsx +0 -54
  243. package/src/widgets/views/searchFilter/SearchField.tsx +0 -63
  244. package/src/widgets/views/searchFilter/SearchFilter.tsx +0 -160
  245. package/src/widgets/views/searchFilter/SearchParams.tsx +0 -35
package/package.json CHANGED
@@ -1,16 +1,15 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "2.0.0-alpha.62",
3
+ "version": "2.0.0-alpha.63",
4
4
  "engines": {
5
5
  "node": "20.5.0"
6
6
  },
7
+ "packageManager": "npm@9.8.0",
7
8
  "publishConfig": {
8
9
  "access": "public"
9
10
  },
10
11
  "files": [
11
- "dist",
12
- "src",
13
- "README.md"
12
+ "dist"
14
13
  ],
15
14
  "module": "./dist/react-ooui.es.js",
16
15
  "types": "./dist/index.d.ts",
@@ -29,7 +28,7 @@
29
28
  "check": "lint-staged",
30
29
  "storybook": "storybook dev -p 6006",
31
30
  "build-storybook": "storybook build",
32
- "analyze": "npm run build && npx vite-bundle-visualizer"
31
+ "analyze": "npx vite-bundle-visualizer"
33
32
  },
34
33
  "dependencies": {
35
34
  "@ant-design/plots": "^1.0.9",
@@ -44,6 +43,7 @@
44
43
  "file-type-buffer-browser": "git+ssh://git@github.com/mguellsegarra/file-type-buffer-browser.git",
45
44
  "interweave": "^13.0.0",
46
45
  "md5": "^2.3.0",
46
+ "nanoid": "^5.0.4",
47
47
  "react": "18.2.0",
48
48
  "react-dom": "18.2.0",
49
49
  "react-grid-layout": "^1.3.4",
@@ -53,7 +53,6 @@
53
53
  "remark-gfm": "^4.0.0",
54
54
  "styled-components": "5.3.5",
55
55
  "use-deep-compare-effect": "^1.8.1",
56
- "uuid": "^9.0.1",
57
56
  "validator": "^13.6.0"
58
57
  },
59
58
  "devDependencies": {
@@ -81,7 +80,6 @@
81
80
  "@types/rollup-plugin-peer-deps-external": "^2.2.2",
82
81
  "@types/scroll-into-view": "^1.16.0",
83
82
  "@types/styled-components": "^5.1.7",
84
- "@types/uuid": "^8.3.1",
85
83
  "@types/validator": "^13.6.3",
86
84
  "@typescript-eslint/eslint-plugin": "5.59.0",
87
85
  "@typescript-eslint/parser": "5.59.0",
@@ -102,7 +100,7 @@
102
100
  "semantic-release": "21.0.7",
103
101
  "storybook": "^7.4.6",
104
102
  "typescript": "^5.0.4",
105
- "vite": "4.4.8",
103
+ "vite": "4.5.1",
106
104
  "vite-bundle-visualizer": "^0.10.0",
107
105
  "vite-plugin-dts": "^3.6.0",
108
106
  "vite-tsconfig-paths": "3.5.0"
@@ -1,16 +0,0 @@
1
- import { ConnectionProviderType } from "@/types";
2
-
3
- export default class ConnectionProvider {
4
- private static handler: ConnectionProviderType;
5
-
6
- public static init(handler: ConnectionProviderType): void {
7
- ConnectionProvider.handler = handler;
8
- }
9
-
10
- public static getHandler(): ConnectionProviderType {
11
- if (!ConnectionProvider.handler) {
12
- throw "Must call init() first with a valid ConnectionProvider instance";
13
- }
14
- return ConnectionProvider.handler;
15
- }
16
- }
@@ -1,30 +0,0 @@
1
- import iconMapper from "../helpers/iconMapper";
2
- import * as Icons from "@ant-design/icons";
3
-
4
- describe("A IconMapper instance", () => {
5
- test("should return undefined when key not found", () => {
6
- const icon = iconMapper("foo-bar");
7
- expect(icon).toBe(undefined);
8
- });
9
- test("should return proper help icon when requested", () => {
10
- const helpIcon = Icons.QuestionOutlined;
11
- const icon = iconMapper("gtk-help");
12
- expect(icon).toBe(helpIcon);
13
- });
14
- test("should replace all - for _", () => {
15
- const findAndReplaceIcon = Icons.FileSearchOutlined;
16
- const icon = iconMapper("gtk-find-and-replace");
17
- expect(icon).toBe(findAndReplaceIcon);
18
- });
19
- test("should return gtk-go", () => {
20
- const findAndReplaceIcon = Icons.FileSearchOutlined;
21
- const icon = iconMapper("gtk-find-and-replace");
22
- expect(icon).toBe(findAndReplaceIcon);
23
- });
24
- describe("If key doesn't exist in iconMapper", () => {
25
- test("should return undefined", () => {
26
- const icon = iconMapper("gtk-foo-bar");
27
- expect(icon).toBe(undefined);
28
- });
29
- });
30
- });
@@ -1,386 +0,0 @@
1
- import {
2
- removeUndefinedFields,
3
- groupDateTimeValuesIfNeeded,
4
- getParamsForFields,
5
- } from "../helpers/searchFilterHelper";
6
- import dayjs from "dayjs";
7
-
8
- describe("A SearchFilterHelper instance", () => {
9
- describe("removeUndefinedFields method", () => {
10
- test("should return the same object without undefined fields", () => {
11
- const object = {
12
- testField: "field",
13
- testField2: undefined,
14
- testField3: undefined,
15
- };
16
-
17
- const filteredObject = removeUndefinedFields(object);
18
-
19
- expect(Object.keys(filteredObject).length).toBe(1);
20
- expect(filteredObject.testField).toBe("field");
21
- });
22
- test("should return an object without fields", () => {
23
- const object = {
24
- testField2: undefined,
25
- testField3: undefined,
26
- };
27
-
28
- const filteredObject = removeUndefinedFields(object);
29
-
30
- expect(Object.keys(filteredObject).length).toBe(0);
31
- });
32
- test("should return same object if it hasn't any undefined files", () => {
33
- const object = {
34
- testField1: "field",
35
- testField2: "field",
36
- };
37
-
38
- const filteredObject = removeUndefinedFields(object);
39
-
40
- expect(Object.keys(filteredObject).length).toBe(2);
41
- expect(filteredObject.testField1).toBe("field");
42
- expect(filteredObject.testField2).toBe("field");
43
- });
44
- test("should return an object without fields if we send a null", () => {
45
- const object = {
46
- testField1: null,
47
- };
48
-
49
- const filteredObject = removeUndefinedFields(object);
50
- expect(Object.keys(filteredObject).length).toBe(0);
51
- });
52
- test("should return an object without fields if we send a blank string", () => {
53
- const object = {
54
- testField1: "",
55
- };
56
-
57
- const filteredObject = removeUndefinedFields(object);
58
- expect(Object.keys(filteredObject).length).toBe(0);
59
- });
60
- });
61
- describe("groupRangeValues method", () => {
62
- test("should return the same object if it hasn't any datetime fields to group", () => {
63
- const object = {
64
- charValue: "test",
65
- floatValue: 0.5,
66
- };
67
-
68
- const filteredObject = groupDateTimeValuesIfNeeded(object);
69
-
70
- expect(JSON.stringify(filteredObject)).toBe(JSON.stringify(object));
71
- });
72
- test("should return a datetime value grouped", () => {
73
- const object = {
74
- charValue: "test",
75
- floatValue: 0.5,
76
- "dateField#date": [dayjs("2021-01-01"), dayjs("2021-01-02")],
77
- "dateField#time": [
78
- dayjs("1970-01-01 00:00"),
79
- dayjs("1970-01-01 04:00"),
80
- ],
81
- };
82
-
83
- const filteredObject = groupDateTimeValuesIfNeeded(object);
84
-
85
- expect(Object.keys(filteredObject).length).toBe(3);
86
- expect(Object.keys(filteredObject)).toContain("dateField#datetime");
87
- expect(filteredObject.charValue).toBe(object.charValue);
88
- expect(filteredObject.floatValue).toBe(object.floatValue);
89
- expect(Array.isArray(filteredObject["dateField#datetime"])).toBeTruthy();
90
- const from = filteredObject["dateField#datetime"][0];
91
- const to = filteredObject["dateField#datetime"][1];
92
- expect(from).toBe("2021-01-01 00:00");
93
- expect(to).toBe("2021-01-02 04:00");
94
- });
95
- });
96
- describe("getParamsForField method", () => {
97
- test("should return properly a float parameter", () => {
98
- const fields = {
99
- floatType: {
100
- type: "float",
101
- },
102
- };
103
- const values = {
104
- "floatType#from": 1.1,
105
- "floatType#to": 1.5,
106
- };
107
- const params = getParamsForFields(values, fields);
108
- expect(Array.isArray(params)).toBeTruthy();
109
- expect(params.length).toBe(2);
110
- expect(Array.isArray(params[0])).toBeTruthy();
111
- expect(params[0].length).toBe(3);
112
- const from = params[0];
113
- const to = params[1];
114
- expect(Array.isArray(from)).toBeTruthy();
115
- expect(Array.isArray(to)).toBeTruthy();
116
- expect(from[0]).toBe("floatType");
117
- expect(to[0]).toBe("floatType");
118
- expect(from[1]).toBe(">=");
119
- expect(to[1]).toBe("<=");
120
- expect(from[2]).toBe(1.1);
121
- expect(to[2]).toBe(1.5);
122
- });
123
- test("should return properly a float_time parameter", () => {
124
- const fields = {
125
- floatType: {
126
- type: "float_time",
127
- },
128
- };
129
- const values = {
130
- "floatType#from": 1.1,
131
- "floatType#to": 1.5,
132
- };
133
- const params = getParamsForFields(values, fields);
134
- expect(Array.isArray(params)).toBeTruthy();
135
- expect(params.length).toBe(2);
136
- expect(Array.isArray(params[0])).toBeTruthy();
137
- expect(params[0].length).toBe(3);
138
- const from = params[0];
139
- const to = params[1];
140
- expect(Array.isArray(from)).toBeTruthy();
141
- expect(Array.isArray(to)).toBeTruthy();
142
- expect(from[0]).toBe("floatType");
143
- expect(to[0]).toBe("floatType");
144
- expect(from[1]).toBe(">=");
145
- expect(to[1]).toBe("<=");
146
- expect(from[2]).toBe(1.1);
147
- expect(to[2]).toBe(1.5);
148
- });
149
- test("should return properly a progressbar parameter", () => {
150
- const fields = {
151
- floatType: {
152
- type: "progressbar",
153
- },
154
- };
155
- const values = {
156
- "floatType#from": 1.1,
157
- "floatType#to": 1.5,
158
- };
159
- const params = getParamsForFields(values, fields);
160
- expect(Array.isArray(params)).toBeTruthy();
161
- expect(params.length).toBe(2);
162
- expect(Array.isArray(params[0])).toBeTruthy();
163
- expect(params[0].length).toBe(3);
164
- const from = params[0];
165
- const to = params[1];
166
- expect(Array.isArray(from)).toBeTruthy();
167
- expect(Array.isArray(to)).toBeTruthy();
168
- expect(from[0]).toBe("floatType");
169
- expect(to[0]).toBe("floatType");
170
- expect(from[1]).toBe(">=");
171
- expect(to[1]).toBe("<=");
172
- expect(from[2]).toBe(1.1);
173
- expect(to[2]).toBe(1.5);
174
- });
175
- test("should return properly an integer parameter", () => {
176
- const fields = {
177
- field: {
178
- type: "integer",
179
- },
180
- };
181
- const values = {
182
- "field#from": 1,
183
- "field#to": 5,
184
- };
185
- const params = getParamsForFields(values, fields);
186
- expect(Array.isArray(params)).toBeTruthy();
187
- expect(params.length).toBe(2);
188
- expect(Array.isArray(params[0])).toBeTruthy();
189
- expect(params[0].length).toBe(3);
190
- const from = params[0];
191
- const to = params[1];
192
- expect(Array.isArray(from)).toBeTruthy();
193
- expect(Array.isArray(to)).toBeTruthy();
194
- expect(from[0]).toBe("field");
195
- expect(to[0]).toBe("field");
196
- expect(from[1]).toBe(">=");
197
- expect(to[1]).toBe("<=");
198
- expect(from[2]).toBe(1);
199
- expect(to[2]).toBe(5);
200
- });
201
- test("should return properly an char parameter", () => {
202
- const fields = {
203
- field: {
204
- type: "char",
205
- },
206
- };
207
- const values = {
208
- field: "lorem ipsum",
209
- };
210
- const params = getParamsForFields(values, fields);
211
- expect(Array.isArray(params)).toBeTruthy();
212
- expect(params.length).toBe(1);
213
- expect(Array.isArray(params[0])).toBeTruthy();
214
- expect(params[0].length).toBe(3);
215
- const fieldParams = params[0];
216
- expect(fieldParams[0]).toBe("field");
217
- expect(fieldParams[1]).toBe("ilike");
218
- expect(fieldParams[2]).toBe("lorem ipsum");
219
- });
220
- test("should return properly a text parameter", () => {
221
- const fields = {
222
- field: {
223
- type: "text",
224
- },
225
- };
226
- const values = {
227
- field: "lorem ipsum",
228
- };
229
- const params = getParamsForFields(values, fields);
230
- expect(Array.isArray(params)).toBeTruthy();
231
- expect(params.length).toBe(1);
232
- expect(Array.isArray(params[0])).toBeTruthy();
233
- expect(params[0].length).toBe(3);
234
- const fieldParams = params[0];
235
- expect(fieldParams[0]).toBe("field");
236
- expect(fieldParams[1]).toBe("ilike");
237
- expect(fieldParams[2]).toBe("lorem ipsum");
238
- });
239
- test("should return properly a many2one parameter", () => {
240
- const fields = {
241
- field: {
242
- type: "many2one",
243
- },
244
- };
245
- const values = {
246
- field: "lorem ipsum",
247
- };
248
- const params = getParamsForFields(values, fields);
249
- expect(Array.isArray(params)).toBeTruthy();
250
- expect(params.length).toBe(1);
251
- expect(Array.isArray(params[0])).toBeTruthy();
252
- expect(params[0].length).toBe(3);
253
- const fieldParams = params[0];
254
- expect(fieldParams[0]).toBe("field");
255
- expect(fieldParams[1]).toBe("ilike");
256
- expect(fieldParams[2]).toBe("lorem ipsum");
257
- });
258
- test("should return properly a one2many parameter", () => {
259
- const fields = {
260
- field: {
261
- type: "one2many",
262
- },
263
- };
264
- const values = {
265
- field: "lorem ipsum",
266
- };
267
- const params = getParamsForFields(values, fields);
268
- expect(Array.isArray(params)).toBeTruthy();
269
- expect(params.length).toBe(1);
270
- expect(Array.isArray(params[0])).toBeTruthy();
271
- expect(params[0].length).toBe(3);
272
- const fieldParams = params[0];
273
- expect(fieldParams[0]).toBe("field");
274
- expect(fieldParams[1]).toBe("ilike");
275
- expect(fieldParams[2]).toBe("lorem ipsum");
276
- });
277
- test("should return properly a many2many parameter", () => {
278
- const fields = {
279
- field: {
280
- type: "many2many",
281
- },
282
- };
283
- const values = {
284
- field: "lorem ipsum",
285
- };
286
- const params = getParamsForFields(values, fields);
287
- expect(Array.isArray(params)).toBeTruthy();
288
- expect(params.length).toBe(1);
289
- expect(Array.isArray(params[0])).toBeTruthy();
290
- expect(params[0].length).toBe(3);
291
- const fieldParams = params[0];
292
- expect(fieldParams[0]).toBe("field");
293
- expect(fieldParams[1]).toBe("ilike");
294
- expect(fieldParams[2]).toBe("lorem ipsum");
295
- });
296
- test("should return properly a selection parameter", () => {
297
- const fields = {
298
- field: {
299
- type: "selection",
300
- },
301
- };
302
- const values = {
303
- field: "value",
304
- };
305
- const params = getParamsForFields(values, fields);
306
- expect(Array.isArray(params)).toBeTruthy();
307
- expect(params.length).toBe(1);
308
- expect(Array.isArray(params[0])).toBeTruthy();
309
- expect(params[0].length).toBe(3);
310
- const fieldParams = params[0];
311
- expect(fieldParams[0]).toBe("field");
312
- expect(fieldParams[1]).toBe("=");
313
- expect(fieldParams[2]).toBe("value");
314
- });
315
- test("should return properly a boolean parameter", () => {
316
- const fields = {
317
- field: {
318
- type: "boolean",
319
- },
320
- };
321
- const values = {
322
- field: "true",
323
- };
324
- const params = getParamsForFields(values, fields);
325
- expect(Array.isArray(params)).toBeTruthy();
326
- expect(params.length).toBe(1);
327
- expect(Array.isArray(params[0])).toBeTruthy();
328
- expect(params[0].length).toBe(3);
329
- const fieldParams = params[0];
330
- expect(fieldParams[0]).toBe("field");
331
- expect(fieldParams[1]).toBe("=");
332
- expect(fieldParams[2]).toBe(true);
333
- });
334
- test("should return properly a date parameter", () => {
335
- const fields = {
336
- field: {
337
- type: "date",
338
- },
339
- };
340
- const values = {
341
- field: [dayjs("2021-01-01"), dayjs("2021-01-02")],
342
- };
343
- const params = getParamsForFields(values, fields);
344
- expect(Array.isArray(params)).toBeTruthy();
345
- expect(params.length).toBe(2);
346
- expect(Array.isArray(params[0])).toBeTruthy();
347
- expect(params[0].length).toBe(3);
348
- const from = params[0];
349
- const to = params[1];
350
- expect(Array.isArray(from)).toBeTruthy();
351
- expect(Array.isArray(to)).toBeTruthy();
352
- expect(from[0]).toBe("field");
353
- expect(to[0]).toBe("field");
354
- expect(from[1]).toBe(">=");
355
- expect(to[1]).toBe("<=");
356
- expect(from[2]).toBe("2021-01-01");
357
- expect(to[2]).toBe("2021-01-02");
358
- });
359
- test("should return properly a datetime parameter", () => {
360
- const fields = {
361
- field: {
362
- type: "datetime",
363
- },
364
- };
365
- const values = {
366
- "field#date": [dayjs("2021-01-01"), dayjs("2021-01-02")],
367
- "field#time": [dayjs("1970-01-01 03:31"), dayjs("1970-01-01 03:32")],
368
- };
369
- const params = getParamsForFields(values, fields);
370
- expect(Array.isArray(params)).toBeTruthy();
371
- expect(params.length).toBe(2);
372
- expect(Array.isArray(params[0])).toBeTruthy();
373
- expect(params[0].length).toBe(3);
374
- const from = params[0];
375
- const to = params[1];
376
- expect(Array.isArray(from)).toBeTruthy();
377
- expect(Array.isArray(to)).toBeTruthy();
378
- expect(from[0]).toBe("field");
379
- expect(to[0]).toBe("field");
380
- expect(from[1]).toBe(">=");
381
- expect(to[1]).toBe("<=");
382
- expect(from[2]).toBe("2021-01-01 03:31");
383
- expect(to[2]).toBe("2021-01-02 03:32");
384
- });
385
- });
386
- });
@@ -1,40 +0,0 @@
1
- import React from "react";
2
- import ButtonWithTooltip from "@/common/ButtonWithTooltip";
3
- import { LoadingOutlined } from "@ant-design/icons";
4
-
5
- type Props = {
6
- tooltip: string;
7
- onClick: any;
8
- icon: any;
9
- disabled?: boolean;
10
- label?: string;
11
- loading?: boolean;
12
- type?: string;
13
- };
14
-
15
- function ActionButton(props: Props) {
16
- const {
17
- onClick,
18
- disabled = false,
19
- loading = false,
20
- tooltip,
21
- icon,
22
- label,
23
- type = "default",
24
- } = props;
25
- const finalIcon = loading ? <LoadingOutlined /> : icon;
26
-
27
- return (
28
- <ButtonWithTooltip
29
- type={type as any}
30
- tooltip={tooltip}
31
- onClick={onClick}
32
- disabled={disabled}
33
- >
34
- {finalIcon}
35
- {label}
36
- </ButtonWithTooltip>
37
- );
38
- }
39
-
40
- export default ActionButton;
@@ -1,132 +0,0 @@
1
- import React, { useCallback, useContext, useEffect, useState } from "react";
2
- import { getMimeType, openBase64InNewTab } from "@/helpers/filesHelper";
3
- import ConnectionProvider from "@/ConnectionProvider";
4
- import {
5
- ActionViewContext,
6
- ActionViewContextType,
7
- } from "@/context/ActionViewContext";
8
- import showErrorDialog from "@/ui/ActionErrorDialog";
9
- import {
10
- Attachment,
11
- AttachmentsButtonWrapper,
12
- } from "./AttachmentsButtonWrapper";
13
- import { Modal, Spin } from "antd";
14
- import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
15
-
16
- export type AttachmentsButtonProps = {
17
- attachments?: any;
18
- disabled?: boolean;
19
- onAddNewAttachment: () => void;
20
- onListAllAttachments: () => void;
21
- onViewAttachmentDetails: (attachment: Attachment) => void;
22
- };
23
-
24
- function AttachmentsButton(props: AttachmentsButtonProps) {
25
- const {
26
- attachments,
27
- disabled = false,
28
- onAddNewAttachment,
29
- onListAllAttachments,
30
- onViewAttachmentDetails,
31
- } = props;
32
- const { formRef } = useContext(ActionViewContext) as ActionViewContextType;
33
- const [preloading, setPreloading] = useState(false);
34
- const [preloadedAttachments, setPreloadedAttachments] = useState<
35
- Attachment[]
36
- >([]);
37
- const [downloading, setDownloading] = useState(false);
38
- const { t } = useContext(LocaleContext) as LocaleContextType;
39
-
40
- const preloadAttachments = useCallback(async () => {
41
- setPreloading(true);
42
- try {
43
- const results = await ConnectionProvider.getHandler().readObjects({
44
- model: "ir.attachment",
45
- ids: attachments.map((a: any) => a.id),
46
- fieldsToRetrieve: ["name", "datas_fname", "link"],
47
- context: (formRef.current as any).getContext(),
48
- });
49
- setPreloadedAttachments(
50
- results.map((r: any) => ({
51
- id: r.id,
52
- name: r.name,
53
- datas_fname: r.datas_fname,
54
- link: r.link,
55
- })),
56
- );
57
- } catch (error) {
58
- showErrorDialog(error as any);
59
- }
60
- setPreloading(false);
61
- }, attachments);
62
-
63
- const openAttachmentLink = useCallback(async (attachment: any) => {
64
- if (attachment.link) {
65
- window.open(attachment.link);
66
- return;
67
- }
68
-
69
- setDownloading(true);
70
-
71
- let retrievedAttachment;
72
-
73
- try {
74
- const results = await ConnectionProvider.getHandler().readObjects({
75
- model: "ir.attachment",
76
- ids: [attachment.id],
77
- context: (formRef.current as any).getContext(),
78
- });
79
- retrievedAttachment = results[0];
80
- } catch (error) {
81
- showErrorDialog(error as any);
82
- }
83
-
84
- setDownloading(false);
85
-
86
- if (!retrievedAttachment) {
87
- return;
88
- }
89
-
90
- if (retrievedAttachment.datas) {
91
- const fileType: any = await getMimeType(retrievedAttachment.datas);
92
- openBase64InNewTab(retrievedAttachment.datas, fileType.mime);
93
- } else {
94
- onViewAttachmentDetails(retrievedAttachment);
95
- }
96
- }, []);
97
-
98
- const openAttachmentDetail = useCallback(async (attachment: any) => {
99
- onViewAttachmentDetails(attachment);
100
- }, []);
101
-
102
- useEffect(() => {
103
- preloadAttachments();
104
- }, [preloadAttachments]);
105
-
106
- return (
107
- <>
108
- <AttachmentsButtonWrapper
109
- numberOfAttachments={attachments.length}
110
- attachments={preloadedAttachments}
111
- disabled={disabled}
112
- loading={preloading}
113
- onAddNewAttachment={onAddNewAttachment}
114
- onListAllAttachments={onListAllAttachments}
115
- onopenAttachmentLink={openAttachmentLink}
116
- onOpenAttachmentDetail={openAttachmentDetail}
117
- />
118
- <Modal
119
- title={t("downloadingAttachment")}
120
- open={downloading}
121
- footer={null}
122
- closable={false}
123
- centered
124
- maskClosable={false}
125
- >
126
- <Spin />
127
- </Modal>
128
- </>
129
- );
130
- }
131
-
132
- export default AttachmentsButton;