@spokane-folio/security-incident 1.0.28

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 (188) hide show
  1. package/.eslintrc +32 -0
  2. package/.github/workflows/CODEOWNERS +8 -0
  3. package/.github/workflows/pr-validation.yml +44 -0
  4. package/.github/workflows/release.yml +64 -0
  5. package/.prettierrc +6 -0
  6. package/.stripesclirc +4 -0
  7. package/CHANGELOG.md +8 -0
  8. package/CONTRIBUTING.md +4 -0
  9. package/LICENSE +201 -0
  10. package/README.md +16 -0
  11. package/administrator-documentation/roles-and-permissions.md +65 -0
  12. package/administrator-documentation/track-settings-admin-guide-sketch.md +192 -0
  13. package/administrator-documentation/using-the-application.md +192 -0
  14. package/icons/app.png +0 -0
  15. package/icons/app.svg +1 -0
  16. package/icons/playButton.png +0 -0
  17. package/icons/profilePicThumbnail.png +0 -0
  18. package/jest.config.js +10 -0
  19. package/module-descriptor.json +75 -0
  20. package/output/service-worker.js +0 -0
  21. package/package.json +146 -0
  22. package/src/components/incidents/ColumnChooser.js +37 -0
  23. package/src/components/incidents/CreateMedia.js +132 -0
  24. package/src/components/incidents/CreatePane.js +1215 -0
  25. package/src/components/incidents/CreatePane.test.js +138 -0
  26. package/src/components/incidents/CreateReport.js +102 -0
  27. package/src/components/incidents/DetailsPane.js +1267 -0
  28. package/src/components/incidents/DetailsPane.test.js +150 -0
  29. package/src/components/incidents/EditPane.js +2334 -0
  30. package/src/components/incidents/EditPane.test.js +187 -0
  31. package/src/components/incidents/GetDetails.js +55 -0
  32. package/src/components/incidents/GetListDQLinkIncident.js +81 -0
  33. package/src/components/incidents/GetListDynamicQuery.js +66 -0
  34. package/src/components/incidents/GetLocations.js +57 -0
  35. package/src/components/incidents/GetMedia.js +98 -0
  36. package/src/components/incidents/GetName.js +111 -0
  37. package/src/components/incidents/GetNameCreatedBy.js +94 -0
  38. package/src/components/incidents/GetOrgLocaleSettings.js +61 -0
  39. package/src/components/incidents/GetPatronGroups.js +52 -0
  40. package/src/components/incidents/GetSelf.js +65 -0
  41. package/src/components/incidents/GetSummary.js +110 -0
  42. package/src/components/incidents/IncidentTypeCard.js +53 -0
  43. package/src/components/incidents/IncidentTypeCard.test.js +133 -0
  44. package/src/components/incidents/IncidentsPaneset.js +810 -0
  45. package/src/components/incidents/IncidentsPaneset.test.js +128 -0
  46. package/src/components/incidents/LinkedIncident.js +86 -0
  47. package/src/components/incidents/ModalAddMedia.js +262 -0
  48. package/src/components/incidents/ModalAddMedia.test.js +97 -0
  49. package/src/components/incidents/ModalAttentionDecOfService.js +111 -0
  50. package/src/components/incidents/ModalCustomWitness.js +469 -0
  51. package/src/components/incidents/ModalCustomWitness.test.js +147 -0
  52. package/src/components/incidents/ModalCustomerDetails.js +480 -0
  53. package/src/components/incidents/ModalCustomerDetails.test.js +116 -0
  54. package/src/components/incidents/ModalDescribeCustomer.js +361 -0
  55. package/src/components/incidents/ModalDescribeCustomer.test.js +156 -0
  56. package/src/components/incidents/ModalDirtyFormWarn.js +62 -0
  57. package/src/components/incidents/ModalLinkIncident.js +1213 -0
  58. package/src/components/incidents/ModalLinkIncidentStyle.css +32 -0
  59. package/src/components/incidents/ModalSelectIncidentTypes.js +178 -0
  60. package/src/components/incidents/ModalSelectIncidentTypes.test.js +273 -0
  61. package/src/components/incidents/ModalSelectKnownCustomer.js +395 -0
  62. package/src/components/incidents/ModalSelectWitness.js +406 -0
  63. package/src/components/incidents/ModalSelectWitness.test.js +308 -0
  64. package/src/components/incidents/ModalStyle.css +44 -0
  65. package/src/components/incidents/ModalTrespass.js +741 -0
  66. package/src/components/incidents/ModalViewCustomerDetails.js +241 -0
  67. package/src/components/incidents/ModalViewMedia.js +86 -0
  68. package/src/components/incidents/ModalViewTrespass.js +210 -0
  69. package/src/components/incidents/ResultsPane.js +437 -0
  70. package/src/components/incidents/ResultsPane.test.js +120 -0
  71. package/src/components/incidents/SearchCustomerOrWitness.js +108 -0
  72. package/src/components/incidents/Thumbnail.js +72 -0
  73. package/src/components/incidents/ThumbnailMarkRemoval.js +38 -0
  74. package/src/components/incidents/ThumbnailSkeleton.js +30 -0
  75. package/src/components/incidents/ThumbnailStyles.js +49 -0
  76. package/src/components/incidents/ThumbnailTempPreSave.js +71 -0
  77. package/src/components/incidents/UpdateReport.js +84 -0
  78. package/src/components/incidents/__snapshots__/CreatePane.test.js.snap +3 -0
  79. package/src/components/incidents/__snapshots__/DetailsPane.test.js.snap +3 -0
  80. package/src/components/incidents/__snapshots__/EditPane.test.js.snap +3 -0
  81. package/src/components/incidents/__snapshots__/IncidentTypeCard.test.js.snap +3 -0
  82. package/src/components/incidents/__snapshots__/IncidentsPaneset.test.js.snap +3 -0
  83. package/src/components/incidents/__snapshots__/ModalAddMedia.test.js.snap +3 -0
  84. package/src/components/incidents/__snapshots__/ModalCustomerDetails.test.js.snap +3 -0
  85. package/src/components/incidents/__snapshots__/ModalSelectWitness.test.js.snap +3 -0
  86. package/src/components/incidents/__snapshots__/ResultsPane.test.js.snap +3 -0
  87. package/src/components/incidents/helpers/ProfilePicture/ProfilePicture.css +5 -0
  88. package/src/components/incidents/helpers/ProfilePicture/ProfilePicture.js +51 -0
  89. package/src/components/incidents/helpers/ProfilePicture/isAValidURL.js +3 -0
  90. package/src/components/incidents/helpers/ProfilePicture/useProfilePicture.js +127 -0
  91. package/src/components/incidents/helpers/buildQueryString.js +28 -0
  92. package/src/components/incidents/helpers/cleanFormValues.js +53 -0
  93. package/src/components/incidents/helpers/computeEditedCustomers.js +124 -0
  94. package/src/components/incidents/helpers/convertDateIgnoringTZ.js +8 -0
  95. package/src/components/incidents/helpers/convertUTCISOToLocalePrettyTime.js +15 -0
  96. package/src/components/incidents/helpers/convertUTCISOToPrettyDate.js +19 -0
  97. package/src/components/incidents/helpers/decodeParamsToForm.js +20 -0
  98. package/src/components/incidents/helpers/deepNormalizeForComparison.js +39 -0
  99. package/src/components/incidents/helpers/extractFilterString.js +12 -0
  100. package/src/components/incidents/helpers/formatDateAndTimeToUTCISO.js +14 -0
  101. package/src/components/incidents/helpers/formatDateToUTCISO.js +14 -0
  102. package/src/components/incidents/helpers/formatTimeToUTCISO.js +28 -0
  103. package/src/components/incidents/helpers/getCurrentTime.js +20 -0
  104. package/src/components/incidents/helpers/getTodayDate.js +12 -0
  105. package/src/components/incidents/helpers/handlebarsHelpers.js +148 -0
  106. package/src/components/incidents/helpers/hasFormChangedAtCreate.js +50 -0
  107. package/src/components/incidents/helpers/hasTopLevelChangeAffectedDeclaration.js +90 -0
  108. package/src/components/incidents/helpers/hasTopLevelFormChanged.js +111 -0
  109. package/src/components/incidents/helpers/identifyCurrentTrespassDocs.js +109 -0
  110. package/src/components/incidents/helpers/isSameHtml.js +13 -0
  111. package/src/components/incidents/helpers/isValidDateFormat.js +14 -0
  112. package/src/components/incidents/helpers/isValidTimeInput.js +11 -0
  113. package/src/components/incidents/helpers/isValidUTCTimeFormat.js +14 -0
  114. package/src/components/incidents/helpers/parseMMDDYYYY.js +7 -0
  115. package/src/components/incidents/helpers/parseQueryString.js +16 -0
  116. package/src/components/incidents/helpers/sortTrespassDocuments.js +44 -0
  117. package/src/components/incidents/helpers/stripHTML.js +11 -0
  118. package/src/components/incidents/helpers/trespassDocUtils.js +197 -0
  119. package/src/components/incidents/helpers/validateTrespassDetails.js +37 -0
  120. package/src/components/incidents/usePersistedColModalLink.js +70 -0
  121. package/src/components/incidents/usePersistedColumns.js +70 -0
  122. package/src/components/incidents/usePersistedSort.js +23 -0
  123. package/src/components/incidents/usePersistedSortModalLink.js +23 -0
  124. package/src/contexts/IncidentContext.js +433 -0
  125. package/src/index.js +61 -0
  126. package/src/routes/Application.js +13 -0
  127. package/src/settings/GetIncidentCategories.js +56 -0
  128. package/src/settings/GetIncidentTypesDetails.js +88 -0
  129. package/src/settings/GetIncidentTypesIds.js +74 -0
  130. package/src/settings/GetLocationsInService.js +54 -0
  131. package/src/settings/GetSingleCustomLocationDetails.js +60 -0
  132. package/src/settings/GetSingleIncidentTypeDetails.js +60 -0
  133. package/src/settings/GetTrespassReasons.js +67 -0
  134. package/src/settings/GetTrespassTemplates.js +51 -0
  135. package/src/settings/IncidentCategoriesPane.js +285 -0
  136. package/src/settings/IncidentCategoriesPane.test.js +229 -0
  137. package/src/settings/IncidentTypeDetailsPane.js +215 -0
  138. package/src/settings/IncidentTypeDetailsPane.test.js +220 -0
  139. package/src/settings/IncidentTypeEditPane.js +211 -0
  140. package/src/settings/IncidentTypeEditPane.test.js +170 -0
  141. package/src/settings/IncidentTypesPaneset.js +167 -0
  142. package/src/settings/IncidentTypesPaneset.test.js +124 -0
  143. package/src/settings/LocationInServiceEditPane.js +320 -0
  144. package/src/settings/LocationsPaneset.js +415 -0
  145. package/src/settings/LocationsPaneset.test.js +106 -0
  146. package/src/settings/ModalDeleteCategory.js +47 -0
  147. package/src/settings/ModalDeleteIncidentType.js +49 -0
  148. package/src/settings/ModalDeleteLocationInService.js +49 -0
  149. package/src/settings/ModalDeleteTrespassReason.js +49 -0
  150. package/src/settings/ModalPreviewTrespassDoc.js +65 -0
  151. package/src/settings/ModalTrespassDocTokens.js +83 -0
  152. package/src/settings/NewIncidentTypePane.js +182 -0
  153. package/src/settings/PutIncidentType.js +60 -0
  154. package/src/settings/PutLocationsInService.js +52 -0
  155. package/src/settings/PutTrespassReasons.js +61 -0
  156. package/src/settings/PutTrespassTemplate.js +50 -0
  157. package/src/settings/TrespassDoc.css +17 -0
  158. package/src/settings/TrespassDocDetailsPane.js +215 -0
  159. package/src/settings/TrespassDocEditPane.js +538 -0
  160. package/src/settings/TrespassDocPaneset.js +581 -0
  161. package/src/settings/TrespassReasonDetailsPane.js +171 -0
  162. package/src/settings/TrespassReasonEditPane.js +221 -0
  163. package/src/settings/TrespassReasonsPaneset.js +282 -0
  164. package/src/settings/__snapshots__/IncidentCategoriesPane.test.js.snap +3 -0
  165. package/src/settings/__snapshots__/IncidentTypeDetailsPane.test.js.snap +3 -0
  166. package/src/settings/__snapshots__/IncidentTypeEditPane.test.js.snap +3 -0
  167. package/src/settings/__snapshots__/IncidentTypesPaneset.test.js.snap +3 -0
  168. package/src/settings/__snapshots__/LocationsPaneset.test.js.snap +3 -0
  169. package/src/settings/data/exampleJSON.json +92 -0
  170. package/src/settings/data/templateTokens.js +396 -0
  171. package/src/settings/helpers/alphabetize.js +18 -0
  172. package/src/settings/helpers/getCategoryTitleById.js +13 -0
  173. package/src/settings/helpers/makeId.js +15 -0
  174. package/src/settings/index.js +48 -0
  175. package/stripes.config.js +10 -0
  176. package/test/jest/__mock__/index.js +8 -0
  177. package/test/jest/__mock__/intl.mock.js +27 -0
  178. package/test/jest/__mock__/stripes.mock.js +26 -0
  179. package/test/jest/__mock__/stripesComponents.mock.js +151 -0
  180. package/test/jest/__mock__/stripesConfig.mock.js +1 -0
  181. package/test/jest/__mock__/stripesCore.mock.js +9 -0
  182. package/test/jest/__mock__/stripesIcon.mock.js +5 -0
  183. package/test/jest/__mock__/stripesSmartComponents.mock.js +7 -0
  184. package/test/jest/__mock__/stripesUtils.mock.js +3 -0
  185. package/test/jest/eslintrc.js +12 -0
  186. package/test/jest/setupFiles.js +5 -0
  187. package/translations/ui-security-incident/en_US.json +542 -0
  188. package/ui-module-acceptance-criteria.md +34 -0
