@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,49 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import { Button, Modal, ModalFooter } from '@folio/stripes/components';
5
+
6
+ const ModalDeleteTrespassReason = ({ isOpen, onClose, onConfirm }) => {
7
+ if (!isOpen) {
8
+ return null;
9
+ }
10
+
11
+ const footer = (
12
+ <ModalFooter>
13
+ <Button onClick={onConfirm} buttonStyle="warning">
14
+ <FormattedMessage id="delete-button"/>
15
+ </Button>
16
+ <Button onClick={onClose}>
17
+ <FormattedMessage id="cancel-button"/>
18
+ </Button>
19
+ </ModalFooter>
20
+ );
21
+
22
+ return (
23
+ <Modal
24
+ open={isOpen}
25
+ dismissible
26
+ closeOnBackgroundClick
27
+ label={
28
+ <FormattedMessage id="settings.trespass-reason-modal-delete-label" />
29
+ }
30
+ size="small"
31
+ onClose={onClose}
32
+ footer={footer}
33
+ >
34
+ <section>
35
+ <p>
36
+ <FormattedMessage id="settings.trespass-reason-delete-warn" />
37
+ </p>
38
+ </section>
39
+ </Modal>
40
+ );
41
+ };
42
+
43
+ ModalDeleteTrespassReason.propTypes = {
44
+ isOpen: PropTypes.func.isRequired,
45
+ onClose: PropTypes.func.isRequired,
46
+ onConfirm: PropTypes.func.isRequired,
47
+ };
48
+
49
+ export default ModalDeleteTrespassReason;
@@ -0,0 +1,65 @@
1
+
2
+ import React, { useState, useEffect } from 'react';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import {
5
+ Button,
6
+ Checkbox,
7
+ Col,
8
+ Modal,
9
+ ModalFooter,
10
+ Pane,
11
+ PaneHeader,
12
+ Paneset,
13
+ Row,
14
+ TextField,
15
+ TextArea
16
+ } from '@folio/stripes/components';
17
+
18
+ const ModalPreviewTrespassDoc = ({
19
+ closePreviewModal,
20
+ previewContent
21
+ }) => {
22
+
23
+ const footer = (
24
+ <ModalFooter>
25
+ <Button
26
+ onClick={closePreviewModal}
27
+ buttonStyle="primary"
28
+ marginBottom0
29
+ >
30
+ <FormattedMessage id="close-button"/>
31
+ </Button>
32
+ </ModalFooter>
33
+ );
34
+
35
+ return (
36
+ <Modal
37
+ style={{
38
+ minHeight: '250px',
39
+ height: '80%', // allows modal to grow/shrink based on content
40
+ maxHeight: '300vh',
41
+ maxWidth: '300vw', // modal width responsive to viewport width
42
+ width: '70%' // modal width adjusts based on content and window size
43
+ }}
44
+ open
45
+ dismissible
46
+ closeOnBackgroundClick
47
+ label='Preview trespass template document'
48
+ size='large'
49
+ onClose={closePreviewModal}
50
+ footer={footer}
51
+ >
52
+ <div
53
+ style={{
54
+ padding: '1em',
55
+ maxHeight: 'calc(80vh - 100px)', // Adjust based on modal header/footer height
56
+ overflowY: 'auto',
57
+ whiteSpace: 'pre-wrap'
58
+ }}
59
+ dangerouslySetInnerHTML={{ __html: previewContent }}>
60
+ </div>
61
+ </Modal>
62
+ );
63
+ };
64
+
65
+ export default ModalPreviewTrespassDoc;
@@ -0,0 +1,83 @@
1
+
2
+ import React, { useState, useEffect } from 'react';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import {
5
+ Button,
6
+ Checkbox,
7
+ Col,
8
+ Modal,
9
+ ModalFooter,
10
+ Row,
11
+ } from '@folio/stripes/components';
12
+
13
+ const ModalTrespassDocTokens = ({
14
+ setShowTokensModal,
15
+ selectedTokens, setSelectedTokens,
16
+ handleInsertTokens, tokensArray
17
+ }) => {
18
+
19
+ const handleCloseDismiss = () => {
20
+ setShowTokensModal(false);
21
+ setSelectedTokens([])
22
+ };
23
+
24
+ const handleCheckboxChange = (tokenValue, isChecked) => {
25
+ if (isChecked) {
26
+ setSelectedTokens((prev) => [...prev, tokenValue])
27
+ } else {
28
+ setSelectedTokens((prev) => prev.filter((val) => val !== tokenValue))
29
+ }
30
+ };
31
+
32
+ const handleInsertClick = () => {
33
+ handleInsertTokens(selectedTokens)
34
+ };
35
+
36
+ const footer = (
37
+ <ModalFooter>
38
+ <Button
39
+ onClick={handleInsertClick}
40
+ buttonStyle="primary"
41
+ marginBottom0
42
+ >
43
+ <FormattedMessage id="settings.trespass-document-template.insert-selected-tokens"/>
44
+ </Button>
45
+ </ModalFooter>
46
+ );
47
+
48
+ return (
49
+ <Modal
50
+ style={{
51
+ minHeight: '250px',
52
+ height: '80%', // allows modal to grow/shrink based on content
53
+ maxHeight: '300vh',
54
+ maxWidth: '300vw', // modal width responsive to viewport width
55
+ width: '70%' // modal width adjusts based on content and window size
56
+ }}
57
+ open
58
+ dismissible
59
+ closeOnBackgroundClick
60
+ label='Tokens'
61
+ size='large'
62
+ onClose={handleCloseDismiss}
63
+ footer={footer}
64
+ >
65
+ <Row>
66
+ <Col>
67
+ {tokensArray.map((token) => (
68
+ <Checkbox
69
+ key={token.value}
70
+ label={token.label}
71
+ checked={selectedTokens.includes(token.value)}
72
+ value={token.value}
73
+ onChange={(e) => handleCheckboxChange(token.value, e.target.checked)}
74
+ />
75
+ ))}
76
+ </Col>
77
+ </Row>
78
+
79
+ </Modal>
80
+ );
81
+ };
82
+
83
+ export default ModalTrespassDocTokens;
@@ -0,0 +1,182 @@
1
+ import React, { useState, useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { FormattedMessage } from 'react-intl';
4
+ import {
5
+ Accordion,
6
+ AccordionSet,
7
+ Button,
8
+ Col,
9
+ Pane,
10
+ PaneHeader,
11
+ PaneFooter,
12
+ Row,
13
+ Select,
14
+ TextArea,
15
+ TextField,
16
+ } from '@folio/stripes/components';
17
+ import GetIncidentTypesDetails from './GetIncidentTypesDetails';
18
+ import GetIncidentCategories from './GetIncidentCategories';
19
+ import PutIncidentType from './PutIncidentType';
20
+ import makeId from './helpers/makeId';
21
+ import { useIncidents } from '../contexts/IncidentContext';
22
+
23
+ const NewIncidentTypePane = ({ handleCloseNew, ...props }) => {
24
+
25
+ const { incidentCategories } = useIncidents();
26
+ const [allIncidentTypes, setAllIncidentTypes] = useState([]);
27
+ const [formattedData, setFormattedData] = useState(null);
28
+ const [formData, setFormData] = useState({
29
+ title: '',
30
+ category_id: '',
31
+ description: '',
32
+ });
33
+
34
+ const handleIncidentTypes = (data) => {
35
+ setAllIncidentTypes(data);
36
+ };
37
+
38
+ const dataOptions = incidentCategories.map((category) => ({
39
+ value: category.id,
40
+ label: category.title,
41
+ }));
42
+
43
+ const handleChange = (e) => {
44
+ const { name, value } = e.target;
45
+ setFormData((prev) => ({
46
+ ...prev,
47
+ [name]: value,
48
+ }));
49
+ };
50
+
51
+ const isFormDataPresent = () => {
52
+ return formData.title && formData.category_id && formData.description;
53
+ };
54
+
55
+ const handleSubmit = (e) => {
56
+ if (e) e.preventDefault();
57
+ const newIncidentType = {
58
+ ...formData,
59
+ id: makeId(formData.title),
60
+ };
61
+ const updatedIncidentTypes = [...allIncidentTypes, newIncidentType];
62
+
63
+ const formattedReadyData = {
64
+ data: {
65
+ value: {
66
+ incidentTypes: updatedIncidentTypes
67
+ }
68
+ }
69
+ };
70
+ setFormattedData(formattedReadyData);
71
+ };
72
+
73
+ const renderHeader = (renderProps) => (
74
+ <PaneHeader
75
+ {...renderProps}
76
+ dismissible
77
+ paneTitle={
78
+ <FormattedMessage id="settings.incident-types.new.paneTitle" />
79
+ }
80
+ onClose={handleCloseNew}
81
+ />
82
+ );
83
+
84
+ const footer = (
85
+ <PaneFooter
86
+ renderStart={
87
+ <Button onClick={handleCloseNew}>
88
+ <FormattedMessage id="cancel-button" />
89
+ </Button>
90
+ }
91
+ renderEnd={
92
+ <Button
93
+ buttonStyle="primary"
94
+ onClick={handleSubmit}
95
+ disabled={!isFormDataPresent()}
96
+ >
97
+ <FormattedMessage id="save-and-close-button" />
98
+ </Button>
99
+ }
100
+ />
101
+ );
102
+
103
+ return (
104
+ <Pane defaultWidth="100%" renderHeader={renderHeader} footer={footer}>
105
+
106
+ <GetIncidentCategories />
107
+
108
+ <GetIncidentTypesDetails
109
+ context="settings"
110
+ handleIncidentTypes={handleIncidentTypes}
111
+ />
112
+ {formattedData && (
113
+ <PutIncidentType
114
+ data={formattedData}
115
+ context="new"
116
+ handleCloseNew={handleCloseNew}
117
+ />
118
+ )}
119
+
120
+ <AccordionSet>
121
+ <Accordion
122
+ label={
123
+ <FormattedMessage id="settings.incident-types.new.type-info-accordion-label" />
124
+ }
125
+ >
126
+ <Row>
127
+ <Col xs={8}>
128
+ <Col>
129
+ <TextField
130
+ required
131
+ label={
132
+ <FormattedMessage id="settings.incident-types.new.title-text-field-label" />
133
+ }
134
+ name="title"
135
+ value={formData.title}
136
+ onChange={handleChange}
137
+ />
138
+ </Col>
139
+ </Col>
140
+ </Row>
141
+ <Row>
142
+ <Col xs={4}>
143
+ <Col>
144
+ <Select
145
+ required
146
+ label={
147
+ <FormattedMessage id="settings.incident-types.new.category-select-label" />
148
+ }
149
+ name="category_id"
150
+ value={formData.category_id}
151
+ placeholder="Select a category"
152
+ dataOptions={dataOptions}
153
+ onChange={handleChange}
154
+ />
155
+ </Col>
156
+ </Col>
157
+ </Row>
158
+ <Row>
159
+ <Col xs={6}>
160
+ <TextArea
161
+ required
162
+ label={
163
+ <FormattedMessage id="settings.incident-types.new.description-text-area-label" />
164
+ }
165
+ name="description"
166
+ value={formData.description}
167
+ onChange={handleChange}
168
+ style={{ width: '100%', height: '200px' }}
169
+ />
170
+ </Col>
171
+ </Row>
172
+ </Accordion>
173
+ </AccordionSet>
174
+ </Pane>
175
+ );
176
+ };
177
+
178
+ NewIncidentTypePane.propTypes = {
179
+ handleCloseNew: PropTypes.func.isRequired,
180
+ };
181
+
182
+ export default NewIncidentTypePane;
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { stripesConnect } from '@folio/stripes/core';
4
+
5
+ class PutIncidentType extends React.Component {
6
+ static manifest = Object.freeze({
7
+ incidentTypes: {
8
+ type: 'okapi',
9
+ path: `incidents/configurations/incident-types`,
10
+ PUT: {
11
+ path: `incidents/configurations/incident-types`,
12
+ },
13
+ accumulate: true,
14
+ },
15
+ });
16
+
17
+ static propTypes = {
18
+ data: PropTypes.string,
19
+ mutator: PropTypes.shape({
20
+ incidentTypes: PropTypes.shape({
21
+ PUT: PropTypes.func.isRequired,
22
+ }).isRequired,
23
+ }).isRequired,
24
+ handleCloseNew: PropTypes.func.isRequired,
25
+ handleCloseEdit: PropTypes.func.isRequired,
26
+ handleDeleteSuccess: PropTypes.func.isRequired,
27
+ context: PropTypes.string.isRequired,
28
+ };
29
+
30
+ componentDidMount() {
31
+ if (this.props.data) {
32
+ this.updateIncidentType(this.props.data);
33
+ }
34
+ }
35
+
36
+ updateIncidentType = (data) => {
37
+ console.log("@updateIncidentType - data passed in --> ", JSON.stringify(this.props.data, null, 2))
38
+ this.props.mutator.incidentTypes
39
+ .PUT(data)
40
+ .then(() => {
41
+ if (this.props.context === 'new') {
42
+ this.props.handleCloseNew();
43
+ } else if (this.props.context === 'edit') {
44
+ this.props.handleCloseEdit();
45
+ } else if (this.props.context === 'details') {
46
+ this.props.handleDeleteSuccess();
47
+ }
48
+ console.log('update successful');
49
+ })
50
+ .catch((error) => {
51
+ console.error('error updating: ', error);
52
+ });
53
+ };
54
+
55
+ render() {
56
+ return null;
57
+ };
58
+ };
59
+
60
+ export default stripesConnect(PutIncidentType, '@spokane-folio/security-incident');
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { stripesConnect } from '@folio/stripes/core';
4
+
5
+ class PutLocationsInService extends React.Component {
6
+ static manifest = Object.freeze({
7
+ locationsInServicePUT: {
8
+ type: 'okapi',
9
+ path: `incidents/configurations/locations-in-service`,
10
+ PUT: {
11
+ path: `incidents/configurations/locations-in-service`,
12
+ }
13
+ },
14
+ });
15
+
16
+ static propTypes = {
17
+ data: PropTypes.object,
18
+ mutator: PropTypes.shape({
19
+ locationsInServicePUT: PropTypes.shape({
20
+ PUT: PropTypes.func.isRequired,
21
+ }).isRequired,
22
+ }).isRequired,
23
+ setShow: PropTypes.func // optional, passed from LocationsPaneset only
24
+ };
25
+
26
+ static defaultProps = {
27
+ setShow: () => {}, // fallback when not supplied
28
+ };
29
+
30
+ componentDidMount() {
31
+ if (this.props.data) {
32
+ this.updateLocationsInService(this.props.data);
33
+ }
34
+ };
35
+
36
+ updateLocationsInService = (data) => {
37
+ this.props.mutator.locationsInServicePUT
38
+ .PUT(data)
39
+ .then(() => {
40
+ this.props.setShow(true)
41
+ })
42
+ .catch((error) => {
43
+ console.error('error updating: ', error);
44
+ });
45
+ };
46
+
47
+ render() {
48
+ return null;
49
+ };
50
+ };
51
+
52
+ export default stripesConnect(PutLocationsInService, '@spokane-folio/security-incident');
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { stripesConnect } from '@folio/stripes/core';
4
+
5
+ class PutTrespassReasons extends React.Component {
6
+ static manifest = Object.freeze({
7
+ trespassReasons: {
8
+ type: 'okapi',
9
+ path: `incidents/configurations/trespass-reasons`,
10
+ PUT: {
11
+ path: `incidents/configurations/trespass-reasons`,
12
+ },
13
+ fetch: false,
14
+ accumulate: false
15
+ },
16
+ });
17
+
18
+ static propTypes = {
19
+ data: PropTypes.object,
20
+ mutator: PropTypes.shape({
21
+ trespassReasons: PropTypes.shape({
22
+ PUT: PropTypes.func.isRequired,
23
+ }).isRequired,
24
+ }).isRequired,
25
+ handleFinishEdit: PropTypes.func, // not required (invoked in Edit)
26
+ onSuccess: PropTypes.func, // not required (invoked in Paneset 'new')
27
+ handleDeleteSuccess: PropTypes.func // not required (invoked in delete context)
28
+ };
29
+
30
+ componentDidMount() {
31
+ if (this.props.data) {
32
+ this.updateTrespassReasons(this.props.data);
33
+ }
34
+ };
35
+
36
+ updateTrespassReasons = async (data) => {
37
+ if (this.props.context === 'delete') {
38
+ try {
39
+ await this.props.mutator.trespassReasons.PUT(data);
40
+ this.props.onSuccess?.() // tell parent paneset it succeeded
41
+ this.props.handleDeleteSuccess()
42
+ } catch (error) {
43
+ console.error('error updating: ', error);
44
+ }
45
+ } else {
46
+ try {
47
+ await this.props.mutator.trespassReasons.PUT(data);
48
+ this.props.onSuccess?.() // tell parent paneset it succeeded
49
+ this.props.handleFinishEdit() // close out Edit work
50
+ } catch (error) {
51
+ console.error('error updating: ', error);
52
+ }
53
+ }
54
+ };
55
+
56
+ render() {
57
+ return null;
58
+ };
59
+ };
60
+
61
+ export default stripesConnect(PutTrespassReasons, '@spokane-folio/security-incident');
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { stripesConnect } from '@folio/stripes/core';
4
+
5
+ class PutTrespassTemplate extends React.Component {
6
+ static manifest = Object.freeze({
7
+ trespassTemplatesPUT: {
8
+ type: 'okapi',
9
+ path: `incidents/configurations/trespass-templates`,
10
+ PUT: {
11
+ path: `incidents/configurations/trespass-templates`,
12
+ }
13
+ },
14
+ });
15
+
16
+ static propTypes = {
17
+ data: PropTypes.object,
18
+ mutator: PropTypes.shape({
19
+ trespassTemplatesPUT: PropTypes.shape({
20
+ PUT: PropTypes.func.isRequired,
21
+ }).isRequired,
22
+ }).isRequired
23
+ };
24
+
25
+ componentDidMount() {
26
+ console.log("COMPONENT DID MOUNT @PutTrespassTemplate - data --> ", JSON.stringify(this.props.data, null, 2))
27
+ if (this.props.data) {
28
+ console.log("IN CONDITION @PutTrespassTemplate - data --> ", JSON.stringify(this.props.data, null, 2))
29
+ this.updateRecords(this.props.data);
30
+ };
31
+ };
32
+
33
+ updateRecords = (data) => {
34
+ console.log("@PutTrespassTemplate - data --> ", JSON.stringify(data, null, 2))
35
+ this.props.mutator.trespassTemplatesPUT
36
+ .PUT(data)
37
+ .then(() => {
38
+ console.log("succcess update trespass templates")
39
+ })
40
+ .catch((error) => {
41
+ console.error('error updating: ', error);
42
+ });
43
+ };
44
+
45
+ render() {
46
+ return null;
47
+ }
48
+ }
49
+
50
+ export default stripesConnect(PutTrespassTemplate, '@spokane-folio/security-incident');
@@ -0,0 +1,17 @@
1
+ .ql-insertToken {
2
+ background: none;
3
+ /* Remove default background */
4
+ border: none;
5
+ color: black;
6
+ /* Set text color */
7
+ cursor: pointer;
8
+ padding: 5px 10px;
9
+ /* Adjust padding */
10
+ font-size: 14px;
11
+ /* Font size */
12
+ }
13
+
14
+ .ql-insertToken:hover {
15
+ background-color: #f0f0f0;
16
+ /* Add hover effect */
17
+ }