@m4l/components 3.1.7 → 3.1.8

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 (201) hide show
  1. package/index.js +183 -340
  2. package/node_modules-CQtkw0uG.js +7350 -0
  3. package/package.json +1 -1
  4. package/vendor-AfIOyqRr.js +24636 -0
  5. package/components/AccountPopover/index-Dm2-k-Mv.js +0 -334
  6. package/components/AppBar/index-i0rhG3J1.js +0 -93
  7. package/components/BaseModule/index-CiNNlxzS.js +0 -30
  8. package/components/CommonActions/components/ActionCancel/index-CIdpDXkr.js +0 -12
  9. package/components/CommonActions/components/ActionFormCancel/index-CpyASN3q.js +0 -56
  10. package/components/CommonActions/components/ActionFormIntro/index-7KKtcUra.js +0 -33
  11. package/components/CommonActions/components/ActionIntro/index-CqqDZZcG.js +0 -25
  12. package/components/CommonActions/components/Actions/index-CuG1pnXW.js +0 -70
  13. package/components/DataGrid/constants-8L7QgBKi.js +0 -10
  14. package/components/DataGrid/formatters/ColumnBooleanFormatter/index-CveSCbq_.js +0 -26
  15. package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index-CHqvieM2.js +0 -22
  16. package/components/DataGrid/formatters/ColumnDateFormatter/index-CKg8CJ6A.js +0 -19
  17. package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index-DE6bwaKP.js +0 -23
  18. package/components/DataGrid/formatters/ColumnNestedValueFormatter/index-BslXGK-A.js +0 -14
  19. package/components/DataGrid/formatters/ColumnPointsFormatter/index-BXGW2CsK.js +0 -10
  20. package/components/DataGrid/formatters/ColumnPriceFormatter/index-O11tBykn.js +0 -10
  21. package/components/DataGrid/formatters/ColumnSetCheckFormatter/index-BaCawLr1.js +0 -36
  22. package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index-Cq7a-jnE.js +0 -10
  23. package/components/DataGrid/formatters/index-CrZXPa0e.js +0 -13
  24. package/components/DataGrid/index-BZ-lbmuU.js +0 -908
  25. package/components/DataGrid/subcomponents/Actions/index-CHvPZ4Ru.js +0 -549
  26. package/components/DataGrid/subcomponents/editors/TextEditor/index-BIFm8akr.js +0 -80
  27. package/components/DragResizeWindow/index-D2jLYExo.js +0 -505
  28. package/components/DynamicFilter/constants-ByqmFATV.js +0 -31
  29. package/components/DynamicFilter/dictionary-PrbXU3VZ.js +0 -51
  30. package/components/DynamicFilter/index-DZiJc9h7.js +0 -116
  31. package/components/DynamicFilter/slots/SlotsEnum-cawFeNzx.js +0 -34
  32. package/components/DynamicFilter/slots/dynamicFilterSlots-DHxelhXP.js +0 -151
  33. package/components/DynamicFilter/slots/index-l0sNRNKZ.js +0 -1
  34. package/components/DynamicFilter/store/index-BT-eWVnJ.js +0 -254
  35. package/components/DynamicFilter/subcomponents/AppliedFilterChip/index-B32bAzi-.js +0 -60
  36. package/components/DynamicFilter/subcomponents/AppliedFilters/index-Bha19drV.js +0 -26
  37. package/components/DynamicFilter/subcomponents/DynamicFilterBase/index-BmvzoHit.js +0 -40
  38. package/components/DynamicFilter/subcomponents/FieldTypes/BooleanFilter/index-BcO3SlP5.js +0 -129
  39. package/components/DynamicFilter/subcomponents/FieldTypes/DateTimeFilter/index-BCJhpNS8.js +0 -171
  40. package/components/DynamicFilter/subcomponents/FieldTypes/NumberFilter/index-DCNhz68u.js +0 -153
  41. package/components/DynamicFilter/subcomponents/FieldTypes/SelectFilter/index-BdypjM1Y.js +0 -146
  42. package/components/DynamicFilter/subcomponents/FieldTypes/StringFilter/index-D-NFIVnK.js +0 -114
  43. package/components/DynamicFilter/subcomponents/FieldTypes/index-BwQHJqk9.js +0 -38
  44. package/components/DynamicFilter/subcomponents/FilterActions/index-B9UWmk07.js +0 -88
  45. package/components/DynamicFilter/subcomponents/InputFilter/index-CfGb1TfV.js +0 -188
  46. package/components/DynamicFilter/subcomponents/PopoverFilter/index-DkfRGrlO.js +0 -158
  47. package/components/DynamicFilter/subcomponents/PopoverMenuFields/index-DSegwAm2.js +0 -63
  48. package/components/FieldLabel/index-CI57EizR.js +0 -54
  49. package/components/GridLayout/index-C4HyxNYX.js +0 -1044
  50. package/components/GridLayout/subcomponents/Griditem/index-C7jT4s8t.js +0 -395
  51. package/components/GridLayout/subcomponents/Responsive/index-BKcU2OnF.js +0 -348
  52. package/components/GridLayout/subcomponents/SizeProvider/index-1aJ-e_54.js +0 -71
  53. package/components/HelperText/index-Crn_XIPF.js +0 -50
  54. package/components/Icon/index-C89MAkeH.js +0 -176
  55. package/components/Image/index-COp8vP0X.js +0 -175
  56. package/components/LanguagePopover/index-BA2Igs9L.js +0 -179
  57. package/components/LinearProgressIndeterminate/index-BwI756Mb.js +0 -55
  58. package/components/Loadable/index-BMbi9ISF.js +0 -9
  59. package/components/LoadingError/index-Cf0oGUrL.js +0 -89
  60. package/components/MFIsolationApp/index-V4R55hNU.js +0 -169
  61. package/components/MFLoader/index-BI8vQZSH.js +0 -299
  62. package/components/ModalDialog/index-CEVQBQ7W.js +0 -77
  63. package/components/NavLink/index-D1S_vtFO.js +0 -55
  64. package/components/NoItemSelected/index-B9oM26AX.js +0 -54
  65. package/components/ObjectLogs/index-CiXOJpS4.js +0 -233
  66. package/components/PDFViewer/index-GVN2rfd6.js +0 -51
  67. package/components/Page/index-DZMkYmr4.js +0 -117
  68. package/components/PaperForm/index-DwgAfjci.js +0 -59
  69. package/components/Period/index-2pJG3VmY.js +0 -238
  70. package/components/PrintingSystem/index-B2qcnfw0.js +0 -187
  71. package/components/PrintingSystem/subcomponents/BodyNode/index-Cv2aoy8S.js +0 -49
  72. package/components/PrintingSystem/subcomponents/ChartNode/index-BmJm8v_C.js +0 -105
  73. package/components/PrintingSystem/subcomponents/DividerNode/index-MpFhE-H0.js +0 -20
  74. package/components/PrintingSystem/subcomponents/FooterNode/index-ZEcWdMSM.js +0 -49
  75. package/components/PrintingSystem/subcomponents/GridNode/index-SsKax2xu.js +0 -74
  76. package/components/PrintingSystem/subcomponents/HeaderNode/index-Cs8TOOBL.js +0 -49
  77. package/components/PrintingSystem/subcomponents/PaperNode/index-DBb25Ecg.js +0 -30
  78. package/components/PrintingSystem/subcomponents/PropertyValueNode/index-CTVn7J9Q.js +0 -47
  79. package/components/PrintingSystem/subcomponents/SectionNode/index-iYPM3EaS.js +0 -49
  80. package/components/PrintingSystem/subcomponents/TextBoxNode/index-DGjXCFKJ.js +0 -24
  81. package/components/PropertyValue/index-Bh-Jnrte.js +0 -264
  82. package/components/Resizeable/index-DdP1xfE9.js +0 -20
  83. package/components/ScrollBar/index-f2URPPE2.js +0 -35
  84. package/components/ScrollToTop/index-TxORk5dB.js +0 -12
  85. package/components/SideBar/index-PUBBe0yH.js +0 -758
  86. package/components/SplitLayout/index-Bu1hcO6G.js +0 -89
  87. package/components/ToastContainer/index-DK1d8NNd.js +0 -191
  88. package/components/WrapperComponent/index-BHV-CsDU.js +0 -14
  89. package/components/animate/LoadingScreen/index-CkVLOrMz.js +0 -70
  90. package/components/animate/MotionContainer/index-eartnWyO.js +0 -34
  91. package/components/animate/MotionLazyContainer/index-Be8osTiG.js +0 -9
  92. package/components/animate/PropagateLoader/index-Bkq8V2SN.js +0 -23
  93. package/components/animate/features-BbnE33u3.js +0 -5
  94. package/components/animate/index-BsWiJfzp.js +0 -89
  95. package/components/animate/variants/bounce-DanQqHAX.js +0 -101
  96. package/components/animate/variants/container-Dmpr6tg5.js +0 -22
  97. package/components/animate/variants/fade-CAOJNn06.js +0 -65
  98. package/components/animate/variants/index-l0sNRNKZ.js +0 -1
  99. package/components/animate/variants/transition-B9W5SWTa.js +0 -20
  100. package/components/areas/components/AreasAdmin/index-OxQU3P8Y.js +0 -699
  101. package/components/areas/components/AreasViewer/index-DQ0aPioP.js +0 -805
  102. package/components/areas/components/index-l0sNRNKZ.js +0 -1
  103. package/components/areas/constants-rqODZNZe.js +0 -6
  104. package/components/areas/contexts/AreasContext/index-BqRlA7JA.js +0 -1110
  105. package/components/areas/contexts/DynamicMFParmsContext/index-22c6E7vK.js +0 -36
  106. package/components/areas/contexts/WindowToolsMFContext/index-DkE30fhm.js +0 -12
  107. package/components/areas/contexts/index-l0sNRNKZ.js +0 -1
  108. package/components/areas/dictionary-YUsP9beq.js +0 -36
  109. package/components/areas/hooks/index-l0sNRNKZ.js +0 -1
  110. package/components/areas/hooks/useAreas/index-BSbwbJLS.js +0 -11
  111. package/components/areas/hooks/useDynamicMFParameters/index-DhbcZPs9.js +0 -12
  112. package/components/areas/hooks/useSetWindowsTitle/useSetWindowsTitle-BzPD-miW.js +0 -31
  113. package/components/areas/hooks/useWindowToolsMF/index-BECQfhbC.js +0 -10
  114. package/components/areas/icons-CwFr-alN.js +0 -24
  115. package/components/areas/index-B_Odny9h.js +0 -22
  116. package/components/commercial/AppBarCommercial/index-CHq3P3GY.js +0 -28
  117. package/components/commercial/SectionCommercial/index-BeABGtdr.js +0 -56
  118. package/components/commercial/TopBar/index-F1repmti.js +0 -232
  119. package/components/commercial/index-CxDzs6Ax.js +0 -81
  120. package/components/formatters/BooleanFormatter/index-DktIidqW.js +0 -44
  121. package/components/formatters/DateFormatter/index-CGcRZ8BA.js +0 -43
  122. package/components/formatters/PointsFormatter/index-C7sR8iqk.js +0 -25
  123. package/components/formatters/PriceFormatter/index-CsvRawmc.js +0 -35
  124. package/components/formatters/UncertaintyFormatter/index-B9ESVEVp.js +0 -29
  125. package/components/formatters/index-pnJhDYKe.js +0 -109
  126. package/components/hook-form/HelperError/index-BVnmUazV.js +0 -19
  127. package/components/hook-form/RHFAutocomplete/index-BtPL16HR.js +0 -657
  128. package/components/hook-form/RHFAutocompleteAsync/index-BfzjLHG8.js +0 -226
  129. package/components/hook-form/RHFCheckbox/index-Vyttu8Vx.js +0 -132
  130. package/components/hook-form/RHFColorPicker/index-Cxxb5Wa_.js +0 -191
  131. package/components/hook-form/RHFDateTime/index-CW1Slb-f.js +0 -190
  132. package/components/hook-form/RHFMultiCheckbox/index-BARudV1A.js +0 -34
  133. package/components/hook-form/RHFPeriod/index-r-HeIOoZ.js +0 -98
  134. package/components/hook-form/RHFRadioGroup/index-CTD-0zKo.js +0 -52
  135. package/components/hook-form/RHFSelect/index-LdwRuFz-.js +0 -29
  136. package/components/hook-form/RHFTextField/index-B6ufruSB.js +0 -337
  137. package/components/hook-form/RHFUpload/index-CDPbm8NR.js +0 -253
  138. package/components/maps/components/GpsTools/index-5MXlhIEt.js +0 -1948
  139. package/components/maps/components/Map/index-2Lx5ARXa.js +0 -2546
  140. package/components/maps/index-Ci-7-FHg.js +0 -7
  141. package/components/modal/WindowBase-Gd27v5FU.js +0 -44
  142. package/components/modal/WindowConfirm-u6vAMFo7.js +0 -73
  143. package/components/modal/index-CydPIpKZ.js +0 -65
  144. package/components/mui_extended/Accordion/index-DMLYJL7o.js +0 -124
  145. package/components/mui_extended/Avatar/index-ClBa-6eF.js +0 -64
  146. package/components/mui_extended/Badge/index-zI-F_Qkq.js +0 -29
  147. package/components/mui_extended/BoxIcon/index-BUTJ2tKw.js +0 -22
  148. package/components/mui_extended/Breadcrumbs/index-DTS7rOZH.js +0 -86
  149. package/components/mui_extended/Button/index-CGfZbaea.js +0 -222
  150. package/components/mui_extended/CheckBox-BXUrbonB.js +0 -76
  151. package/components/mui_extended/CircularProgress/index-Bnnti_G6.js +0 -8
  152. package/components/mui_extended/IconButton/classes/constants-ChY2jKkp.js +0 -4
  153. package/components/mui_extended/IconButton/classes/index-BxjJGAqZ.js +0 -45
  154. package/components/mui_extended/IconButton/index-CusYFjie.js +0 -97
  155. package/components/mui_extended/IconButton/styledIconButton-fAsbGoFS.js +0 -7
  156. package/components/mui_extended/LinearProgress/index-CGgW8jq2.js +0 -9
  157. package/components/mui_extended/LinkWithRoute/index-BC2miUjR.js +0 -15
  158. package/components/mui_extended/MenuActions/MenuActions-C6CjSU6C.js +0 -149
  159. package/components/mui_extended/MenuActions/constants-BwsU9chA.js +0 -10
  160. package/components/mui_extended/MenuActions/dictionary-Dj_07puT.js +0 -11
  161. package/components/mui_extended/MenuActions/slots/MenuActionsEnum-Bu-L6eWU.js +0 -13
  162. package/components/mui_extended/MenuActions/slots/MenuActionsSlots-D65KZAKF.js +0 -46
  163. package/components/mui_extended/Pager/index-DCbxiTZA.js +0 -257
  164. package/components/mui_extended/Popover/index-DfrJAQkV.js +0 -153
  165. package/components/mui_extended/Stack/index-DzEeCYfp.js +0 -31
  166. package/components/mui_extended/Tab/index-Bu3dPidV.js +0 -129
  167. package/components/mui_extended/ToggleButton/index-C9cBkT1V.js +0 -18
  168. package/components/mui_extended/ToggleIconButton/index--0b3Td6C.js +0 -26
  169. package/components/mui_extended/Tooltip/index-B8QUytCK.js +0 -42
  170. package/components/mui_extended/Typography/index-Cf_4Zw8f.js +0 -54
  171. package/components/mui_extended/index-l0sNRNKZ.js +0 -1
  172. package/components/popups/PopupsProvider/index-DhSxmtfJ.js +0 -172
  173. package/components/popups/PopupsViewer/constants-DuyD7aCn.js +0 -4
  174. package/components/popups/PopupsViewer/icons-BUujqqbu.js +0 -7
  175. package/components/popups/PopupsViewer/index-BecevSns.js +0 -172
  176. package/components/popups/PopupsViewer/slots/index-B98CiRLa.js +0 -14
  177. package/components/popups/PopupsViewer/slots/popupsViewerSlots-BXH77nCF.js +0 -46
  178. package/components/popups/index-l0sNRNKZ.js +0 -1
  179. package/contexts/ModalContext/index-CPfNnfTL.js +0 -39
  180. package/contexts/RHFormContext/index-D_nK759o.js +0 -78
  181. package/hocs/withToggle/index-C1_DMZD3.js +0 -14
  182. package/hooks/useFormAddEdit/index-D9oSjUn1.js +0 -90
  183. package/hooks/useFormReadyForUpdate/index-B3HygFCM.js +0 -20
  184. package/hooks/useModal/index-BJSQOX3U.js +0 -10
  185. package/hooks/useSizeContainer/index-D4hDjM1P.js +0 -37
  186. package/hooks/useStateRef/index-C3P6ZK3m.js +0 -15
  187. package/hooks/useTab/index-B_GEQFOP.js +0 -12
  188. package/react-data-grid-BfYuZ6AK.js +0 -2606
  189. package/react-draggable-DsCPdgQP.js +0 -811
  190. package/react-json-view-bhqIAaNg.js +0 -2576
  191. package/react-resizable-eBbFl2dX.js +0 -618
  192. package/react-spinners-TpKN9lZg.js +0 -123
  193. package/react-splitter-layout-C-JTsNGs.js +0 -158
  194. package/styles/DynamicFilter-CJFsIegc.js +0 -319
  195. package/styles/MenuActions-lTi-ynPM.js +0 -42
  196. package/styles/index-DKj6m8SL.js +0 -1691
  197. package/test/constants_no_mock-CF-669v-.js +0 -4
  198. package/test/getNameDataTestId-BaBTWhBr.js +0 -10
  199. package/utils/index-DiMrtgIu.js +0 -502
  200. /package/components/GridLayout/subcomponents/{Griditem → GridItem}/index.d.ts +0 -0
  201. /package/components/GridLayout/subcomponents/{Griditem → GridItem}/types.d.ts +0 -0