@@ -0,0 +1,70 @@
1
+ import React, { useState, useCallback, useEffect } from 'react';
2
+
3
+ export const STORAGE_KEY = 'ui-secinci-visible-columns';
4
+
5
+ export default function usePersistedColumns(possibleColumns) {
6
+ // walk through the canonical list and retain only the columns that are currently visible, in their canonical order
7
+ const reorderToCanonical = (columns, canonicalOrder) =>
8
+ canonicalOrder.filter(col => columns.includes(col));
9
+
10
+ const [visibleColumns, setVisibleColumns] = useState(() => {
11
+ // load from sessionStorage
12
+ const stored = sessionStorage.getItem(STORAGE_KEY);
13
+
14
+ try {
15
+ const parsed = JSON.parse(stored);
16
+ // keep only valid column IDs
17
+ const filtered = Array.isArray(parsed) && parsed.length
18
+ ? parsed.filter(col => possibleColumns.includes(col))
19
+ : possibleColumns;
20
+
21
+ // initialize with canon
22
+ return reorderToCanonical(filtered, possibleColumns);
23
+ } catch {
24
+ return possibleColumns;
25
+ }
26
+ });
27
+
28
+ // sync visibleColumns from sessionStorage on each mount/render
29
+ useEffect(() => {
30
+ const stored = sessionStorage.getItem(STORAGE_KEY);
31
+
32
+ try {
33
+ const parsed = JSON.parse(stored);
34
+ const filtered = Array.isArray(parsed) && parsed.length
35
+ ? parsed.filter(col => possibleColumns.includes(col))
36
+ : possibleColumns;
37
+
38
+ const canonical = reorderToCanonical(filtered, possibleColumns);
39
+ setVisibleColumns((current) => {
40
+ const joined = (arr) => arr.join('|');
41
+ return joined(current) === joined(canonical) ? current : canonical;
42
+ });
43
+ } catch {
44
+ setVisibleColumns(possibleColumns);
45
+ }
46
+ }, [possibleColumns]);
47
+
48
+ const toggleColumn = useCallback((colId) => {
49
+ setVisibleColumns(prev => {
50
+ const isRemoving = prev.includes(colId);
51
+ // const isLastOne = prev.length === 1;
52
+
53
+ // if (isRemoving && isLastOne) {
54
+ // return prev;
55
+ // }
56
+
57
+ let next = isRemoving
58
+ ? prev.filter(c => c !== colId)
59
+ : [...prev, colId];
60
+
61
+ // return enforced canonical order after every toggle, regardless of toggle sequence
62
+ next = reorderToCanonical(next, possibleColumns);
63
+
64
+ sessionStorage.setItem(STORAGE_KEY, JSON.stringify(next));
65
+ return next;
66
+ });
67
+ }, [possibleColumns]);
68
+
69
+ return [visibleColumns, toggleColumn];
70
+ }
@@ -0,0 +1,23 @@
1
+ import { useState } from 'react';
2
+
3
+ export default function usePersistedSort() {
4
+ const [sortColumn, setCol] = useState('');
5
+ const [sortDirection, setDir] = useState('asc');
6
+
7
+ const toggleSort = (col) => {
8
+ if (col === sortColumn) {
9
+ setDir(d => (d === 'asc' ? 'desc' : 'asc'));
10
+ } else {
11
+ setCol(col);
12
+ setDir('asc');
13
+ }
14
+ };
15
+
16
+ return {
17
+ sortColumn,
18
+ sortDirection,
19
+ toggleSort,
20
+ setSortColumn : setCol,
21
+ setSortDirection : setDir
22
+ };
23
+ }
@@ -0,0 +1,23 @@
1
+ import { useState } from 'react';
2
+
3
+ export default function usePersistedSortModalLink() {
4
+ const [sortColumn, setCol] = useState('');
5
+ const [sortDirection, setDir] = useState('asc');
6
+
7
+ const toggleSort = (col) => {
8
+ if (col === sortColumn) {
9
+ setDir(d => (d === 'asc' ? 'desc' : 'asc'));
10
+ } else {
11
+ setCol(col);
12
+ setDir('asc');
13
+ }
14
+ };
15
+
16
+ return {
17
+ sortColumn,
18
+ sortDirection,
19
+ toggleSort,
20
+ setSortColumn : setCol,
21
+ setSortDirection : setDir
22
+ };
23
+ }
@@ -0,0 +1,433 @@
1
+
2
+ import React, { createContext, useState, useContext, useEffect } from 'react';
3
+ // export for class components
4
+ export const IncidentContext = createContext();
5
+ // export for function components
6
+ export const useIncidents = () => useContext(IncidentContext);
7
+
8
+ export const IncidentProvider = ({ children }) => {
9
+ // data
10
+ const [incidentsList, setIncidentsList] = useState([]);
11
+ const [singleIncident, setSingleIncident] = useState({});
12
+ const [incidentTypesList, setIncidentTypesList] = useState([])
13
+ const [incidentTypesNamesIdsList, setIncidentTypesNamesIdsList] = useState([]);
14
+ const [locations, setLocations] = useState([]);
15
+ const [customers, setCustomers] = useState([]);
16
+ const [self, setSelf] = useState({})
17
+ const [selectedCustomers, setSelectedCustomers] = useState([]);
18
+ const [selectedWitnesses, setSelectedWitnesses] = useState([]);
19
+ const [selectedTrespassWitnesses, setSelectedTrespassWitnesses] = useState([]);
20
+ const [describedCustomers, setDescribedCustomers] = useState([]);
21
+ const [attachmentsData, setAttachmentsData] = useState([]);
22
+ const [idForMediaCreate, setIdForMediaCreate] = useState(null);
23
+ const [formDataArrayForMediaCreate, setFormDataArrayForMediaCreate] = useState(null);
24
+ const [modalErrorContent, setModalErrorContent] = useState("");
25
+ const [locationsInService, setLocationsInService] = useState([]);
26
+ const [incidentCategories, setIncidentCategories] = useState([]);
27
+ const [trespassTemplates, setTrespassTemplates] = useState([]);
28
+ const [trespassReasons, setTrespassReasons] = useState([]);
29
+ const [organizationTimezone, setOrganizationTimezone] = useState('');
30
+
31
+ // toggle
32
+ const [isDetailsPaneOpen, setIsDetailsPaneOpen] = useState(false);
33
+ const [isEditPaneOpen, setIsEditPaneOpen] = useState(false);
34
+ const [isCreatePaneOpen, setIsCreatePaneOpen] = useState(false);
35
+ const [isModalSelectTypesOpen, setIsModalSelectTypesOpen] = useState(false);
36
+ const [isModalUnknownCustOpen, setIsModalUnknownCustOpen] = useState(false);
37
+ const [isModalSelectKnownCustOpen, setIsModalSelectKnownCustOpen] = useState(false);
38
+ const [isModalSelectWitness, setIsModalSelectWitness] = useState(false);
39
+ const [isModalDeleteDescCustOpen, setIsModalDeleteDescCustOpen] = useState(false);
40
+ const [isModalCustomerDetails, setIsModalCustomerDetails] = useState(false);
41
+ const [isModalViewCustomerDetails, setIsModalViewCustomerDetails] = useState(false);
42
+ const [isModalTrespass, setIsModalTrespass] = useState(false);
43
+ const [isModalViewTrespass, setIsModalViewTrespass] = useState(false);
44
+ const [isModalMedia, setIsModalMedia] = useState(false);
45
+ const [isModalViewImage, setIsModalViewImage] = useState(false);
46
+ const [isModalViewDocument, setIsModalViewDocument] = useState(false);
47
+ const [isModalCustomWitness, setIsModalCustomWitness] = useState(false);
48
+ const [isLoadingSearch, setIsLoadingSearch] = useState(false);
49
+ const [isLoadingDetails, setIsLoadingDetails] = useState(false);
50
+ const [showModalError, setShowModalError] = useState(false);
51
+ const [isImageArrayLoading, setIsImageArrayLoading] = useState(false);
52
+ const [isUpdatingReport, setIsUpdatingReport] = useState(false);
53
+ const [isCreatingReport, setIsCreatingReport] = useState(false);
54
+
55
+ // nav
56
+ const [mode, setMode] = useState('');
57
+ const [recentInstanceId, setRecentInstanceId] = useState('');
58
+
59
+ // query
60
+ const [limit, setLimit] = useState(20); //limit value for query params, pagination
61
+ const [offset, setOffset] = useState(0);//offset value for query params, pagination
62
+ const [totalResults, setTotalResults] = useState(0);//value of response total records
63
+ const [appliedSearchParams, setAppliedSearchParams] = useState(null); // stable, cleaned fields for local persist
64
+ const [queryString, setQueryString] = useState("");// value passed to <GetListByDynamicQuery/>
65
+
66
+
67
+ // TODO remove useGetList
68
+ const [useGetList, setUseGetList] = useState(false);//boolean to run <GetListByDynamicQuery/>
69
+
70
+
71
+ // useEffect(() => {
72
+ // console.log("@IncidentContext - offset --> ", offset)
73
+ // }, [offset]);
74
+
75
+ // document error
76
+ const [documentError, setDocumentError] = useState(false);
77
+ const [documentErrorMessage, setDocumentErrorMessage] = useState([]);
78
+
79
+ const triggerDocumentError = (message) => {
80
+ setDocumentError(true);
81
+ setDocumentErrorMessage((prev) => [...prev, message])
82
+ };
83
+
84
+ const clearDocumentError = () => {
85
+ setDocumentError(false);
86
+ setDocumentErrorMessage([]);
87
+ };
88
+
89
+ const updateSingleIncident = (incident) => {
90
+ setSingleIncident(incident);
91
+ };
92
+
93
+ const openDetailsPane = () => {
94
+ setIsDetailsPaneOpen(true);
95
+ };
96
+
97
+ const closeDetailsPane = () => {
98
+ setIsDetailsPaneOpen(false);
99
+ };
100
+
101
+ const openEditPane = () => {
102
+ setIsEditPaneOpen(true)
103
+ };
104
+
105
+ const closeEditPane = () => {
106
+ setIsEditPaneOpen(false)
107
+ };
108
+
109
+ const openCreatePane = () => {
110
+ setIsCreatePaneOpen(true)
111
+ };
112
+
113
+ const closeCreatePane = () => {
114
+ setIsCreatePaneOpen(false)
115
+ };
116
+
117
+ const openModalSelectTypes = () => {
118
+ setIsModalSelectTypesOpen(true)
119
+ };
120
+
121
+ const closeModalSelectTypes = () => {
122
+ setIsModalSelectTypesOpen(false)
123
+ };
124
+
125
+ const openModalUnknownCust = () => {
126
+ setIsModalUnknownCustOpen(true)
127
+ };
128
+
129
+ const closeModalUnknownCust = () => {
130
+ setIsModalUnknownCustOpen(false)
131
+ };
132
+
133
+ const openModalSelectKnownCust = () => {
134
+ setIsModalSelectKnownCustOpen(true)
135
+ };
136
+
137
+ const closeModalSelectKnownCust = () => {
138
+ setIsModalSelectKnownCustOpen(false)
139
+ };
140
+
141
+ const openModalSelectWitness = () => {
142
+ setIsModalSelectWitness(true)
143
+ };
144
+
145
+ const closeModalSelectWitness = () => {
146
+ setIsModalSelectWitness(false)
147
+ };
148
+
149
+ const openModalDeleteDescCustOpen = () => {
150
+ setIsModalDeleteDescCustOpen(true)
151
+ };
152
+
153
+ const closeModalDeleteDescCustOpen = () => {
154
+ setIsModalDeleteDescCustOpen(false)
155
+ };
156
+
157
+ const openModalCustomerDetails = () => {
158
+ setIsModalCustomerDetails(true)
159
+ };
160
+
161
+ const closeModalCustomerDetails = () => {
162
+ setIsModalCustomerDetails(false)
163
+ };
164
+
165
+ const openModalViewCustomerDetails = () => {
166
+ setIsModalViewCustomerDetails(true)
167
+ };
168
+
169
+ const closeModalViewCustomerDetails = () => {
170
+ setIsModalViewCustomerDetails(false)
171
+ };
172
+
173
+ const openModalTrespass = () => {
174
+ setIsModalTrespass(true)
175
+ };
176
+
177
+ const closeModalTrespass = () => {
178
+ setIsModalTrespass(false)
179
+ };
180
+
181
+ const openModalMedia = () => {
182
+ setIsModalMedia(true)
183
+ };
184
+
185
+ const closeModalMedia = () => {
186
+ setIsModalMedia(false)
187
+ };
188
+
189
+ const openModalViewImage = () => {
190
+ setIsModalViewImage(true)
191
+ };
192
+
193
+ const closeModalViewImage = () => {
194
+ setIsModalViewImage(false)
195
+ };
196
+
197
+ const openModelViewDocument = () => {
198
+ setIsModalViewDocument(true)
199
+ };
200
+
201
+ const closeModalViewDocument = () => {
202
+ setIsModalViewDocument(false)
203
+ };
204
+
205
+
206
+ const openModalCustomWitness= () => {
207
+ setIsModalCustomWitness(true)
208
+ };
209
+
210
+ const closeModalCustomWitness = () => {
211
+ setIsModalCustomWitness(false)
212
+ };
213
+
214
+ const openModelViewTrespass = () => {
215
+ setIsModalViewTrespass(true)
216
+ };
217
+
218
+ const closeModalViewTrespass = () => {
219
+ setIsModalViewTrespass(false)
220
+ };
221
+
222
+ const openModalError = () => {
223
+ setShowModalError(true)
224
+ };
225
+
226
+ const closeModalError = () => {
227
+ setShowModalError(false)
228
+ };
229
+
230
+ const openImageSkeleton = () => {
231
+ setIsImageArrayLoading(true)
232
+ };
233
+
234
+ const closeImageSkeleton = () => {
235
+ setIsImageArrayLoading(false)
236
+ };
237
+
238
+ const openLoadingSearch = () => {
239
+ setIsLoadingSearch(true)
240
+ };
241
+
242
+ const closeLoadingSearch = () => {
243
+ setIsLoadingSearch(false)
244
+ };
245
+
246
+ const openLoadingDetails = () => {
247
+ setIsLoadingDetails(true)
248
+ };
249
+
250
+ const closeLoadingDetails = () => {
251
+ setIsLoadingDetails(false)
252
+ };
253
+
254
+ return (
255
+ <IncidentContext.Provider value={{
256
+ // data
257
+ incidentsList,
258
+ setIncidentsList,
259
+
260
+ singleIncident,
261
+ setSingleIncident,
262
+
263
+ incidentTypesList,
264
+ setIncidentTypesList,
265
+
266
+ incidentTypesNamesIdsList,
267
+ setIncidentTypesNamesIdsList,
268
+
269
+ locations,
270
+ setLocations,
271
+
272
+ customers,
273
+ setCustomers,
274
+
275
+ self,
276
+ setSelf,
277
+
278
+ selectedCustomers,
279
+ setSelectedCustomers,
280
+
281
+ selectedWitnesses,
282
+ setSelectedWitnesses,
283
+
284
+ selectedTrespassWitnesses,
285
+ setSelectedTrespassWitnesses,
286
+
287
+ describedCustomers,
288
+ setDescribedCustomers,
289
+
290
+ attachmentsData,
291
+ setAttachmentsData,
292
+
293
+ idForMediaCreate,
294
+ setIdForMediaCreate,
295
+
296
+ formDataArrayForMediaCreate,
297
+ setFormDataArrayForMediaCreate,
298
+
299
+ modalErrorContent,
300
+ setModalErrorContent,
301
+
302
+ locationsInService,
303
+ setLocationsInService,
304
+
305
+ incidentCategories,
306
+ setIncidentCategories,
307
+
308
+ trespassTemplates,
309
+ setTrespassTemplates,
310
+
311
+ trespassReasons,
312
+ setTrespassReasons,
313
+
314
+ organizationTimezone,
315
+ setOrganizationTimezone,
316
+
317
+ // togglers
318
+ isDetailsPaneOpen,
319
+ openDetailsPane,
320
+ closeDetailsPane,
321
+
322
+ isEditPaneOpen,
323
+ openEditPane,
324
+ closeEditPane,
325
+
326
+ isCreatePaneOpen,
327
+ openCreatePane,
328
+ closeCreatePane,
329
+
330
+ isModalSelectTypesOpen,
331
+ openModalSelectTypes,
332
+ closeModalSelectTypes,
333
+
334
+ isModalUnknownCustOpen,
335
+ openModalUnknownCust,
336
+ closeModalUnknownCust,
337
+
338
+ isModalSelectKnownCustOpen,
339
+ openModalSelectKnownCust,
340
+ closeModalSelectKnownCust,
341
+
342
+ isModalSelectWitness,
343
+ openModalSelectWitness,
344
+ closeModalSelectWitness,
345
+
346
+ isModalDeleteDescCustOpen,
347
+ openModalDeleteDescCustOpen,
348
+ closeModalDeleteDescCustOpen,
349
+
350
+ isModalTrespass,
351
+ openModalTrespass,
352
+ closeModalTrespass,
353
+
354
+ isModalViewTrespass,
355
+ openModelViewTrespass,
356
+ closeModalViewTrespass,
357
+
358
+ isModalCustomerDetails,
359
+ openModalCustomerDetails,
360
+ closeModalCustomerDetails,
361
+
362
+ isModalViewCustomerDetails,
363
+ openModalViewCustomerDetails,
364
+ closeModalViewCustomerDetails,
365
+
366
+ isModalMedia,
367
+ openModalMedia,
368
+ closeModalMedia,
369
+
370
+ isModalViewImage,
371
+ openModalViewImage,
372
+ closeModalViewImage,
373
+
374
+ isModalViewDocument,
375
+ openModelViewDocument,
376
+ closeModalViewDocument,
377
+
378
+ isModalCustomWitness,
379
+ openModalCustomWitness,
380
+ closeModalCustomWitness,
381
+
382
+ showModalError,
383
+ openModalError,
384
+ closeModalError,
385
+
386
+ isImageArrayLoading,
387
+ openImageSkeleton,
388
+ closeImageSkeleton,
389
+
390
+ isUpdatingReport,
391
+ setIsUpdatingReport,
392
+
393
+ isCreatingReport,
394
+ setIsCreatingReport,
395
+
396
+
397
+ isLoadingSearch,
398
+ openLoadingSearch,
399
+ closeLoadingSearch,
400
+
401
+ isLoadingDetails,
402
+ setIsLoadingDetails,
403
+ openLoadingDetails,
404
+ closeLoadingDetails,
405
+
406
+ useGetList,
407
+ setUseGetList,
408
+
409
+ // nav
410
+ mode,
411
+ setMode,
412
+
413
+ queryString,
414
+ setQueryString,
415
+
416
+ limit, setLimit,
417
+ offset, setOffset,
418
+ totalResults, setTotalResults,
419
+ appliedSearchParams, setAppliedSearchParams,
420
+
421
+ // document error
422
+ documentError, setDocumentError,
423
+ documentErrorMessage, setDocumentErrorMessage,
424
+ triggerDocumentError,
425
+ clearDocumentError,
426
+
427
+ recentInstanceId,
428
+ setRecentInstanceId
429
+ }}>
430
+ {children}
431
+ </IncidentContext.Provider>
432
+ )
433
+ };
package/src/index.js ADDED
@@ -0,0 +1,61 @@
1
+ import 'core-js/stable';
2
+ import 'regenerator-runtime/runtime';
3
+ import React from 'react';
4
+ import { IntlProvider } from 'react-intl';
5
+ import PropTypes from 'prop-types';
6
+ import { Switch, Route } from 'react-router-dom';
7
+ import enUStranslations from '../translations/ui-security-incident/en_US';
8
+ import Settings from './settings';
9
+ import Application from './routes/Application';
10
+ import CreatePane from './components/incidents/CreatePane';
11
+ import DetailsPane from './components/incidents/DetailsPane';
12
+ import EditPane from './components/incidents/EditPane';
13
+ import { IncidentProvider } from './contexts/IncidentContext';
14
+ class SecurityIncident extends React.Component {
15
+ static propTypes = {
16
+ match: PropTypes.object.isRequired,
17
+ showSettings: PropTypes.bool,
18
+ stripes: PropTypes.shape({
19
+ connect: PropTypes.func,
20
+ }),
21
+ };
22
+
23
+ render() {
24
+ const {
25
+ showSettings,
26
+ match: { path },
27
+ stripes,
28
+ } = this.props;
29
+
30
+ if (showSettings) {
31
+ return (
32
+ <IntlProvider
33
+ locale="en"
34
+ messages={enUStranslations}
35
+ >
36
+ <IncidentProvider>
37
+ <Settings {...this.props} />
38
+ </IncidentProvider>
39
+ </IntlProvider>
40
+ );
41
+ }
42
+
43
+ return (
44
+ <IntlProvider
45
+ locale="en"
46
+ messages={enUStranslations}
47
+ >
48
+ <IncidentProvider>
49
+ <Switch>
50
+ <Route path={path} exact component={Application} />
51
+ <Route path={`${path}/create`} exact component={CreatePane} />
52
+ <Route path={`${path}/:id`} exact component={DetailsPane} />
53
+ <Route path={`${path}/:id/edit`} exact component={EditPane} />
54
+ </Switch>
55
+ </IncidentProvider>
56
+ </IntlProvider>
57
+ );
58
+ }
59
+ }
60
+
61
+ export default SecurityIncident;
@@ -0,0 +1,13 @@
1
+
2
+ import React from 'react';
3
+ import IncidentsPaneset from '../components/incidents/IncidentsPaneset.js';
4
+
5
+ const Application = () => {
6
+ return (
7
+ <>
8
+ <IncidentsPaneset />
9
+ </>
10
+ );
11
+ };
12
+
13
+ export default Application;
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { stripesConnect } from '@folio/stripes/core';
4
+ import { IncidentContext } from '../contexts/IncidentContext';
5
+
6
+ class GetIncidentCategories extends React.Component {
7
+ static contextType = IncidentContext;
8
+ static manifest = Object.freeze({
9
+ incidentCategories: {
10
+ type: 'okapi',
11
+ path: 'incidents/configurations/incident-categories',
12
+ records: 'data.value.categories',
13
+ throwErrors: false // prevent error modal if empty on first pass
14
+ },
15
+ });
16
+
17
+ static propTypes = {
18
+ resources: PropTypes.object.isRequired,
19
+ handleFetchedCategories: PropTypes.func,
20
+ };
21
+
22
+ componentDidMount() {
23
+ this.fetchRecords();
24
+ };
25
+
26
+ componentDidUpdate(prevProps) {
27
+ const resourceChanged =
28
+ this.props.resources.incidentCategories !==
29
+ prevProps.resources.incidentCategories;
30
+
31
+ if (resourceChanged) {
32
+ this.fetchRecords();
33
+ };
34
+ };
35
+
36
+ fetchRecords = () => {
37
+ const incidentCategoriesBody = this.props.resources.incidentCategories;
38
+ // console.log("incidentCategoriesBody --> ", JSON.stringify(incidentCategoriesBody, null, 2));
39
+
40
+ if (!incidentCategoriesBody?.hasLoaded) return;
41
+
42
+ const categories = incidentCategoriesBody?.records;
43
+ this.context.setIncidentCategories(categories)
44
+ };
45
+
46
+ render() {
47
+ return null;
48
+ };
49
+ };
50
+
51
+ GetIncidentCategories.contextType = IncidentContext;
52
+
53
+ export default stripesConnect(
54
+ GetIncidentCategories,
55
+ '@spokane-folio/security-incident'
56
+ );