@@ -1,1948 +0,0 @@
1
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
- import { useEnvironment, useModuleDictionary, useHostTools, useNetwork, useModulePrivileges, usePaginate, useModuleSkeleton } from "@m4l/core";
3
- import { useState, useMemo, useCallback, useRef, useEffect, createContext, useContext } from "react";
4
- import { shallow } from "zustand/shallow";
5
- import "@geoman-io/leaflet-geoman-free/dist/leaflet-geoman.css";
6
- import "@geoman-io/leaflet-geoman-free";
7
- import clsx from "clsx";
8
- import { au as RHFormProviderStyled, av as StackGeofenceListRoot, aw as DivTabGpsToolsRoot } from "../../../../styles/index-DKj6m8SL.js";
9
- import { D as DynamicFilter } from "../../../DynamicFilter/index-DZiJc9h7.js";
10
- import { C as ColumnIconFormatter } from "../../../DataGrid/formatters/index-CrZXPa0e.js";
11
- import { C as ColumnDateFormatter } from "../../../DataGrid/formatters/ColumnDateFormatter/index-CKg8CJ6A.js";
12
- import { useResponsiveDesktop, useFirstRender } from "@m4l/graphics";
13
- import { useFormContext, useWatch, useFormState } from "react-hook-form";
14
- import { H as HelperError } from "../../../hook-form/HelperError/index-BVnmUazV.js";
15
- import { u as useModal } from "../../../../hooks/useModal/index-BJSQOX3U.js";
16
- import { u as usePopupsStore } from "../../../popups/PopupsProvider/index-DhSxmtfJ.js";
17
- import { createStore, useStore } from "zustand";
18
- import { devtools } from "zustand/middleware";
19
- import { immer } from "zustand/middleware/immer";
20
- import { enableMapSet } from "immer";
21
- import { A as ActionFormIntro } from "../../../CommonActions/components/ActionFormIntro/index-7KKtcUra.js";
22
- import { W as WindowConfirm } from "../../../modal/WindowConfirm-u6vAMFo7.js";
23
- import { A as Actions } from "../../../CommonActions/components/Actions/index-CuG1pnXW.js";
24
- import { B as Button } from "../../../mui_extended/Button/index-CGfZbaea.js";
25
- import { useMap } from "react-leaflet";
26
- import * as L from "leaflet";
27
- import { u as useFormReadyForUpdate } from "../../../../hooks/useFormReadyForUpdate/index-B3HygFCM.js";
28
- import { u as useTab } from "../../../../hooks/useTab/index-B_GEQFOP.js";
29
- import { generateUtilityClasses } from "@mui/material";
30
- import "@mui/base";
31
- import { P as PaperForm } from "../../../PaperForm/index-DwgAfjci.js";
32
- import { R as RHFAutocomplete } from "../../../hook-form/RHFAutocomplete/index-BtPL16HR.js";
33
- import { R as RHFTextField } from "../../../hook-form/RHFTextField/index-B6ufruSB.js";
34
- import { S as Stack } from "../../../mui_extended/Stack/index-DzEeCYfp.js";
35
- import { I as IconButton } from "../../../mui_extended/IconButton/index-CusYFjie.js";
36
- import { P as PropertyValue } from "../../../PropertyValue/index-Bh-Jnrte.js";
37
- import { R as RHFColorPicker } from "../../../hook-form/RHFColorPicker/index-Cxxb5Wa_.js";
38
- import { T as Tabs, a as Tab, b as TabContent, c as TabProvider } from "../../../mui_extended/Tab/index-Bu3dPidV.js";
39
- import { I as Icon } from "../../../Icon/index-C89MAkeH.js";
40
- import * as Yup from "yup";
41
- import { u as useFormAddEdit } from "../../../../hooks/useFormAddEdit/index-D9oSjUn1.js";
42
- import { u as useMapStore, C as CommonFeatureRender, G as GPS_TOOLS_POPUP_ID } from "../Map/index-2Lx5ARXa.js";
43
- import { D as DataGrid } from "../../../DataGrid/index-BZ-lbmuU.js";
44
- const COMPONENT_CLASS_NAME = "M4LMapGpsTools";
45
- const COMPONENT_MAP_TOOLS_ID = "gps_tools";
46
- const STYLE_OPACITIES = [
47
- {
48
- value: 0,
49
- label: "0%"
50
- },
51
- {
52
- value: 0.1,
53
- label: "10%"
54
- },
55
- {
56
- value: 0.2,
57
- label: "20%"
58
- },
59
- {
60
- value: 0.3,
61
- label: "30%"
62
- },
63
- {
64
- value: 0.4,
65
- label: "40%"
66
- },
67
- {
68
- value: 0.5,
69
- label: "50%"
70
- },
71
- {
72
- value: 1,
73
- label: "100%"
74
- }
75
- ];
76
- const STYLE_WHEIGHTS = [
77
- {
78
- value: 0,
79
- label: "0px"
80
- },
81
- {
82
- value: 1,
83
- label: "1px"
84
- },
85
- {
86
- value: 2,
87
- label: "2px"
88
- },
89
- {
90
- value: 3,
91
- label: "3px"
92
- },
93
- {
94
- value: 4,
95
- label: "4px"
96
- }
97
- ];
98
- const STYLE_PATTERNS = [
99
- {
100
- value: "",
101
- label: "------"
102
- },
103
- {
104
- value: "4 1 2",
105
- label: "-- - - --"
106
- }
107
- ];
108
- const gpsToolsClasses = generateUtilityClasses(COMPONENT_CLASS_NAME, [
109
- /* elements */
110
- "gpsToolsRoot",
111
- "gpsToolsTab",
112
- "gpsToolsTabContent",
113
- "gpsToolsGeofencesList",
114
- "gpsToolsGeofencesAddEdit",
115
- "gpsToolsGeofencesAddEditContent",
116
- "gpsToolsGeofencesAddEditDrawFinishContainer",
117
- "toolGeofencesAddEditGeneral",
118
- "toolGeofencesAddEditStyle",
119
- /* states or variants of elements */
120
- "visible",
121
- "hidden"
122
- ]);
123
- const MAP_GPSTOOLS_DICCTIONARY = {
124
- /**
125
- * GPSTools
126
- */
127
- LABEL_GPSTOOLS_NAME: "label_gpstools_name",
128
- /** Common */
129
- /** GeofenceList */
130
- ACTION_GEOFENCE_ADD: "action_geofence_add",
131
- ACTION_GEOFENCE_EDIT: "action_geofence_edit",
132
- // Row Actions
133
- ROW_ACTION_GEO_EDIT: "row_action_geo_edit",
134
- ROW_ACTION_GEO_ENABLE: "row_action_geo_enable",
135
- ROW_ACTION_GEO_DISABLE: "row_action_geo_disable",
136
- ROW_ACTION_GEO_DELETE: "row_action_geo_delete",
137
- /** GeofenceAddEdit */
138
- LABEL_TAB_GEO: "label_tab_geo",
139
- TAB_GENERAL_CONFIG_TOOLTIP: "tab_general_config_tooltip",
140
- PAPER_GENERAL: "paper_general",
141
- LABEL_ID: "label_id",
142
- LABEL_NAME: "label_name",
143
- LABEL_GEOMETRY_TYPE: "label_geometry_type",
144
- LABEL_GEOMETRY_CIRCLE: "label_geometry_circle",
145
- LABEL_GEOMETRY_RECTANGLE: "label_geometry_rectangle",
146
- LABEL_GEOMETRY_POLYGON: "label_geometry_polygon",
147
- LABEL_DRAW: "label_draw",
148
- LABEL_FINISH: "label_finish",
149
- PAPER_CONFIG: "paper_config",
150
- LABEL_ALIAS: "label_alias",
151
- LABEL_CUSTOMER_ID: "label_customer_id",
152
- LABEL_TIME_MIN_IN_SECONDS: "label_time_min_in_seconds",
153
- LABEL_TIME_MIN_OUT_SECONDS: "label_time_min_out_seconds",
154
- TAB_STYLE_CONFIG_TOOLTIP: "tab_style_tooltip",
155
- PAPER_STROKE: "paper_stroke",
156
- LABEL_COLOR: "label_color",
157
- LABEL_OPACITY: "label_opacity",
158
- LABEL_WEIGHT: "label_weight",
159
- LABEL_DASH_ARRAY: "label_dash_array",
160
- LABEL_DASH_OFFSET: "label_dash_offset",
161
- PAPER_FILL: "paper_fill",
162
- LABEL_RADIUS: "label_radius",
163
- LABEL_LAT: "label_lat",
164
- LABEL_LON: "label_lon",
165
- LABEL_PLACE_MARKER: "label_place_marker",
166
- LABEL_FIRST_VERTEX: "label_first_vertex",
167
- LABEL_CONTINUE_LINE: "label_continue_line",
168
- LABEL_FINISH_LINE: "label_finish_line",
169
- LABEL_FINISH_POLY: "label_finish_poly",
170
- LABEL_FINISH_RECT: "label_finish_rect",
171
- LABEL_START_CIRCLE: "label_start_circle",
172
- LABEL_FINISH_CIRCLE: "label_finish_circle",
173
- LABEL_PLACE_CIRCLE_MARKER: "label_place_circle_marker",
174
- VALIDATION_GEOMETRY_REQUIRED: "validation_geometry_required",
175
- VALIDATION_FIELD_REQUIRED: "validation_field_required",
176
- VALIDATION_FIELD_TYPE_NUMBER_ERROR: "validation_field_type_number_error",
177
- VALIDATION_FIELD_MIN_NUMBER_ERROR: "validation_field_min_number_error",
178
- LABEL_VIEW_TRANSIT_FEATURES: "label_view_crossing_features",
179
- LABEL_VIEW_INTERNAL_FEATURES: "label_view_internal_features",
180
- LABEL_CREATED_AT: "label_created_at",
181
- LABEL_UPDATED_AT: "label_updated_at",
182
- MODAL_DELETE_GEO_TITLE: "modal_delete_geo_title",
183
- MODAL_DELETE_GEO_MESSAGE: "modal_delete_geo_message",
184
- MODAL_DISABLE_GEO_TITLE: "modal_disable_geo_title",
185
- MODAL_DISABLE_MESSAGE: "modal_disable_geo_message",
186
- ACTION_CANCEL: "action_cancel"
187
- };
188
- const MAP_GPSTOOLS_ICONS = {
189
- /**
190
- * GpsTools
191
- */
192
- MAP_GPS_TOOLS_TOOL: "cmp_map_gpstools_tool.svg",
193
- GEOFENCES: "cmp_map_gpstools_geofences.svg",
194
- GEOFENCE_ID: "cmp_map_gpstools_geofence_id.svg",
195
- GEOFENCE_NAME: "cmp_map_gpstools_geofence_name.svg",
196
- GEOFENCE_ADD: "cmp_map_gpstools_add-geofence.svg",
197
- GEOFENCE_EDIT: "cmp_map_gpstools_edit-geofence.svg",
198
- GEOFENCE_DELETE: "cmp_map_gpstools_delete-geofence.svg",
199
- GENERAL: "cmp_map_gpstools_general.svg",
200
- DATA: "cmp_map_gpstools_data.svg",
201
- STYLE: "cmp_map_gpstools_style.svg",
202
- GEOFENCE_DRAW: "cmp_map_gpstools_draw.svg",
203
- GEOFENCE_FINISH: "cmp_map_gpstools_finish.svg",
204
- GEOFENCE_TYPE_CIRCLE: "cmp_map_gpstools_circle.svg",
205
- GEOFENCE_TYPE_RECTANGLE: "cmp_map_gpstools_rectangle.svg",
206
- GEOFENCE_TYPE_POLYGON: "cmp_map_gpstools_polygon.svg",
207
- CONFIG: "cmp_map_gpstools_config.svg",
208
- STROKE: "cmp_map_gpstools_stroke.svg",
209
- FILL: "cmp_map_gpstools_fill.svg"
210
- };
211
- function Filter(props) {
212
- const { refresh, setBackendQueryParams } = props;
213
- const { host_static_assets, environment_assets } = useEnvironment();
214
- const [initialFilter] = useState(() => {
215
- return [];
216
- });
217
- const onChangeFilter = (_initialFilters, rawFilters) => {
218
- setBackendQueryParams({
219
- f: rawFilters
220
- });
221
- refresh();
222
- };
223
- return /* @__PURE__ */ jsx(
224
- DynamicFilter,
225
- {
226
- withAllField: true,
227
- onChangeFilters: onChangeFilter,
228
- fields: [
229
- {
230
- name: "id",
231
- dictionaryId: MAP_GPSTOOLS_DICCTIONARY.LABEL_ID,
232
- type: "number",
233
- multiple: true,
234
- presence: "optional",
235
- urlIcon: `${host_static_assets}/${environment_assets}/components/${COMPONENT_MAP_TOOLS_ID}/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCE_ID}`
236
- },
237
- {
238
- name: "name",
239
- dictionaryId: MAP_GPSTOOLS_DICCTIONARY.LABEL_NAME,
240
- type: "string",
241
- multiple: true,
242
- presence: "optional",
243
- urlIcon: `${host_static_assets}/${environment_assets}/components/${COMPONENT_MAP_TOOLS_ID}/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCE_NAME}`
244
- }
245
- ],
246
- initialAppliedFilters: initialFilter
247
- }
248
- );
249
- }
250
- function useColumns(_props) {
251
- const { getLabel } = useModuleDictionary();
252
- const { host_static_assets, environment_assets } = useEnvironment();
253
- const columns = useMemo(
254
- () => [
255
- {
256
- key: "id",
257
- name: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_ID),
258
- type: "number",
259
- width: 40,
260
- visible: false
261
- },
262
- {
263
- key: "geometry",
264
- name: "",
265
- type: "string",
266
- formatter: ColumnIconFormatter({
267
- getIconUrl: (formatterRowProps) => {
268
- const { row } = formatterRowProps;
269
- let iconUrl;
270
- if (row.type.id === "gt_polygon") {
271
- iconUrl = MAP_GPSTOOLS_ICONS.GEOFENCE_TYPE_POLYGON;
272
- } else if (row.type.id === "gt_circle") {
273
- iconUrl = MAP_GPSTOOLS_ICONS.GEOFENCE_TYPE_CIRCLE;
274
- } else {
275
- iconUrl = MAP_GPSTOOLS_ICONS.GEOFENCE_TYPE_RECTANGLE;
276
- }
277
- return {
278
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${iconUrl}`
279
- };
280
- }
281
- }),
282
- width: 30,
283
- minWidth: 25
284
- },
285
- {
286
- key: "name",
287
- name: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_NAME),
288
- type: "string",
289
- width: 220
290
- },
291
- // {
292
- // key: 'checkedCrossingFeatures',
293
- // name: getLabel(DICCTIONARY.LABEL_VIEW_TRANSIT_FEATURES),
294
- // width: 32,
295
- // type: 'boolean',
296
- // // frozen: true,
297
- // // isDraggable: false,
298
- // formatter: ColumnSetCheckFormatter({
299
- // field: 'CrossingFeatures',
300
- // rowKeyGetter,
301
- // useHook,
302
- // }),
303
- // cellClass: 'rdg-cell-align-center',
304
- // },
305
- // {
306
- // key: 'checkedInternalFeatures',
307
- // name: getLabel(DICCTIONARY.LABEL_VIEW_INTERNAL_FEATURES),
308
- // width: 32,
309
- // type: 'boolean',
310
- // // isDraggable: false,
311
- // // frozen: true,
312
- // formatter: ColumnSetCheckFormatter({
313
- // field: 'InternalFeatures',
314
- // rowKeyGetter,
315
- // useHook,
316
- // }),
317
- // cellClass: 'rdg-cell-align-center',
318
- // },
319
- {
320
- key: "created_at",
321
- name: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_CREATED_AT),
322
- type: "date",
323
- formatter: ColumnDateFormatter({
324
- presentationType: "datetime",
325
- fieldValue: "row.created_at"
326
- }),
327
- visible: false
328
- },
329
- {
330
- key: "updated_at",
331
- name: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_UPDATED_AT),
332
- type: "date",
333
- formatter: ColumnDateFormatter({
334
- presentationType: "datetime",
335
- fieldValue: "row.updated_at"
336
- }),
337
- visible: false
338
- }
339
- ],
340
- [getLabel]
341
- );
342
- return { columns };
343
- }
344
- function MyActions(props) {
345
- const { geofenceId } = props;
346
- const { control } = useFormContext();
347
- const { getLabel } = useModuleDictionary();
348
- const { openModal } = useModal();
349
- const inEdition = useWatch({
350
- control,
351
- name: "inEdition"
352
- });
353
- const { isDirty } = useFormState({
354
- control
355
- });
356
- const { closePopup, showPopup } = usePopupsStore((state) => state.popupsActions);
357
- const { addCheckedGeofence } = useGpsToolsStore((state) => state.geofenceActions);
358
- const onClickCancelLocal = useCallback(() => {
359
- if (isDirty) {
360
- openModal({
361
- window: /* @__PURE__ */ jsx(
362
- WindowConfirm,
363
- {
364
- variant: "warning",
365
- title: getLabel("common_actions.confirm_quit_title"),
366
- msg: getLabel("common_actions.confirm_quit_msg"),
367
- onClickIntro: onConfirmQuit
368
- }
369
- ),
370
- variant: "warning"
371
- });
372
- } else {
373
- onConfirmQuit();
374
- }
375
- }, [getLabel, isDirty, openModal]);
376
- const onConfirmQuit = () => {
377
- closePopup("geofencesAddEdit");
378
- if (geofenceId !== void 0) {
379
- addCheckedGeofence(geofenceId);
380
- }
381
- showPopup("gpsTools");
382
- };
383
- return /* @__PURE__ */ jsxs(Actions, { children: [
384
- /* @__PURE__ */ jsx(HelperError, { name: "geometry" }),
385
- /* @__PURE__ */ jsx(Button, { onClick: onClickCancelLocal, disabled: inEdition, children: getLabel(MAP_GPSTOOLS_DICCTIONARY.ACTION_CANCEL) }),
386
- /* @__PURE__ */ jsx(ActionFormIntro, { disabled: inEdition })
387
- ] });
388
- }
389
- const STROKE_COLOR_DEFAULT = "#aaccaa";
390
- const STROKE_OPACITY_DEFAULT = { value: 1, label: "100%" };
391
- const STROKE_WHEIGTH_DEFAULT = { value: 1, label: "1 px" };
392
- const STROKE_DASH_ARRAY_DEFAULT = { value: "", label: "-----" };
393
- const FILL_COLOR_DEFAULT = "#aa3000";
394
- const FILL_OPACITY_DEFAULT = { value: 0.2, label: "20%" };
395
- const initialValues = {
396
- /** General Data */
397
- name: "",
398
- geofenceType: null,
399
- /** Config Data */
400
- alias: null,
401
- customerId: null,
402
- timeMinInSeconds: 5,
403
- timeMinOutSeconds: 5,
404
- /** de Apoyo */
405
- inEdition: false,
406
- geometry: null,
407
- lat: null,
408
- lng: null,
409
- properties: {
410
- radius: null,
411
- /** Style Data */
412
- strokeColor: STROKE_COLOR_DEFAULT,
413
- strokeOpacity: STROKE_OPACITY_DEFAULT,
414
- strokeWeight: STROKE_WHEIGTH_DEFAULT,
415
- strokeDashArray: STROKE_DASH_ARRAY_DEFAULT,
416
- fillColor: FILL_COLOR_DEFAULT,
417
- fillOpacity: FILL_OPACITY_DEFAULT
418
- }
419
- };
420
- const formatDataEnpoint = (response) => {
421
- try {
422
- const { data } = response;
423
- const obRet = {
424
- ...initialValues,
425
- inEdition: false,
426
- name: data.name,
427
- geometry: data.geometry,
428
- geofenceType: { id: data.type.id, name: data.type.name, url: "" },
429
- properties: {
430
- strokeColor: data.properties.strokeColor || STROKE_COLOR_DEFAULT,
431
- strokeOpacity: STROKE_OPACITY_DEFAULT,
432
- //getFormStrokeOpacityFromData(data.properties.strokeOpacity),
433
- strokeWeight: STROKE_WHEIGTH_DEFAULT,
434
- //,getFormStrokeWeightFromData(data.properties.strokeWeight) ,
435
- strokeDashArray: STROKE_DASH_ARRAY_DEFAULT,
436
- // getFormstrokeDashArrayFromData(data.properties.strokeDashArray) ,
437
- fillColor: data.properties.fillColor || FILL_COLOR_DEFAULT,
438
- fillOpacity: FILL_OPACITY_DEFAULT
439
- //data.properties.fillOpacity || FILL_OPACITY_DEFAULT,
440
- }
441
- };
442
- if (obRet.geofenceType?.id === "gt_circle") {
443
- if (data.properties.radius) {
444
- obRet.properties.radius = data.properties.radius;
445
- }
446
- if (data.geometry && data.geometry.type === "Point") {
447
- obRet.lng = data.geometry.coordinates[0];
448
- obRet.lat = data.geometry.coordinates[1];
449
- }
450
- }
451
- return obRet;
452
- } catch (error) {
453
- return { ...initialValues };
454
- }
455
- };
456
- const getLayerFromGeometry = (geometry, geofenceTypeId, radius, options) => {
457
- if (geometry) {
458
- if (geofenceTypeId === "gt_circle" && geometry.type === "Point") {
459
- return L.circle([geometry.coordinates[1], geometry.coordinates[0]], {
460
- ...options,
461
- radius: radius || 0
462
- });
463
- } else if (geofenceTypeId === "gt_polygon" && geometry.type === "Polygon") {
464
- const coordinates = geometry.coordinates.map(
465
- (ring) => ring.map((position) => [position[1], position[0]])
466
- );
467
- return L.polygon(coordinates, options);
468
- } else if (geofenceTypeId === "gt_rectangle" && geometry.type === "Polygon") {
469
- const latLngs = geometry.coordinates[0].map(
470
- (coord) => [coord[1], coord[0]]
471
- );
472
- const lats = latLngs.map((coord) => {
473
- if (Array.isArray(coord)) {
474
- return coord[0];
475
- }
476
- return 0;
477
- });
478
- const lngs = latLngs.map((coord) => {
479
- if (Array.isArray(coord)) {
480
- return coord[1];
481
- }
482
- return 0;
483
- });
484
- const southWest = [Math.min(...lats), Math.min(...lngs)];
485
- const northEast = [Math.max(...lats), Math.max(...lngs)];
486
- return L.rectangle([southWest, northEast], options);
487
- }
488
- }
489
- return null;
490
- };
491
- function useDrawing() {
492
- const { getLabel } = useModuleDictionary();
493
- const readyToUpdate = useFormReadyForUpdate();
494
- const map = useMap();
495
- const { control, setValue } = useFormContext();
496
- const fieldsWatch = useWatch({
497
- control,
498
- name: [
499
- "geofenceType",
500
- "inEdition",
501
- "properties.strokeColor",
502
- "properties.strokeOpacity",
503
- "properties.strokeWeight",
504
- "properties.strokeDashArray",
505
- "properties.fillColor",
506
- "properties.fillOpacity",
507
- "geometry",
508
- "properties.radius"
509
- ]
510
- });
511
- const geofenceTypeId = fieldsWatch[0]?.id;
512
- const inEdition = fieldsWatch[1];
513
- const strokeColor = fieldsWatch[2];
514
- const strokeOpacity = fieldsWatch[3].value;
515
- const strokeWeight = fieldsWatch[4].value;
516
- const strokeDashArray = fieldsWatch[5].value;
517
- const fillColor = fieldsWatch[6];
518
- const fillOpacity = fieldsWatch[7].value;
519
- const geometry = fieldsWatch[8];
520
- const radius = fieldsWatch[9];
521
- const [drawing, setDrawing] = useState(false);
522
- const currentLayer = useRef(null);
523
- const [geometrTypeIdCached, setgeofenceTypeIdCached] = useState(geofenceTypeId);
524
- useEffect(() => {
525
- if (geometry) {
526
- currentLayer.current = getLayerFromGeometry(geometry, geofenceTypeId, radius, {
527
- color: strokeColor,
528
- opacity: strokeOpacity,
529
- weight: strokeWeight,
530
- dashArray: strokeDashArray,
531
- fillColor,
532
- fillOpacity
533
- });
534
- if (currentLayer.current) {
535
- map.addLayer(currentLayer.current);
536
- map.fitBounds(currentLayer.current.getBounds());
537
- }
538
- }
539
- return () => {
540
- if (currentLayer.current) {
541
- currentLayer.current.remove();
542
- }
543
- };
544
- }, [map]);
545
- useEffect(() => {
546
- if (currentLayer.current) {
547
- currentLayer.current.setStyle({
548
- color: strokeColor,
549
- opacity: strokeOpacity,
550
- weight: strokeWeight,
551
- dashArray: strokeDashArray,
552
- fillColor,
553
- fillOpacity
554
- });
555
- }
556
- }, [strokeColor, strokeOpacity, strokeWeight, strokeDashArray, fillColor, fillOpacity]);
557
- useEffect(() => {
558
- map.pm.setLang("en", {
559
- tooltips: {
560
- placeMarker: void 0,
561
- firstVertex: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_FIRST_VERTEX),
562
- continueLine: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_CONTINUE_LINE),
563
- finishLine: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_FINISH_LINE),
564
- finishPoly: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_FINISH_POLY),
565
- finishRect: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_FINISH_RECT),
566
- startCircle: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_START_CIRCLE),
567
- finishCircle: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_FINISH_CIRCLE),
568
- placeCircleMarker: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_PLACE_CIRCLE_MARKER)
569
- }
570
- });
571
- }, [map, getLabel]);
572
- useEffect(() => {
573
- if (map) {
574
- let shape = "Circle";
575
- if (geometrTypeIdCached === "gt_polygon") {
576
- shape = "Polygon";
577
- } else if (geometrTypeIdCached === "gt_rectangle") {
578
- shape = "Rectangle";
579
- }
580
- if (drawing) {
581
- if (!currentLayer.current) {
582
- setValue("inEdition", true);
583
- if (shape === "Circle") {
584
- map.on("pm:drawstart", ({ workingLayer }) => {
585
- workingLayer.on("pm:centerplaced", (e) => {
586
- const layer = e.workingLayer;
587
- layer.setStyle({
588
- color: strokeColor,
589
- opacity: strokeOpacity,
590
- weight: strokeWeight,
591
- dashArray: strokeDashArray,
592
- fillColor,
593
- fillOpacity
594
- });
595
- setValue("lat", Number(layer.getLatLng().lat.toFixed(8)));
596
- setValue("lng", Number(layer.getLatLng().lng.toFixed(8)));
597
- layer.on("pm:change", (_e) => {
598
- setValue("properties.radius", Number(layer.getRadius().toFixed(1)));
599
- });
600
- });
601
- });
602
- setValue("properties.subType", shape);
603
- } else if (shape === "Polygon") {
604
- map.on("pm:drawstart", ({ workingLayer }) => {
605
- workingLayer.on("pm:vertexadded", (e) => {
606
- const layer = e.workingLayer;
607
- layer.setStyle({
608
- color: strokeColor,
609
- opacity: strokeOpacity,
610
- weight: strokeWeight,
611
- dashArray: strokeDashArray,
612
- fillColor,
613
- fillOpacity
614
- });
615
- });
616
- });
617
- }
618
- map.pm.enableDraw(shape);
619
- map.pm.setPathOptions({
620
- color: strokeColor,
621
- opacity: strokeOpacity,
622
- weight: strokeWeight,
623
- dashArray: strokeDashArray,
624
- fillColor,
625
- fillOpacity
626
- });
627
- map.on("pm:create", (e) => {
628
- currentLayer.current = e.layer;
629
- setValue("geometry", currentLayer.current.toGeoJSON()?.geometry, {
630
- shouldTouch: false,
631
- shouldValidate: true
632
- });
633
- setValue("inEdition", false);
634
- setDrawing(false);
635
- });
636
- } else {
637
- currentLayer.current.pm.enable();
638
- setValue("inEdition", true);
639
- currentLayer.current.on("pm:disable", (e) => {
640
- currentLayer.current = e.layer;
641
- setValue("geometry", currentLayer.current.toGeoJSON()?.geometry, {
642
- shouldTouch: false,
643
- shouldValidate: true
644
- });
645
- setValue("inEdition", false);
646
- setDrawing(false);
647
- });
648
- if (shape === "Circle") {
649
- currentLayer.current.on("pm:change", (e) => {
650
- currentLayer.current = e.layer;
651
- setValue("lat", Number(currentLayer.current.getLatLng().lat.toFixed(8)));
652
- setValue("lng", Number(currentLayer.current.getLatLng().lng.toFixed(8)));
653
- setValue("properties.radius", currentLayer.current.getRadius());
654
- setValue("properties.radius", Number(currentLayer.current.getRadius().toFixed(1)));
655
- });
656
- }
657
- }
658
- } else {
659
- map.pm.disableDraw("Polygon");
660
- map.off("pm:create");
661
- map.off("pm:edit");
662
- map.off("pm:drawstart");
663
- }
664
- }
665
- }, [map, drawing]);
666
- const handleDraw = useCallback(() => {
667
- setDrawing(true);
668
- }, []);
669
- const handleFinish = useCallback(() => {
670
- if (currentLayer.current) {
671
- currentLayer.current.pm.disable();
672
- currentLayer.current.setStyle({ color: "#ff0000", fillColor: "#ff0000" });
673
- }
674
- }, []);
675
- useEffect(() => {
676
- if (!readyToUpdate) return;
677
- if (geofenceTypeId) {
678
- if (geofenceTypeId !== geometrTypeIdCached) {
679
- setgeofenceTypeIdCached(geofenceTypeId);
680
- if (geometrTypeIdCached !== "gt_circle") {
681
- setValue("properties.radius", null);
682
- setValue("lat", null);
683
- setValue("lng", null);
684
- }
685
- setValue("geometry", null);
686
- if (currentLayer.current) {
687
- currentLayer.current.remove();
688
- currentLayer.current = null;
689
- }
690
- }
691
- }
692
- }, [geofenceTypeId]);
693
- return { inEdition, handleDraw, handleFinish, geometrTypeIdCached };
694
- }
695
- function useSumbitErrorsFocus() {
696
- const {
697
- setFocus,
698
- formState: { isSubmitted, errors }
699
- } = useFormContext();
700
- const { handleChange } = useTab();
701
- useEffect(() => {
702
- if (isSubmitted) {
703
- const firstError = Object.keys(errors).reduce((field, a) => {
704
- const fieldKey = field;
705
- return errors[fieldKey] ? fieldKey : a;
706
- }, null);
707
- if (firstError) {
708
- const found = [
709
- "name",
710
- "geometry",
711
- "geofenceType",
712
- "timeMinInSeconds",
713
- "timeMinOutSeconds"
714
- ].some((field) => field.includes(firstError));
715
- if (found) {
716
- handleChange(null, "general");
717
- }
718
- if (firstError) {
719
- setFocus(firstError);
720
- }
721
- }
722
- }
723
- }, [isSubmitted, errors]);
724
- }
725
- function GeneralData() {
726
- const { getLabel } = useModuleDictionary();
727
- const { host_static_assets, environment_assets } = useEnvironment();
728
- const { inEdition, handleDraw, handleFinish, geometrTypeIdCached } = useDrawing();
729
- useSumbitErrorsFocus();
730
- const urlIcon = `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.GENERAL}`;
731
- const geofencesTypes = useMemo(() => {
732
- return [
733
- {
734
- id: "gt_circle",
735
- name: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_GEOMETRY_CIRCLE),
736
- url: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCE_TYPE_CIRCLE}`
737
- },
738
- {
739
- id: "gt_polygon",
740
- name: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_GEOMETRY_POLYGON),
741
- url: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCE_TYPE_POLYGON}`
742
- },
743
- {
744
- id: "gt_rectangle",
745
- name: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_GEOMETRY_RECTANGLE),
746
- url: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCE_TYPE_RECTANGLE}`
747
- }
748
- ];
749
- }, [getLabel]);
750
- return /* @__PURE__ */ jsxs(PaperForm, { urlIcon, title: getLabel(MAP_GPSTOOLS_DICCTIONARY.PAPER_GENERAL), children: [
751
- /* @__PURE__ */ jsx(
752
- RHFTextField,
753
- {
754
- name: "name",
755
- disabled: false,
756
- type: "text",
757
- label: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_NAME}`)
758
- }
759
- ),
760
- /* @__PURE__ */ jsxs(Stack, { direction: "column", spacing: 1, alignItems: "center", children: [
761
- /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
762
- /* @__PURE__ */ jsx(
763
- RHFAutocomplete,
764
- {
765
- type: "image",
766
- name: "geofenceType",
767
- autoComplete: "off",
768
- options: geofencesTypes,
769
- getOptionLabel: (option) => option.name,
770
- isOptionEqualToValue: (option, value) => option.id === value.id,
771
- getOptionUrlImage: (option) => option.url,
772
- label: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_GEOMETRY_TYPE)
773
- }
774
- ),
775
- /* @__PURE__ */ jsxs(
776
- Stack,
777
- {
778
- className: gpsToolsClasses.gpsToolsGeofencesAddEditDrawFinishContainer,
779
- direction: "row",
780
- gap: 1,
781
- alignItems: "center",
782
- children: [
783
- /* @__PURE__ */ jsx(
784
- IconButton,
785
- {
786
- src: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCE_DRAW}`,
787
- variant: "primary",
788
- onClick: handleDraw,
789
- disabled: inEdition || !geometrTypeIdCached,
790
- tooltip: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_DRAW)
791
- }
792
- ),
793
- /* @__PURE__ */ jsx(
794
- IconButton,
795
- {
796
- src: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCE_FINISH}`,
797
- variant: "primary",
798
- onClick: handleFinish,
799
- disabled: !inEdition,
800
- tooltip: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_FINISH)
801
- }
802
- )
803
- ]
804
- }
805
- )
806
- ] }),
807
- geometrTypeIdCached && geometrTypeIdCached === "gt_circle" && // <HelperText variant='info' message={'undefined'} />
808
- /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
809
- /* @__PURE__ */ jsx(
810
- RHFTextField,
811
- {
812
- name: "properties.radius",
813
- label: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_RADIUS),
814
- autoComplete: "off",
815
- skeletonWidth: "70%",
816
- skeletonHeight: "18px",
817
- disabled: true,
818
- size: "small"
819
- }
820
- ),
821
- /* @__PURE__ */ jsx(
822
- RHFTextField,
823
- {
824
- name: "lat",
825
- label: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_LAT),
826
- autoComplete: "off",
827
- skeletonWidth: "70%",
828
- skeletonHeight: "18px",
829
- disabled: true,
830
- size: "small"
831
- }
832
- ),
833
- /* @__PURE__ */ jsx(
834
- RHFTextField,
835
- {
836
- name: "lng",
837
- label: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_LON),
838
- autoComplete: "off",
839
- skeletonWidth: "70%",
840
- skeletonHeight: "18px",
841
- disabled: true,
842
- size: "small"
843
- }
844
- )
845
- ] })
846
- ] })
847
- ] });
848
- }
849
- function ConfigData() {
850
- const { getLabel } = useModuleDictionary();
851
- const { host_static_assets, environment_assets } = useEnvironment();
852
- const urlIcon = `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.CONFIG}`;
853
- return /* @__PURE__ */ jsxs(PaperForm, { urlIcon, title: getLabel(MAP_GPSTOOLS_DICCTIONARY.PAPER_CONFIG), children: [
854
- /* @__PURE__ */ jsx(
855
- RHFTextField,
856
- {
857
- name: "alias",
858
- disabled: false,
859
- type: "text",
860
- label: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_ALIAS}`)
861
- }
862
- ),
863
- /* @__PURE__ */ jsx(
864
- RHFTextField,
865
- {
866
- name: "customerId",
867
- disabled: false,
868
- type: "text",
869
- label: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_CUSTOMER_ID}`)
870
- }
871
- ),
872
- /* @__PURE__ */ jsx(
873
- RHFTextField,
874
- {
875
- name: "timeMinInSeconds",
876
- disabled: false,
877
- type: "number",
878
- label: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_TIME_MIN_IN_SECONDS}`)
879
- }
880
- ),
881
- /* @__PURE__ */ jsx(
882
- RHFTextField,
883
- {
884
- name: "timeMinOutSeconds",
885
- disabled: false,
886
- type: "number",
887
- label: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_TIME_MIN_OUT_SECONDS}`)
888
- }
889
- )
890
- ] });
891
- }
892
- function FillData() {
893
- const { getLabel } = useModuleDictionary();
894
- const { host_static_assets, environment_assets } = useEnvironment();
895
- const urlIcon = `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.FILL}`;
896
- return /* @__PURE__ */ jsxs(PaperForm, { urlIcon, title: getLabel(MAP_GPSTOOLS_DICCTIONARY.PAPER_FILL), children: [
897
- /* @__PURE__ */ jsx(
898
- PropertyValue,
899
- {
900
- property: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_COLOR}`),
901
- isForm: true,
902
- propertyWidth: 150,
903
- value: /* @__PURE__ */ jsx(RHFColorPicker, { name: "properties.fillColor" })
904
- },
905
- "properties.fillColor"
906
- ),
907
- /* @__PURE__ */ jsx(
908
- PropertyValue,
909
- {
910
- property: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_OPACITY}`),
911
- isForm: true,
912
- propertyWidth: 150,
913
- value: /* @__PURE__ */ jsx(
914
- RHFAutocomplete,
915
- {
916
- type: "text",
917
- name: "properties.fillOpacity",
918
- autoComplete: "off",
919
- options: STYLE_OPACITIES,
920
- getOptionLabel: (option) => option.label,
921
- isOptionEqualToValue: (option, value) => option.value === value.value
922
- }
923
- )
924
- },
925
- "properties.fillOpacity"
926
- )
927
- ] });
928
- }
929
- function StrokeData() {
930
- const { getLabel } = useModuleDictionary();
931
- const { host_static_assets, environment_assets } = useEnvironment();
932
- const urlIcon = `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.STROKE}`;
933
- return /* @__PURE__ */ jsxs(PaperForm, { urlIcon, title: getLabel(MAP_GPSTOOLS_DICCTIONARY.PAPER_STROKE), children: [
934
- /* @__PURE__ */ jsx(
935
- PropertyValue,
936
- {
937
- property: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_COLOR}`),
938
- isForm: true,
939
- propertyWidth: 150,
940
- value: /* @__PURE__ */ jsx(RHFColorPicker, { name: "properties.strokeColor" })
941
- },
942
- "properties.strokeColor"
943
- ),
944
- /* @__PURE__ */ jsx(
945
- PropertyValue,
946
- {
947
- property: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_OPACITY}`),
948
- isForm: true,
949
- propertyWidth: 150,
950
- value: /* @__PURE__ */ jsx(
951
- RHFAutocomplete,
952
- {
953
- type: "text",
954
- name: "properties.strokeOpacity",
955
- autoComplete: "off",
956
- options: STYLE_OPACITIES,
957
- getOptionLabel: (option) => option.label,
958
- isOptionEqualToValue: (option, value) => option.value === value.value
959
- }
960
- )
961
- },
962
- "properties.strokeOpacity"
963
- ),
964
- /* @__PURE__ */ jsx(
965
- PropertyValue,
966
- {
967
- property: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_WEIGHT}`),
968
- isForm: true,
969
- propertyWidth: 150,
970
- value: /* @__PURE__ */ jsx(
971
- RHFAutocomplete,
972
- {
973
- type: "text",
974
- name: "properties.strokeWeight",
975
- autoComplete: "off",
976
- options: STYLE_WHEIGHTS,
977
- getOptionLabel: (option) => option.label,
978
- isOptionEqualToValue: (option, value) => option.value === value.value
979
- }
980
- )
981
- },
982
- "properties.strokeWeight"
983
- ),
984
- /* @__PURE__ */ jsx(
985
- PropertyValue,
986
- {
987
- property: getLabel(`${MAP_GPSTOOLS_DICCTIONARY.LABEL_DASH_ARRAY}`),
988
- isForm: true,
989
- propertyWidth: 150,
990
- value: /* @__PURE__ */ jsx(
991
- RHFAutocomplete,
992
- {
993
- type: "text",
994
- name: "properties.strokeDashArray",
995
- autoComplete: "off",
996
- options: STYLE_PATTERNS,
997
- getOptionLabel: (option) => option.label,
998
- isOptionEqualToValue: (option, value) => option.value === value.value
999
- }
1000
- )
1001
- },
1002
- "properties.strokeDashArray"
1003
- )
1004
- ] });
1005
- }
1006
- function StyleData() {
1007
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1008
- /* @__PURE__ */ jsx(StrokeData, {}),
1009
- /* @__PURE__ */ jsx(FillData, {})
1010
- ] });
1011
- }
1012
- function MyTabs() {
1013
- const { getLabel } = useModuleDictionary();
1014
- const { host_static_assets, environment_assets } = useEnvironment();
1015
- const { currentTab, handleChange } = useTab();
1016
- const geofenceAddEditTabs = useMemo(() => {
1017
- return [
1018
- {
1019
- id: "general",
1020
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.DATA}`,
1021
- component: /* @__PURE__ */ jsxs(Fragment, { children: [
1022
- /* @__PURE__ */ jsx(GeneralData, {}),
1023
- /* @__PURE__ */ jsx(ConfigData, {})
1024
- ] }),
1025
- label: getLabel(MAP_GPSTOOLS_DICCTIONARY.TAB_GENERAL_CONFIG_TOOLTIP),
1026
- className: gpsToolsClasses.toolGeofencesAddEditGeneral
1027
- },
1028
- {
1029
- id: "style",
1030
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.STYLE}`,
1031
- component: /* @__PURE__ */ jsx(StyleData, {}),
1032
- label: getLabel(MAP_GPSTOOLS_DICCTIONARY.TAB_STYLE_CONFIG_TOOLTIP),
1033
- className: gpsToolsClasses.toolGeofencesAddEditStyle
1034
- }
1035
- ];
1036
- }, [getLabel]);
1037
- return /* @__PURE__ */ jsxs("div", { className: gpsToolsClasses.gpsToolsGeofencesAddEditContent, children: [
1038
- /* @__PURE__ */ jsx(
1039
- Tabs,
1040
- {
1041
- value: currentTab,
1042
- scrollButtons: "auto",
1043
- variant: "scrollable",
1044
- allowScrollButtonsMobile: true,
1045
- onChange: (_e, newValue) => handleChange(_e, newValue),
1046
- children: geofenceAddEditTabs.map((tab) => /* @__PURE__ */ jsx(
1047
- Tab,
1048
- {
1049
- value: tab.id,
1050
- icon: /* @__PURE__ */ jsx(Icon, { src: tab.iconUrl }),
1051
- label: "",
1052
- SKTWidth: "100px",
1053
- SKTHeight: "14px"
1054
- },
1055
- tab.id
1056
- ))
1057
- }
1058
- ),
1059
- geofenceAddEditTabs.map((tab) => {
1060
- const isMatched = tab.id === currentTab;
1061
- return /* @__PURE__ */ jsx(
1062
- TabContent,
1063
- {
1064
- className: clsx(
1065
- gpsToolsClasses.gpsToolsTabContent,
1066
- tab.className,
1067
- isMatched ? gpsToolsClasses.visible : gpsToolsClasses.hidden
1068
- ),
1069
- children: tab.component
1070
- },
1071
- tab.id
1072
- );
1073
- })
1074
- ] });
1075
- }
1076
- function GeneralDataValidation(getLabel) {
1077
- return {
1078
- name: Yup.string().required(getLabel(MAP_GPSTOOLS_DICCTIONARY.VALIDATION_FIELD_REQUIRED)),
1079
- geometry: Yup.object().nullable().required(getLabel(MAP_GPSTOOLS_DICCTIONARY.VALIDATION_GEOMETRY_REQUIRED)),
1080
- geofenceType: Yup.object().nullable().required(getLabel(MAP_GPSTOOLS_DICCTIONARY.VALIDATION_FIELD_REQUIRED))
1081
- };
1082
- }
1083
- function ConfigDataValidation(getLabel) {
1084
- return {
1085
- timeMinInSeconds: Yup.number().nullable().required(getLabel(MAP_GPSTOOLS_DICCTIONARY.VALIDATION_FIELD_REQUIRED)).typeError(getLabel(MAP_GPSTOOLS_DICCTIONARY.VALIDATION_FIELD_TYPE_NUMBER_ERROR)).min(0, getLabel(MAP_GPSTOOLS_DICCTIONARY.VALIDATION_FIELD_MIN_NUMBER_ERROR)),
1086
- timeMinOutSeconds: Yup.number().nullable().required(getLabel(MAP_GPSTOOLS_DICCTIONARY.VALIDATION_FIELD_REQUIRED)).typeError(getLabel(MAP_GPSTOOLS_DICCTIONARY.VALIDATION_FIELD_TYPE_NUMBER_ERROR)).min(0, getLabel(MAP_GPSTOOLS_DICCTIONARY.VALIDATION_FIELD_MIN_NUMBER_ERROR))
1087
- };
1088
- }
1089
- function useValidation() {
1090
- const { getLabel } = useModuleDictionary();
1091
- const validationSchema = useMemo(
1092
- () => Yup.object().shape({
1093
- ...GeneralDataValidation(getLabel),
1094
- ...ConfigDataValidation(getLabel)
1095
- }),
1096
- [getLabel]
1097
- );
1098
- return { validationSchema };
1099
- }
1100
- const ENDPOINT_GEOFENCE_GET = "geofences";
1101
- const ENDPOINT_GEOFENCE_NEW_EDIT = "geofences";
1102
- var GeofencesFeaturesLayers = /* @__PURE__ */ ((GeofencesFeaturesLayers2) => {
1103
- GeofencesFeaturesLayers2["LAYER_GEOFENCES"] = "geofences";
1104
- GeofencesFeaturesLayers2["LAYER_GEOFENCES_TRANSIT_FEATURES"] = "geofencesCrossingFeatures";
1105
- GeofencesFeaturesLayers2["LAYER_GEOFENCES_INTERNAL_FEATURES"] = "geofencesInternalFeatures";
1106
- return GeofencesFeaturesLayers2;
1107
- })(GeofencesFeaturesLayers || {});
1108
- const getSummitData = (values, geofenceId) => {
1109
- const newEditObj = {
1110
- name: values.name,
1111
- typeId: values.geofenceType.id,
1112
- geometry: values.geometry,
1113
- properties: {
1114
- subType: values.properties.subType,
1115
- strokeColor: values.properties.fillColor,
1116
- strokeOpacity: values.properties.strokeOpacity.value,
1117
- strokeWeight: values.properties.strokeWeight.value,
1118
- strokeDashArray: values.properties.strokeDashArray.value,
1119
- fillColor: values.properties.fillColor,
1120
- fillOpacity: values.properties.fillOpacity.value
1121
- },
1122
- timeMinInSeconds: values.timeMinInSeconds,
1123
- timeMinOutSeconds: values.timeMinOutSeconds,
1124
- alias: values.alias,
1125
- customerId: values.customerId,
1126
- ...geofenceId ? { geofenceId } : {}
1127
- };
1128
- if (values.geofenceType.id === "gt_circle") {
1129
- newEditObj.properties.radius = values.properties.radius;
1130
- }
1131
- return newEditObj;
1132
- };
1133
- function useSubmit(props) {
1134
- const { objectId, fullRefresh } = props;
1135
- const { toast } = useHostTools();
1136
- const { networkOperation } = useNetwork();
1137
- const { closePopup, showPopup } = usePopupsStore((state) => state.popupsActions);
1138
- const { addCheckedGeofence } = useGpsToolsStore((state) => state.geofenceActions, shallow);
1139
- const onSubmit = async (data) => {
1140
- await networkOperation({
1141
- method: objectId ? "PUT" : "POST",
1142
- endPoint: `${ENDPOINT_GEOFENCE_NEW_EDIT}${objectId ? `/${objectId}` : ""}`,
1143
- data: getSummitData(data, objectId),
1144
- toastError: true,
1145
- toastSuccess: false,
1146
- bodyToSnakeCase: true,
1147
- isRemote: false
1148
- }).then((response) => {
1149
- toast({ title: response.message }, { type: "success" });
1150
- closePopup("geofencesAddEdit");
1151
- showPopup("gpsTools");
1152
- if (objectId !== void 0) {
1153
- addCheckedGeofence(objectId);
1154
- }
1155
- if (fullRefresh) {
1156
- fullRefresh();
1157
- }
1158
- }).catch(() => {
1159
- });
1160
- };
1161
- return { onSubmit };
1162
- }
1163
- function GeofenceAddEdit(props) {
1164
- const { geofenceId } = props;
1165
- const [finalInitalValues, omitCallEnpoint] = useGpsToolsStore((state) => {
1166
- if (geofenceId === void 0) {
1167
- return [initialValues, false];
1168
- }
1169
- const geofence = state.geofenceState.hashGeofences[geofenceId];
1170
- if (geofence?.geometry) {
1171
- const emulateResponse = {
1172
- data: {
1173
- type: geofence.type,
1174
- name: geofence.name,
1175
- id: geofence.id,
1176
- active: false,
1177
- geometry: geofence.geometry,
1178
- properties: geofence.properties,
1179
- countCrossingFeatures: geofence.countCrossingFeatures,
1180
- countInternalFeatures: geofence.countInternalFeatures,
1181
- createdAt: geofence.createdAt,
1182
- updatedAt: geofence.updatedAt,
1183
- timeMinInSeconds: geofence.timeMinInSeconds,
1184
- timeMinOutSeconds: geofence.timeMinOutSeconds,
1185
- alias: geofence.alias,
1186
- customerId: geofence.customerId
1187
- }
1188
- };
1189
- return [formatDataEnpoint(emulateResponse), true];
1190
- } else {
1191
- return [initialValues, false];
1192
- }
1193
- });
1194
- const { formValues, statusLoad } = useFormAddEdit({
1195
- objectId: geofenceId,
1196
- formatDataEnpoint,
1197
- initialValues: finalInitalValues,
1198
- endPoint: ENDPOINT_GEOFENCE_GET,
1199
- isRemote: false,
1200
- omitCallEnpoint
1201
- });
1202
- const { validationSchema } = useValidation();
1203
- const { onSubmit } = useSubmit({ objectId: geofenceId });
1204
- return /* @__PURE__ */ jsx(
1205
- RHFormProviderStyled,
1206
- {
1207
- statusLoad,
1208
- onSubmit,
1209
- values: formValues,
1210
- validationSchema,
1211
- className: gpsToolsClasses.gpsToolsGeofencesAddEdit,
1212
- children: /* @__PURE__ */ jsxs(Stack, { direction: "column", gap: "8px", children: [
1213
- /* @__PURE__ */ jsx(TabProvider, { initialValue: "general", children: /* @__PURE__ */ jsx(MyTabs, {}) }),
1214
- /* @__PURE__ */ jsx(MyActions, { ...props })
1215
- ] })
1216
- }
1217
- );
1218
- }
1219
- function useRowActionsGetter(props) {
1220
- const { fullRefresh } = props;
1221
- const { networkOperation } = useNetwork();
1222
- const { openModal, closeModal } = useModal();
1223
- const { getLabel } = useModuleDictionary();
1224
- const { hasPrivilege } = useModulePrivileges();
1225
- const { host_static_assets, environment_assets } = useEnvironment();
1226
- const { hidePopup, addPopup } = usePopupsStore((state) => state.popupsActions, shallow);
1227
- const { removeCheckedGeofence } = useGpsToolsStore((state) => state.geofenceActions, shallow);
1228
- const { toast } = useHostTools();
1229
- const isDesktop = useResponsiveDesktop();
1230
- const [urlIconEdit] = useState(
1231
- `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCE_EDIT}`
1232
- );
1233
- const [urlIconDelete] = useState(
1234
- `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCE_DELETE}`
1235
- );
1236
- const goEdit = (objectId, name) => {
1237
- hidePopup("gpsTools");
1238
- addPopup({
1239
- popupId: "geofencesAddEdit",
1240
- title: getLabel(MAP_GPSTOOLS_DICCTIONARY.ACTION_GEOFENCE_EDIT),
1241
- editionInfo: `${getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_ID)}:${objectId} - ${name} `,
1242
- componentProps: { fullRefresh, geofenceId: objectId },
1243
- functionComponent: GeofenceAddEdit,
1244
- // onMouseDown,
1245
- defaultPosition: {
1246
- vertical: { top: 50, bottom: 50 },
1247
- horizontal: { right: 50, width: 380 }
1248
- // left:490,top:50,width:360, height:420},
1249
- // bounds:{top:5, left:5, right:-5, bottom:-5}
1250
- },
1251
- iconUrl: urlIconEdit
1252
- });
1253
- removeCheckedGeofence(objectId);
1254
- };
1255
- const onDelete = useCallback(
1256
- (row) => {
1257
- openModal({
1258
- window: /* @__PURE__ */ jsx(
1259
- WindowConfirm,
1260
- {
1261
- title: getLabel(MAP_GPSTOOLS_DICCTIONARY.MODAL_DELETE_GEO_TITLE),
1262
- msg: getLabel(MAP_GPSTOOLS_DICCTIONARY.MODAL_DELETE_GEO_MESSAGE),
1263
- onClickIntro: () => onConfirmDelete(row)
1264
- }
1265
- ),
1266
- variant: "delete",
1267
- initialWidth: 300,
1268
- initialHeigth: 350
1269
- });
1270
- },
1271
- [getLabel]
1272
- );
1273
- const onConfirmDelete = useCallback((row) => {
1274
- networkOperation({
1275
- method: "DELETE",
1276
- endPoint: `geofences/${row.id}`
1277
- }).then((response) => {
1278
- toast({ title: response.message }, { type: "success" });
1279
- fullRefresh();
1280
- });
1281
- closeModal();
1282
- }, []);
1283
- const rowActionsGetter = useCallback(
1284
- (row) => {
1285
- const conditionalItems = [];
1286
- conditionalItems.push({
1287
- urlIcon: urlIconEdit,
1288
- dictionaryId: MAP_GPSTOOLS_DICCTIONARY.ROW_ACTION_GEO_EDIT,
1289
- onClick: () => {
1290
- goEdit(row.id, row.name);
1291
- },
1292
- // Solo se habilita si intenta editarse a él mismo, o si tiene permisos pero está en un nivel superior al usuario a editar
1293
- // disabled: !(itsMe || (hasPrivilege(PRIVILEGE_EDIT) && (loggedUserType > row.user_type.id)))
1294
- disabled: !row.authUserOptions.edit
1295
- });
1296
- conditionalItems.push({
1297
- urlIcon: urlIconDelete,
1298
- dictionaryId: MAP_GPSTOOLS_DICCTIONARY.ROW_ACTION_GEO_DELETE,
1299
- onClick: () => {
1300
- onDelete(row);
1301
- },
1302
- variant: "delete",
1303
- // Solo se habilita si intenta editarse a él mismo, o si tiene permisos pero está en un nivel superior al usuario a editar
1304
- // disabled: !(itsMe || (hasPrivilege(PRIVILEGE_EDIT) && (loggedUserType > row.user_type.id)))
1305
- disabled: !row.authUserOptions.edit
1306
- });
1307
- return conditionalItems;
1308
- },
1309
- [hasPrivilege, goEdit, onDelete, urlIconDelete, urlIconEdit, isDesktop]
1310
- );
1311
- return { rowActionsGetter };
1312
- }
1313
- function useCheckedGeofences() {
1314
- const layersIds = useMapStore((state) => state.layersIds, shallow);
1315
- const [checkedGeofences, hashGeofences] = useGpsToolsStore(
1316
- (state) => [state.geofenceState.checkedGeofences, state.geofenceState.hashGeofences],
1317
- shallow
1318
- );
1319
- const { setCheckedGeofences, updatePartialGeofence } = useGpsToolsStore(
1320
- (state) => state.geofenceActions,
1321
- shallow
1322
- );
1323
- const { setFeatureData, removeFeature, getFeatureIds } = useMapStore(
1324
- (state) => state.mapActions,
1325
- shallow
1326
- );
1327
- const { networkOperation } = useNetwork();
1328
- useEffect(() => {
1329
- if (!layersIds.includes(GeofencesFeaturesLayers.LAYER_GEOFENCES)) {
1330
- return;
1331
- }
1332
- const mapFeatureIds = getFeatureIds(GeofencesFeaturesLayers.LAYER_GEOFENCES);
1333
- checkedGeofences.forEach((chkRow) => {
1334
- const geofence = hashGeofences[chkRow];
1335
- if (!geofence) {
1336
- return;
1337
- }
1338
- if (!mapFeatureIds.includes(chkRow) || !geofence.hasRenderizedGeofence) {
1339
- if (!geofence.geometry) {
1340
- networkOperation({
1341
- method: "GET",
1342
- endPoint: `geofences/${geofence.id}`,
1343
- isRemote: false,
1344
- responseToCamelCase: true
1345
- }).then((response) => {
1346
- const geoLoaded = {
1347
- geometry: response.data.geometry,
1348
- name: response.data.name,
1349
- properties: response.data.properties,
1350
- countCrossingFeatures: response.data.countCrossingFeatures,
1351
- hasRenderizedGeofence: false
1352
- };
1353
- if (geoLoaded.geometry) {
1354
- if (checkedGeofences.has(geofence.id)) {
1355
- setFeatureData("geofences", chkRow, geoLoaded.geometry, geoLoaded.properties, {
1356
- label: geoLoaded.name,
1357
- labelColor: geoLoaded.properties?.color
1358
- });
1359
- geoLoaded.hasRenderizedGeofence = true;
1360
- }
1361
- }
1362
- updatePartialGeofence(geofence.id, geoLoaded);
1363
- });
1364
- } else {
1365
- setFeatureData(
1366
- GeofencesFeaturesLayers.LAYER_GEOFENCES,
1367
- chkRow,
1368
- geofence.geometry,
1369
- geofence.properties,
1370
- { label: geofence.name }
1371
- );
1372
- updatePartialGeofence(geofence.id, { hasRenderizedGeofence: true });
1373
- }
1374
- }
1375
- });
1376
- mapFeatureIds.forEach((mapFeatureId) => {
1377
- if (!checkedGeofences.has(Number(mapFeatureId))) {
1378
- removeFeature(GeofencesFeaturesLayers.LAYER_GEOFENCES, mapFeatureId);
1379
- }
1380
- });
1381
- return () => {
1382
- };
1383
- }, [checkedGeofences, layersIds]);
1384
- return {
1385
- checkedGeofences,
1386
- setCheckedGeofences
1387
- };
1388
- }
1389
- function useCheckedFeatures(layerId, featuresType, endpoint) {
1390
- const layersIds = useMapStore((state) => state.layersIds, shallow);
1391
- const [checkedFeatures, setCheckedFeatures, hashGeofences] = useGpsToolsStore((state) => {
1392
- return featuresType === "CrossingFeatures" ? [
1393
- state.geofenceState.checkedCrossingFeatures,
1394
- state.geofenceActions.setCheckedCrossingFeatures,
1395
- state.geofenceState.hashGeofences
1396
- ] : [
1397
- state.geofenceState.checkedInternalFeatures,
1398
- state.geofenceActions.setCheckedInternalFeatures,
1399
- state.geofenceState.hashGeofences
1400
- ];
1401
- }, shallow);
1402
- const { setFeatureData, removeFeature, getFeatureIds } = useMapStore(
1403
- (state) => state.mapActions,
1404
- shallow
1405
- );
1406
- const { networkOperation } = useNetwork();
1407
- useEffect(() => {
1408
- if (!layersIds.includes(layerId)) {
1409
- return;
1410
- }
1411
- const mapFeatureIds = getFeatureIds(layerId);
1412
- checkedFeatures.forEach((chkRow) => {
1413
- const geofence = hashGeofences[chkRow];
1414
- if (!geofence) {
1415
- return;
1416
- }
1417
- if (!mapFeatureIds.find((fId) => fId.toString().includes(`geo_${geofence.id}_fid`)) || !geofence[`hasRenderized${featuresType}`]) {
1418
- const currentGeofenceLoadedFeatures = geofence[`loaded${featuresType}`];
1419
- if (!currentGeofenceLoadedFeatures) {
1420
- networkOperation({
1421
- method: "GET",
1422
- endPoint: `geofences/${geofence.id}/${endpoint}`,
1423
- isRemote: false,
1424
- responseToCamelCase: true
1425
- }).then((response) => {
1426
- geofence[`loaded${featuresType}`] = response.data;
1427
- const newGeofenceLoadedFeatures = geofence[`loaded${featuresType}`];
1428
- if (newGeofenceLoadedFeatures && Array.isArray(geofence[`loaded${featuresType}`])) {
1429
- if (checkedFeatures.has(geofence.id)) {
1430
- newGeofenceLoadedFeatures.forEach((feature) => {
1431
- setFeatureData(
1432
- layerId,
1433
- `geo_${geofence.id}_fid_${feature.id}`,
1434
- feature.geometry,
1435
- feature.properties
1436
- );
1437
- });
1438
- geofence[`hasRenderized${featuresType}`] = true;
1439
- }
1440
- }
1441
- }).catch(() => {
1442
- });
1443
- } else {
1444
- currentGeofenceLoadedFeatures.forEach((feature) => {
1445
- setFeatureData(
1446
- layerId,
1447
- `geo_${geofence.id}_fid_${feature.id}`,
1448
- feature.geometry,
1449
- feature.properties
1450
- );
1451
- });
1452
- geofence[`hasRenderized${featuresType}`] = true;
1453
- }
1454
- }
1455
- });
1456
- mapFeatureIds.forEach((mapFeatureId) => {
1457
- const featureId = Number(mapFeatureId.toString().split("_")[1]);
1458
- if (!checkedFeatures.has(featureId)) {
1459
- removeFeature(layerId, mapFeatureId);
1460
- }
1461
- });
1462
- return () => {
1463
- };
1464
- }, [checkedFeatures, layersIds]);
1465
- return [checkedFeatures, setCheckedFeatures];
1466
- }
1467
- function useMaster() {
1468
- const { getLabel } = useModuleDictionary();
1469
- const { host_static_assets, environment_assets } = useEnvironment();
1470
- const { hidePopup, addPopup } = usePopupsStore((state) => state.popupsActions, shallow);
1471
- const goToAdd = () => {
1472
- hidePopup("gpsTools");
1473
- addPopup({
1474
- popupId: "geofencesAddEdit",
1475
- title: getLabel(MAP_GPSTOOLS_DICCTIONARY.ACTION_GEOFENCE_ADD),
1476
- functionComponent: () => /* @__PURE__ */ jsx(GeofenceAddEdit, {}),
1477
- // onMouseDown,
1478
- defaultPosition: {
1479
- vertical: { top: 50, bottom: 50 },
1480
- horizontal: { right: 50, width: 380 }
1481
- // left:490,top:50,width:360, height:420},
1482
- // bounds:{top:5, left:5, right:-5, bottom:-5}
1483
- },
1484
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCE_ADD}`
1485
- });
1486
- };
1487
- const [checkedGeofences, hashGeofences, initialRows] = useGpsToolsStore(
1488
- (state) => [
1489
- state.geofenceState.checkedGeofences,
1490
- state.geofenceState.hashGeofences,
1491
- state.geofenceState.rows
1492
- ],
1493
- shallow
1494
- );
1495
- const { setCheckedGeofences, addGeofence, updatePartialGeofence, updateRows } = useGpsToolsStore(
1496
- (state) => state.geofenceActions,
1497
- shallow
1498
- );
1499
- useCheckedGeofences();
1500
- const [checkedCrossingFeatures, setCheckedCrossingFeatures] = useCheckedFeatures(
1501
- GeofencesFeaturesLayers.LAYER_GEOFENCES_TRANSIT_FEATURES,
1502
- "CrossingFeatures",
1503
- "crossing_features"
1504
- );
1505
- const [checkedInternalFeatures, setCheckedInternalFeatures] = useCheckedFeatures(
1506
- GeofencesFeaturesLayers.LAYER_GEOFENCES_INTERNAL_FEATURES,
1507
- "InternalFeatures",
1508
- "internal_features"
1509
- );
1510
- const rowKeyGetter = useCallback((row) => row.id, []);
1511
- const [selectedRows, setSelectedRows] = useState(/* @__PURE__ */ new Set());
1512
- const [backendQueryParams, setBackendQueryParams] = useState({});
1513
- const { columns } = useColumns();
1514
- const { pagerState, rows, onPageChange, onRowsPerPageChange, Refresh, setRows } = usePaginate({
1515
- endPoint: "geofences",
1516
- fireOnChangeParms: false,
1517
- fireOnFirstLoad: false,
1518
- queryParams: backendQueryParams,
1519
- isRemote: false,
1520
- responseToCamelCase: true,
1521
- initialRows
1522
- });
1523
- const onSelectedRowsChange = (newRowsSelectSet) => {
1524
- setSelectedRows(newRowsSelectSet);
1525
- };
1526
- const fullRefresh = useCallback((_id) => {
1527
- Refresh();
1528
- }, []);
1529
- useEffect(() => {
1530
- const newCheckedGeofences = new Set(checkedGeofences);
1531
- const newCheckedCrossingFeatures = new Set(checkedCrossingFeatures);
1532
- const newCheckedInternalFeatures = new Set(checkedInternalFeatures);
1533
- let updatedCheckedGeofences = false;
1534
- let updatedCheckedCrossingFeatures = false;
1535
- let updatedCheckedInternalFeatures = false;
1536
- newCheckedGeofences.forEach((chkRow) => {
1537
- if (rows.findIndex((row) => row.id === chkRow) === -1) {
1538
- newCheckedGeofences.delete(chkRow);
1539
- }
1540
- });
1541
- newCheckedCrossingFeatures.forEach((chkTF) => {
1542
- if (rows.findIndex((row) => row.id === chkTF) === -1) {
1543
- newCheckedCrossingFeatures.delete(chkTF);
1544
- }
1545
- });
1546
- newCheckedInternalFeatures.forEach((chkIF) => {
1547
- if (rows.findIndex((row) => row.id === chkIF) === -1) {
1548
- newCheckedInternalFeatures.delete(chkIF);
1549
- }
1550
- });
1551
- rows.forEach((row) => {
1552
- let hasGeo = hashGeofences[row.id];
1553
- if (!hasGeo) {
1554
- hasGeo = {
1555
- ...row,
1556
- hasRenderizedGeofence: false,
1557
- loadedCrossingFeatures: null,
1558
- loadedInternalFeatures: null,
1559
- hasRenderizedCrossingFeatures: false,
1560
- hasRenderizedInternalFeatures: false,
1561
- createdAt: row.createdAt
1562
- };
1563
- addGeofence(row.id, hasGeo);
1564
- return;
1565
- }
1566
- if (row.updatedAt && row.updatedAt !== hasGeo.updatedAt) {
1567
- updatePartialGeofence(row.id, {
1568
- updatedAt: row.updatedAt,
1569
- geometry: null,
1570
- hasRenderizedGeofence: false,
1571
- hasRenderizedCrossingFeatures: false,
1572
- hasRenderizedInternalFeatures: false,
1573
- loadedCrossingFeatures: null,
1574
- loadedInternalFeatures: null
1575
- });
1576
- updatedCheckedGeofences = true;
1577
- updatedCheckedCrossingFeatures = true;
1578
- updatedCheckedInternalFeatures = true;
1579
- }
1580
- });
1581
- if (newCheckedGeofences.size !== checkedGeofences.size || updatedCheckedGeofences) {
1582
- setCheckedGeofences(newCheckedGeofences);
1583
- }
1584
- if (newCheckedCrossingFeatures.size !== checkedCrossingFeatures.size || updatedCheckedCrossingFeatures) {
1585
- setCheckedCrossingFeatures(newCheckedCrossingFeatures);
1586
- }
1587
- if (newCheckedInternalFeatures.size !== checkedInternalFeatures.size || updatedCheckedInternalFeatures) {
1588
- setCheckedInternalFeatures(newCheckedInternalFeatures);
1589
- }
1590
- onSelectedRowsChange(selectedRows);
1591
- updateRows(rows);
1592
- }, [rows]);
1593
- const { rowActionsGetter } = useRowActionsGetter({ fullRefresh });
1594
- return {
1595
- rowKeyGetter,
1596
- columns,
1597
- refresh: Refresh,
1598
- setBackendQueryParams,
1599
- pagerState,
1600
- rows,
1601
- onPageChange,
1602
- onRowsPerPageChange,
1603
- rowActionsGetter,
1604
- selectedRows,
1605
- onSelectedRowsChange,
1606
- checkedRows: checkedGeofences,
1607
- onCheckedRowsChange: setCheckedGeofences,
1608
- setRows,
1609
- goToAdd
1610
- };
1611
- }
1612
- function GeofencesList() {
1613
- const { getLabel } = useModuleDictionary();
1614
- const {
1615
- refresh,
1616
- setBackendQueryParams,
1617
- columns,
1618
- rows,
1619
- rowActionsGetter,
1620
- selectedRows,
1621
- onSelectedRowsChange,
1622
- pagerState,
1623
- onPageChange,
1624
- onRowsPerPageChange,
1625
- checkedRows,
1626
- onCheckedRowsChange,
1627
- setRows,
1628
- rowKeyGetter,
1629
- goToAdd
1630
- } = useMaster();
1631
- return /* @__PURE__ */ jsxs(
1632
- StackGeofenceListRoot,
1633
- {
1634
- direction: "column",
1635
- gap: "8px",
1636
- className: gpsToolsClasses.gpsToolsGeofencesList,
1637
- children: [
1638
- /* @__PURE__ */ jsx(Filter, { refresh, setBackendQueryParams }),
1639
- /* @__PURE__ */ jsx(
1640
- DataGrid,
1641
- {
1642
- id: "geofences",
1643
- columns,
1644
- rows,
1645
- onRowsChange: setRows,
1646
- checkedRows,
1647
- onCheckedRowsChange,
1648
- rowActionsGetter,
1649
- rowKeyGetter,
1650
- selectedRows,
1651
- onSelectedRowsChange,
1652
- withActions: true,
1653
- actionsProps: {
1654
- withPager: true,
1655
- withLocalFilters: true,
1656
- pagerOptions: {
1657
- records: rows.length,
1658
- totalRecords: pagerState.totalRecords,
1659
- rowsPerPageOptions: [1, 2, 3, 4, 5, 10, 25],
1660
- page: pagerState.page,
1661
- rowsPerPage: pagerState.rowsPerPage,
1662
- onPageChange,
1663
- onRowsPerPageChange
1664
- }
1665
- }
1666
- },
1667
- "list"
1668
- ),
1669
- /* @__PURE__ */ jsx(Actions, { children: /* @__PURE__ */ jsx(Button, { onClick: () => goToAdd(), children: getLabel(MAP_GPSTOOLS_DICCTIONARY.ACTION_GEOFENCE_ADD) }) })
1670
- ]
1671
- }
1672
- );
1673
- }
1674
- enableMapSet();
1675
- const createGpsToolsStore = (initProps) => {
1676
- const startProps = {
1677
- currentTabGpsTool: "geofences",
1678
- geofenceState: {
1679
- // currentGeofenceTool: 'list',
1680
- rows: [],
1681
- checkedGeofences: /* @__PURE__ */ new Set(),
1682
- checkedCrossingFeatures: /* @__PURE__ */ new Set(),
1683
- checkedInternalFeatures: /* @__PURE__ */ new Set(),
1684
- hashGeofences: {}
1685
- },
1686
- ...initProps
1687
- };
1688
- return createStore(
1689
- devtools(
1690
- immer((set, _get) => ({
1691
- ...startProps,
1692
- gpsToolsActions: {
1693
- init: () => {
1694
- set((state) => {
1695
- state.ownerState.status = "ready";
1696
- });
1697
- },
1698
- setGpsToolsState: (status) => {
1699
- set((state) => {
1700
- state.ownerState.status = status;
1701
- });
1702
- },
1703
- setHandlerGetLabel: (newHandler) => {
1704
- set((state) => {
1705
- state.getLabel = newHandler;
1706
- });
1707
- },
1708
- setExternalState: (newExternalState) => {
1709
- set((state) => {
1710
- state.ownerState = { ...state.ownerState, ...newExternalState };
1711
- });
1712
- },
1713
- setCurrentTabTool: (newTabTool) => {
1714
- set((state) => {
1715
- state.currentTabGpsTool = newTabTool;
1716
- });
1717
- }
1718
- },
1719
- geofenceActions: {
1720
- // goToAddEdit: (geofenceId?: GeofenceId) => {
1721
- // set(state => {
1722
- // state.geofenceState.currentGeofenceTool = 'add_edit';
1723
- // state.geofenceState.geofenceId = geofenceId;
1724
- // });
1725
- // },
1726
- // goToList: (geofenceId?: GeofenceId) => {
1727
- // set(state => {
1728
- // state.geofenceState.currentGeofenceTool = 'list';
1729
- // state.geofenceState.geofenceId = geofenceId;
1730
- // });
1731
- // },
1732
- addGeofence: (geofenceId, geofence) => {
1733
- set((state) => {
1734
- state.geofenceState.hashGeofences[geofenceId] = geofence;
1735
- });
1736
- },
1737
- updatePartialGeofence: (geofenceId, geofence) => {
1738
- set((state) => {
1739
- state.geofenceState.hashGeofences[geofenceId] = {
1740
- ...state.geofenceState.hashGeofences[geofenceId],
1741
- ...geofence
1742
- };
1743
- });
1744
- },
1745
- updateRows: (newRows) => {
1746
- set((state) => {
1747
- state.geofenceState.rows = newRows;
1748
- });
1749
- },
1750
- addCheckedGeofence: (geofenceId) => {
1751
- set((state) => {
1752
- state.geofenceState.checkedGeofences.add(geofenceId);
1753
- state.geofenceState.checkedGeofences = new Set(state.geofenceState.checkedGeofences);
1754
- });
1755
- },
1756
- removeCheckedGeofence: (geofenceId) => {
1757
- set((state) => {
1758
- state.geofenceState.checkedGeofences.delete(geofenceId);
1759
- state.geofenceState.checkedGeofences = new Set(state.geofenceState.checkedGeofences);
1760
- });
1761
- },
1762
- setCheckedGeofences: (newGeofences) => {
1763
- set((state) => {
1764
- state.geofenceState.checkedGeofences = new Set(newGeofences);
1765
- });
1766
- },
1767
- setCheckedCrossingFeatures: (newFeatures) => {
1768
- set((state) => {
1769
- state.geofenceState.checkedCrossingFeatures = new Set(newFeatures);
1770
- });
1771
- },
1772
- setCheckedInternalFeatures: (newFeatures) => {
1773
- set((state) => {
1774
- state.geofenceState.checkedInternalFeatures = new Set(newFeatures);
1775
- });
1776
- }
1777
- }
1778
- })),
1779
- { name: `Map Tools Store` }
1780
- )
1781
- );
1782
- };
1783
- const GpsToolsContext = createContext(null);
1784
- function GpsToolsProvider(props) {
1785
- const { children } = props;
1786
- const { getLabel } = useModuleDictionary();
1787
- const isDesktop = useResponsiveDesktop();
1788
- const isSkeleton = useModuleSkeleton();
1789
- const isFirstRender = useFirstRender([getLabel]);
1790
- const mapStoreRef = useRef();
1791
- if (!mapStoreRef.current) {
1792
- mapStoreRef.current = createGpsToolsStore({
1793
- getLabel,
1794
- ownerState: {
1795
- status: "init",
1796
- isMobile: !isDesktop,
1797
- isSkeleton,
1798
- focus: false
1799
- }
1800
- });
1801
- }
1802
- const { setHandlerGetLabel, setExternalState } = useStore(
1803
- mapStoreRef.current,
1804
- (state) => state.gpsToolsActions,
1805
- shallow
1806
- );
1807
- useEffect(() => {
1808
- if (!isFirstRender) {
1809
- setHandlerGetLabel(getLabel);
1810
- }
1811
- }, [getLabel]);
1812
- useEffect(() => {
1813
- if (isFirstRender) {
1814
- return;
1815
- }
1816
- setExternalState({ isMobile: !isDesktop, isSkeleton });
1817
- }, [isDesktop, isSkeleton]);
1818
- return /* @__PURE__ */ jsx(GpsToolsContext.Provider, { value: mapStoreRef.current, children });
1819
- }
1820
- function useGpsToolsStore(selector, equalityFn) {
1821
- const context = useContext(GpsToolsContext);
1822
- if (!context) throw new Error("useGpsToolsStore context must be use inside GpsToolsContext");
1823
- return useStore(context, selector, equalityFn);
1824
- }
1825
- function useLayers() {
1826
- const { addLayer, removeLayer } = useMapStore((state) => state.mapActions, shallow);
1827
- const { init } = useGpsToolsStore((state) => state.gpsToolsActions, shallow);
1828
- useEffect(() => {
1829
- addLayer({
1830
- layerId: GeofencesFeaturesLayers.LAYER_GEOFENCES,
1831
- name: "Geocercas",
1832
- renderFeature: CommonFeatureRender,
1833
- geoJsonObject: {
1834
- object: {
1835
- type: "FeatureCollection",
1836
- features: []
1837
- }
1838
- },
1839
- autoFocus: false
1840
- });
1841
- addLayer({
1842
- layerId: GeofencesFeaturesLayers.LAYER_GEOFENCES_TRANSIT_FEATURES,
1843
- name: "Geometrías de tránsito",
1844
- renderFeature: CommonFeatureRender,
1845
- geoJsonObject: {
1846
- object: {
1847
- type: "FeatureCollection",
1848
- features: []
1849
- }
1850
- },
1851
- autoFocus: false
1852
- });
1853
- addLayer({
1854
- layerId: GeofencesFeaturesLayers.LAYER_GEOFENCES_INTERNAL_FEATURES,
1855
- name: "Geometrías internas",
1856
- renderFeature: CommonFeatureRender,
1857
- geoJsonObject: {
1858
- object: {
1859
- type: "FeatureCollection",
1860
- features: []
1861
- }
1862
- },
1863
- autoFocus: false
1864
- });
1865
- init();
1866
- return () => {
1867
- removeLayer(GeofencesFeaturesLayers.LAYER_GEOFENCES);
1868
- removeLayer(GeofencesFeaturesLayers.LAYER_GEOFENCES_INTERNAL_FEATURES);
1869
- removeLayer(GeofencesFeaturesLayers.LAYER_GEOFENCES_TRANSIT_FEATURES);
1870
- };
1871
- }, []);
1872
- }
1873
- function TabsGpsTools() {
1874
- const { getLabel } = useModuleDictionary();
1875
- const { host_static_assets, environment_assets } = useEnvironment();
1876
- const status = useGpsToolsStore((state) => state.ownerState.status, shallow);
1877
- const currentTabTool = useGpsToolsStore((state) => state.currentTabGpsTool, shallow);
1878
- const { setCurrentTabTool } = useGpsToolsStore((state) => state.gpsToolsActions, shallow);
1879
- const { updatePopup } = usePopupsStore((state) => state.popupsActions, shallow);
1880
- const toolTabs = useMemo(() => {
1881
- return [
1882
- {
1883
- id: "geofences",
1884
- iconUrl: `${host_static_assets}/${environment_assets}/frontend/components/map_gpstools/assets/icons/${MAP_GPSTOOLS_ICONS.GEOFENCES}`,
1885
- component: /* @__PURE__ */ jsx(GeofencesList, {}),
1886
- label: getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_TAB_GEO),
1887
- className: gpsToolsClasses.gpsToolsGeofencesList
1888
- }
1889
- ];
1890
- }, [getLabel]);
1891
- useEffect(() => {
1892
- updatePopup(GPS_TOOLS_POPUP_ID, {
1893
- subTitle: currentTabTool === "geofences" ? getLabel(MAP_GPSTOOLS_DICCTIONARY.LABEL_TAB_GEO) : ""
1894
- });
1895
- }, [currentTabTool]);
1896
- useLayers();
1897
- if (status !== "ready") {
1898
- return null;
1899
- }
1900
- return /* @__PURE__ */ jsxs(DivTabGpsToolsRoot, { className: gpsToolsClasses.gpsToolsRoot, children: [
1901
- /* @__PURE__ */ jsx(
1902
- Tabs,
1903
- {
1904
- value: currentTabTool,
1905
- scrollButtons: "auto",
1906
- variant: "scrollable",
1907
- allowScrollButtonsMobile: true,
1908
- onChange: (_e, value) => setCurrentTabTool(value),
1909
- children: toolTabs.map((tab) => /* @__PURE__ */ jsx(
1910
- Tab,
1911
- {
1912
- value: tab.id,
1913
- icon: /* @__PURE__ */ jsx(Icon, { src: tab.iconUrl }),
1914
- className: clsx(gpsToolsClasses.gpsToolsTab, tab.className),
1915
- SKTWidth: "100px",
1916
- SKTHeight: "14px"
1917
- },
1918
- tab.id
1919
- ))
1920
- }
1921
- ),
1922
- toolTabs.map((tab) => {
1923
- const isMatched = tab.id === currentTabTool;
1924
- return /* @__PURE__ */ jsx(
1925
- TabContent,
1926
- {
1927
- className: clsx(
1928
- gpsToolsClasses.gpsToolsTabContent,
1929
- tab.className,
1930
- isMatched ? gpsToolsClasses.visible : gpsToolsClasses.hidden
1931
- ),
1932
- children: tab.component
1933
- },
1934
- tab.id
1935
- );
1936
- })
1937
- ] });
1938
- }
1939
- function MapGpsTools() {
1940
- const isSkeleton = useModuleSkeleton();
1941
- return !isSkeleton && /* @__PURE__ */ jsx(TabsGpsTools, {});
1942
- }
1943
- export {
1944
- GpsToolsProvider as G,
1945
- MapGpsTools as M,
1946
- gpsToolsClasses as g,
1947
- useGpsToolsStore as u
1948
- };