@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.
- package/.eslintrc +32 -0
- package/.github/workflows/CODEOWNERS +8 -0
- package/.github/workflows/pr-validation.yml +44 -0
- package/.github/workflows/release.yml +64 -0
- package/.prettierrc +6 -0
- package/.stripesclirc +4 -0
- package/CHANGELOG.md +8 -0
- package/CONTRIBUTING.md +4 -0
- package/LICENSE +201 -0
- package/README.md +16 -0
- package/administrator-documentation/roles-and-permissions.md +65 -0
- package/administrator-documentation/track-settings-admin-guide-sketch.md +192 -0
- package/administrator-documentation/using-the-application.md +192 -0
- package/icons/app.png +0 -0
- package/icons/app.svg +1 -0
- package/icons/playButton.png +0 -0
- package/icons/profilePicThumbnail.png +0 -0
- package/jest.config.js +10 -0
- package/module-descriptor.json +75 -0
- package/output/service-worker.js +0 -0
- package/package.json +146 -0
- package/src/components/incidents/ColumnChooser.js +37 -0
- package/src/components/incidents/CreateMedia.js +132 -0
- package/src/components/incidents/CreatePane.js +1215 -0
- package/src/components/incidents/CreatePane.test.js +138 -0
- package/src/components/incidents/CreateReport.js +102 -0
- package/src/components/incidents/DetailsPane.js +1267 -0
- package/src/components/incidents/DetailsPane.test.js +150 -0
- package/src/components/incidents/EditPane.js +2334 -0
- package/src/components/incidents/EditPane.test.js +187 -0
- package/src/components/incidents/GetDetails.js +55 -0
- package/src/components/incidents/GetListDQLinkIncident.js +81 -0
- package/src/components/incidents/GetListDynamicQuery.js +66 -0
- package/src/components/incidents/GetLocations.js +57 -0
- package/src/components/incidents/GetMedia.js +98 -0
- package/src/components/incidents/GetName.js +111 -0
- package/src/components/incidents/GetNameCreatedBy.js +94 -0
- package/src/components/incidents/GetOrgLocaleSettings.js +61 -0
- package/src/components/incidents/GetPatronGroups.js +52 -0
- package/src/components/incidents/GetSelf.js +65 -0
- package/src/components/incidents/GetSummary.js +110 -0
- package/src/components/incidents/IncidentTypeCard.js +53 -0
- package/src/components/incidents/IncidentTypeCard.test.js +133 -0
- package/src/components/incidents/IncidentsPaneset.js +810 -0
- package/src/components/incidents/IncidentsPaneset.test.js +128 -0
- package/src/components/incidents/LinkedIncident.js +86 -0
- package/src/components/incidents/ModalAddMedia.js +262 -0
- package/src/components/incidents/ModalAddMedia.test.js +97 -0
- package/src/components/incidents/ModalAttentionDecOfService.js +111 -0
- package/src/components/incidents/ModalCustomWitness.js +469 -0
- package/src/components/incidents/ModalCustomWitness.test.js +147 -0
- package/src/components/incidents/ModalCustomerDetails.js +480 -0
- package/src/components/incidents/ModalCustomerDetails.test.js +116 -0
- package/src/components/incidents/ModalDescribeCustomer.js +361 -0
- package/src/components/incidents/ModalDescribeCustomer.test.js +156 -0
- package/src/components/incidents/ModalDirtyFormWarn.js +62 -0
- package/src/components/incidents/ModalLinkIncident.js +1213 -0
- package/src/components/incidents/ModalLinkIncidentStyle.css +32 -0
- package/src/components/incidents/ModalSelectIncidentTypes.js +178 -0
- package/src/components/incidents/ModalSelectIncidentTypes.test.js +273 -0
- package/src/components/incidents/ModalSelectKnownCustomer.js +395 -0
- package/src/components/incidents/ModalSelectWitness.js +406 -0
- package/src/components/incidents/ModalSelectWitness.test.js +308 -0
- package/src/components/incidents/ModalStyle.css +44 -0
- package/src/components/incidents/ModalTrespass.js +741 -0
- package/src/components/incidents/ModalViewCustomerDetails.js +241 -0
- package/src/components/incidents/ModalViewMedia.js +86 -0
- package/src/components/incidents/ModalViewTrespass.js +210 -0
- package/src/components/incidents/ResultsPane.js +437 -0
- package/src/components/incidents/ResultsPane.test.js +120 -0
- package/src/components/incidents/SearchCustomerOrWitness.js +108 -0
- package/src/components/incidents/Thumbnail.js +72 -0
- package/src/components/incidents/ThumbnailMarkRemoval.js +38 -0
- package/src/components/incidents/ThumbnailSkeleton.js +30 -0
- package/src/components/incidents/ThumbnailStyles.js +49 -0
- package/src/components/incidents/ThumbnailTempPreSave.js +71 -0
- package/src/components/incidents/UpdateReport.js +84 -0
- package/src/components/incidents/__snapshots__/CreatePane.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/DetailsPane.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/EditPane.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/IncidentTypeCard.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/IncidentsPaneset.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ModalAddMedia.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ModalCustomerDetails.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ModalSelectWitness.test.js.snap +3 -0
- package/src/components/incidents/__snapshots__/ResultsPane.test.js.snap +3 -0
- package/src/components/incidents/helpers/ProfilePicture/ProfilePicture.css +5 -0
- package/src/components/incidents/helpers/ProfilePicture/ProfilePicture.js +51 -0
- package/src/components/incidents/helpers/ProfilePicture/isAValidURL.js +3 -0
- package/src/components/incidents/helpers/ProfilePicture/useProfilePicture.js +127 -0
- package/src/components/incidents/helpers/buildQueryString.js +28 -0
- package/src/components/incidents/helpers/cleanFormValues.js +53 -0
- package/src/components/incidents/helpers/computeEditedCustomers.js +124 -0
- package/src/components/incidents/helpers/convertDateIgnoringTZ.js +8 -0
- package/src/components/incidents/helpers/convertUTCISOToLocalePrettyTime.js +15 -0
- package/src/components/incidents/helpers/convertUTCISOToPrettyDate.js +19 -0
- package/src/components/incidents/helpers/decodeParamsToForm.js +20 -0
- package/src/components/incidents/helpers/deepNormalizeForComparison.js +39 -0
- package/src/components/incidents/helpers/extractFilterString.js +12 -0
- package/src/components/incidents/helpers/formatDateAndTimeToUTCISO.js +14 -0
- package/src/components/incidents/helpers/formatDateToUTCISO.js +14 -0
- package/src/components/incidents/helpers/formatTimeToUTCISO.js +28 -0
- package/src/components/incidents/helpers/getCurrentTime.js +20 -0
- package/src/components/incidents/helpers/getTodayDate.js +12 -0
- package/src/components/incidents/helpers/handlebarsHelpers.js +148 -0
- package/src/components/incidents/helpers/hasFormChangedAtCreate.js +50 -0
- package/src/components/incidents/helpers/hasTopLevelChangeAffectedDeclaration.js +90 -0
- package/src/components/incidents/helpers/hasTopLevelFormChanged.js +111 -0
- package/src/components/incidents/helpers/identifyCurrentTrespassDocs.js +109 -0
- package/src/components/incidents/helpers/isSameHtml.js +13 -0
- package/src/components/incidents/helpers/isValidDateFormat.js +14 -0
- package/src/components/incidents/helpers/isValidTimeInput.js +11 -0
- package/src/components/incidents/helpers/isValidUTCTimeFormat.js +14 -0
- package/src/components/incidents/helpers/parseMMDDYYYY.js +7 -0
- package/src/components/incidents/helpers/parseQueryString.js +16 -0
- package/src/components/incidents/helpers/sortTrespassDocuments.js +44 -0
- package/src/components/incidents/helpers/stripHTML.js +11 -0
- package/src/components/incidents/helpers/trespassDocUtils.js +197 -0
- package/src/components/incidents/helpers/validateTrespassDetails.js +37 -0
- package/src/components/incidents/usePersistedColModalLink.js +70 -0
- package/src/components/incidents/usePersistedColumns.js +70 -0
- package/src/components/incidents/usePersistedSort.js +23 -0
- package/src/components/incidents/usePersistedSortModalLink.js +23 -0
- package/src/contexts/IncidentContext.js +433 -0
- package/src/index.js +61 -0
- package/src/routes/Application.js +13 -0
- package/src/settings/GetIncidentCategories.js +56 -0
- package/src/settings/GetIncidentTypesDetails.js +88 -0
- package/src/settings/GetIncidentTypesIds.js +74 -0
- package/src/settings/GetLocationsInService.js +54 -0
- package/src/settings/GetSingleCustomLocationDetails.js +60 -0
- package/src/settings/GetSingleIncidentTypeDetails.js +60 -0
- package/src/settings/GetTrespassReasons.js +67 -0
- package/src/settings/GetTrespassTemplates.js +51 -0
- package/src/settings/IncidentCategoriesPane.js +285 -0
- package/src/settings/IncidentCategoriesPane.test.js +229 -0
- package/src/settings/IncidentTypeDetailsPane.js +215 -0
- package/src/settings/IncidentTypeDetailsPane.test.js +220 -0
- package/src/settings/IncidentTypeEditPane.js +211 -0
- package/src/settings/IncidentTypeEditPane.test.js +170 -0
- package/src/settings/IncidentTypesPaneset.js +167 -0
- package/src/settings/IncidentTypesPaneset.test.js +124 -0
- package/src/settings/LocationInServiceEditPane.js +320 -0
- package/src/settings/LocationsPaneset.js +415 -0
- package/src/settings/LocationsPaneset.test.js +106 -0
- package/src/settings/ModalDeleteCategory.js +47 -0
- package/src/settings/ModalDeleteIncidentType.js +49 -0
- package/src/settings/ModalDeleteLocationInService.js +49 -0
- package/src/settings/ModalDeleteTrespassReason.js +49 -0
- package/src/settings/ModalPreviewTrespassDoc.js +65 -0
- package/src/settings/ModalTrespassDocTokens.js +83 -0
- package/src/settings/NewIncidentTypePane.js +182 -0
- package/src/settings/PutIncidentType.js +60 -0
- package/src/settings/PutLocationsInService.js +52 -0
- package/src/settings/PutTrespassReasons.js +61 -0
- package/src/settings/PutTrespassTemplate.js +50 -0
- package/src/settings/TrespassDoc.css +17 -0
- package/src/settings/TrespassDocDetailsPane.js +215 -0
- package/src/settings/TrespassDocEditPane.js +538 -0
- package/src/settings/TrespassDocPaneset.js +581 -0
- package/src/settings/TrespassReasonDetailsPane.js +171 -0
- package/src/settings/TrespassReasonEditPane.js +221 -0
- package/src/settings/TrespassReasonsPaneset.js +282 -0
- package/src/settings/__snapshots__/IncidentCategoriesPane.test.js.snap +3 -0
- package/src/settings/__snapshots__/IncidentTypeDetailsPane.test.js.snap +3 -0
- package/src/settings/__snapshots__/IncidentTypeEditPane.test.js.snap +3 -0
- package/src/settings/__snapshots__/IncidentTypesPaneset.test.js.snap +3 -0
- package/src/settings/__snapshots__/LocationsPaneset.test.js.snap +3 -0
- package/src/settings/data/exampleJSON.json +92 -0
- package/src/settings/data/templateTokens.js +396 -0
- package/src/settings/helpers/alphabetize.js +18 -0
- package/src/settings/helpers/getCategoryTitleById.js +13 -0
- package/src/settings/helpers/makeId.js +15 -0
- package/src/settings/index.js +48 -0
- package/stripes.config.js +10 -0
- package/test/jest/__mock__/index.js +8 -0
- package/test/jest/__mock__/intl.mock.js +27 -0
- package/test/jest/__mock__/stripes.mock.js +26 -0
- package/test/jest/__mock__/stripesComponents.mock.js +151 -0
- package/test/jest/__mock__/stripesConfig.mock.js +1 -0
- package/test/jest/__mock__/stripesCore.mock.js +9 -0
- package/test/jest/__mock__/stripesIcon.mock.js +5 -0
- package/test/jest/__mock__/stripesSmartComponents.mock.js +7 -0
- package/test/jest/__mock__/stripesUtils.mock.js +3 -0
- package/test/jest/eslintrc.js +12 -0
- package/test/jest/setupFiles.js +5 -0
- package/translations/ui-security-incident/en_US.json +542 -0
- package/ui-module-acceptance-criteria.md +34 -0
|
@@ -0,0 +1,88 @@
|
|
|
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 GetIncidentTypesDetails extends React.Component {
|
|
7
|
+
static contextType = IncidentContext;
|
|
8
|
+
static manifest = Object.freeze({
|
|
9
|
+
incidentTypes: {
|
|
10
|
+
type: 'okapi',
|
|
11
|
+
path: 'incidents/configurations/incident-types',
|
|
12
|
+
records: 'data.value.incidentTypes',
|
|
13
|
+
throwErrors: false // prevent error modal if empty on first pass
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
static propTypes = {
|
|
18
|
+
resources: PropTypes.object.isRequired,
|
|
19
|
+
context: PropTypes.oneOf(['incidents', 'settings']).isRequired,
|
|
20
|
+
handleIncidentTypes: PropTypes.func, //only passed in 'settings' context
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
componentDidMount() {
|
|
24
|
+
// console.log("@GetIncidentTypesDetails - componentDidMount")
|
|
25
|
+
this.fetchRecords();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
componentDidUpdate(prevProps) {
|
|
29
|
+
const resourceChanged =
|
|
30
|
+
this.props.resources.incidentTypes !==
|
|
31
|
+
prevProps.resources.incidentTypes;
|
|
32
|
+
|
|
33
|
+
if (resourceChanged) {
|
|
34
|
+
// console.log("@GetIncidentTypesDetails - componentDidUPDATE")
|
|
35
|
+
this.fetchRecords();
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
fetchRecords() {
|
|
40
|
+
const incidentTypesBody = this.props.resources.incidentTypes;
|
|
41
|
+
if (!incidentTypesBody?.hasLoaded) return;
|
|
42
|
+
|
|
43
|
+
const types = incidentTypesBody?.records;
|
|
44
|
+
|
|
45
|
+
if (!Array.isArray(types) || !types.length) return;
|
|
46
|
+
|
|
47
|
+
// make shape for id, title shape list
|
|
48
|
+
const incTypes = [...types];
|
|
49
|
+
const titlesAndIds = incTypes.map((type) => ({
|
|
50
|
+
id: type.id,
|
|
51
|
+
title: type.title,
|
|
52
|
+
}));
|
|
53
|
+
|
|
54
|
+
if (titlesAndIds) {
|
|
55
|
+
// set inc types names, ids list for ready use at
|
|
56
|
+
// <IncidentsPaneset /> (app), < IncidentTypesPaneset/> (Settings)
|
|
57
|
+
this.context.setIncidentTypesNamesIdsList(titlesAndIds);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
if (this.props.context === 'incidents') {
|
|
62
|
+
// set incident types for general application
|
|
63
|
+
this.context.setIncidentTypesList(types);
|
|
64
|
+
|
|
65
|
+
} else if (this.props.context === 'settings') {
|
|
66
|
+
/*
|
|
67
|
+
set full-shape incidentTypes for Settings
|
|
68
|
+
<IncidentTypeDetailsPane />, <IncidentTypeEditPane />,
|
|
69
|
+
and <NewIncidentTypePane />. They pass handleIncidentTypes()
|
|
70
|
+
via props.
|
|
71
|
+
*/
|
|
72
|
+
if (typeof this.props.handleIncidentTypes === 'function') {
|
|
73
|
+
this.props.handleIncidentTypes(types);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
render() {
|
|
79
|
+
return null;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
GetIncidentTypesDetails.contextType = IncidentContext;
|
|
84
|
+
|
|
85
|
+
export default stripesConnect(
|
|
86
|
+
GetIncidentTypesDetails,
|
|
87
|
+
'@spokane-folio/security-incident'
|
|
88
|
+
);
|
|
@@ -0,0 +1,74 @@
|
|
|
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 GetIncidentTypesIds extends React.Component {
|
|
7
|
+
static contextType = IncidentContext;
|
|
8
|
+
/*
|
|
9
|
+
'incTypesIds' named manifest key so no collision with 'incidentTypes' manifest key at GetIncidentTypesDetails.
|
|
10
|
+
GetIncidentTypesIds requests at the same /incident-types endpoint that
|
|
11
|
+
GetIncidentTypesDetails utilizes. GetIncidentTypesIds is for convenience.
|
|
12
|
+
*/
|
|
13
|
+
static manifest = Object.freeze({
|
|
14
|
+
incTypesIds: {
|
|
15
|
+
type: 'okapi',
|
|
16
|
+
path: 'incidents/configurations/incident-types'
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
static propTypes = {
|
|
21
|
+
resources: PropTypes.object.isRequired,
|
|
22
|
+
// not required, used in context of <IncidentTypesPaneset />
|
|
23
|
+
handleGetTypesList: PropTypes.func,
|
|
24
|
+
// leave use of oneOf for future addition
|
|
25
|
+
contextTypeProp: PropTypes.oneOf(['incident-types-paneset'])
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
componentDidMount() {
|
|
29
|
+
this.fetchRecords();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
componentDidUpdate(prevProps) {
|
|
33
|
+
const resourceChanged =
|
|
34
|
+
this.props.resources.incTypesIds !==
|
|
35
|
+
prevProps.resources.incTypesIds;
|
|
36
|
+
if (resourceChanged) {
|
|
37
|
+
this.fetchRecords();
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
fetchRecords() {
|
|
42
|
+
// console.log("this.props.resources --> ", JSON.stringify(this.props.resources, null, 2))
|
|
43
|
+
const incTypesIdsBody = this.props.resources.incTypesIds;
|
|
44
|
+
// console.log("incTypesIdsBody --> ", JSON.stringify(incTypesIdsBody, null, 2))
|
|
45
|
+
if (!incTypesIdsBody?.hasLoaded) return;
|
|
46
|
+
|
|
47
|
+
const incTypes = incTypesIdsBody?.records[0]?.data?.value?.incidentTypes;
|
|
48
|
+
// console.log("incTypes --> ", JSON.stringify(incTypes, null, 2));
|
|
49
|
+
|
|
50
|
+
if (incTypes) {
|
|
51
|
+
const types = incTypes;
|
|
52
|
+
const titlesAndIds = types.map((type) => ({
|
|
53
|
+
id: type.id,
|
|
54
|
+
title: type.title,
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
// console.log("titlesAndIds --> ", JSON.stringify(titlesAndIds, null, 2));
|
|
58
|
+
|
|
59
|
+
if (this.props.contextTypeProp === 'incident-types-paneset') {
|
|
60
|
+
this.props.handleGetTypesList(titlesAndIds);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
this.context.setIncidentTypesNamesIdsList(titlesAndIds);
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
render() {
|
|
68
|
+
return null;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
GetIncidentTypesIds.contextType = IncidentContext;
|
|
73
|
+
|
|
74
|
+
export default stripesConnect(GetIncidentTypesIds, '@spokane-folio/security-incident');
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
import alphabetize from './helpers/alphabetize';
|
|
6
|
+
|
|
7
|
+
class GetLocationsInService extends React.Component {
|
|
8
|
+
static contextType = IncidentContext;
|
|
9
|
+
static manifest = Object.freeze({
|
|
10
|
+
locationsInService: {
|
|
11
|
+
type: 'okapi',
|
|
12
|
+
path: 'incidents/configurations/locations-in-service',
|
|
13
|
+
records: 'data.value.locationsInService',
|
|
14
|
+
throwErrors: false // prevent error modal if empty on first pass
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
static propTypes = {
|
|
19
|
+
resources: PropTypes.object.isRequired,
|
|
20
|
+
handleFetchedLocationsInService: PropTypes.func,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
componentDidMount() {
|
|
24
|
+
this.fetchRecords();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
componentDidUpdate(prevProps) {
|
|
28
|
+
const resourceChanged =
|
|
29
|
+
this.props.resources.locationsInService !==
|
|
30
|
+
prevProps.resources.locationsInService;
|
|
31
|
+
|
|
32
|
+
if (resourceChanged) {
|
|
33
|
+
this.fetchRecords();
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
fetchRecords() {
|
|
38
|
+
const res = this.props.resources.locationsInService;
|
|
39
|
+
if (!res?.hasLoaded) return;
|
|
40
|
+
|
|
41
|
+
const locationsInServiceList = res?.records;
|
|
42
|
+
if (!Array.isArray(locationsInServiceList)) return;
|
|
43
|
+
|
|
44
|
+
this.context.setLocationsInService(alphabetize(locationsInServiceList))
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
render() {
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
GetLocationsInService.contextType = IncidentContext;
|
|
53
|
+
|
|
54
|
+
export default stripesConnect(GetLocationsInService, '@spokane-folio/security-incident');
|
|
@@ -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 GetSingleCustomLocationDetails extends React.Component {
|
|
6
|
+
static manifest = Object.freeze({
|
|
7
|
+
customLocations: {
|
|
8
|
+
type: 'okapi',
|
|
9
|
+
path: 'configurations/entries?query=module==security-incident and configName=custom-locations and enabled=true',
|
|
10
|
+
accumulate: true,
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
static propTypes = {
|
|
15
|
+
customLocations: PropTypes.shape({
|
|
16
|
+
records: PropTypes.arrayOf(PropTypes.object),
|
|
17
|
+
}),
|
|
18
|
+
detailsId: PropTypes.string.isRequired,
|
|
19
|
+
handleFetchedDetails: PropTypes.func.isRequired,
|
|
20
|
+
mutator: PropTypes.shape({
|
|
21
|
+
customLocations: PropTypes.shape({
|
|
22
|
+
GET: PropTypes.func.isRequired,
|
|
23
|
+
}).isRequired,
|
|
24
|
+
}).isRequired,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
componentDidMount() {
|
|
28
|
+
this.fetchCustomLocationDetails(this.props.detailsId);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
componentDidUpdate(prevProps) {
|
|
32
|
+
if (this.props.detailsId !== prevProps.detailsId) {
|
|
33
|
+
this.fetchCustomLocationDetails(this.props.detailsId);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fetchCustomLocationDetails(id) {
|
|
38
|
+
this.props.mutator.customLocations
|
|
39
|
+
.GET({ path: 'configurations/entries?query=module==security-incident and configName=custom-locations and enabled=true' })
|
|
40
|
+
.then((records) => {
|
|
41
|
+
const valueObject = JSON.parse(records.configs[0].value);
|
|
42
|
+
const locations = valueObject.customLocations;
|
|
43
|
+
const singleLocation = locations.find((loc) => loc.id === id);
|
|
44
|
+
this.props.handleFetchedDetails(singleLocation);
|
|
45
|
+
})
|
|
46
|
+
.catch((error) => {
|
|
47
|
+
// placeholder
|
|
48
|
+
console.log('error fetching single custom location: ', error.message);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
return <></>;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export default stripesConnect(
|
|
58
|
+
GetSingleCustomLocationDetails,
|
|
59
|
+
'@spokane-folio/security-incident'
|
|
60
|
+
);
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { stripesConnect } from '@folio/stripes/core';
|
|
4
|
+
class GetSingleIncidentTypeDetails extends React.Component {
|
|
5
|
+
static manifest = Object.freeze({
|
|
6
|
+
incidentTypes: {
|
|
7
|
+
type: 'okapi',
|
|
8
|
+
path: 'incidents/configurations/incident-types',
|
|
9
|
+
records: 'data.value.incidentTypes',
|
|
10
|
+
throwErrors: false
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
static propTypes = {
|
|
15
|
+
resources: PropTypes.object.isRequired,
|
|
16
|
+
detailsId: PropTypes.string.isRequired,
|
|
17
|
+
handleFetchedDetails: PropTypes.func.isRequired,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
this.fetchRecord(this.props.detailsId);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
componentDidUpdate(prevProps) {
|
|
25
|
+
const resourceChanged =
|
|
26
|
+
this.props.resources.incidentTypes !==
|
|
27
|
+
prevProps.resources.incidentTypes;
|
|
28
|
+
const idChanged = this.props.detailsId !== prevProps.detailsId;
|
|
29
|
+
|
|
30
|
+
if (idChanged || resourceChanged) {
|
|
31
|
+
this.fetchRecord(this.props.detailsId);
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
fetchRecord(id) {
|
|
36
|
+
const res = this.props.resources.incidentTypes;
|
|
37
|
+
console.log("res --> ", JSON.stringify(res, null, 2))
|
|
38
|
+
if (!res?.hasLoaded) return;
|
|
39
|
+
|
|
40
|
+
const incTypesRecords = res?.records;
|
|
41
|
+
console.log("incTypesRecords --> ", JSON.stringify(incTypesRecords, null, 2));
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const singleType = incTypesRecords.find((type) => type.id === id);
|
|
45
|
+
this.props.handleFetchedDetails(singleType);
|
|
46
|
+
if (singleType) {
|
|
47
|
+
console.log("singleType --> ", JSON.stringify(singleType, null, 2));
|
|
48
|
+
this.props.handleFetchedDetails(singleType);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
return null;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default stripesConnect(
|
|
58
|
+
GetSingleIncidentTypeDetails,
|
|
59
|
+
'@spokane-folio/security-incident'
|
|
60
|
+
);
|
|
@@ -0,0 +1,67 @@
|
|
|
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 GetTrespassReasons extends React.Component {
|
|
7
|
+
static contextType = IncidentContext;
|
|
8
|
+
static manifest = Object.freeze({
|
|
9
|
+
trespassReasons: {
|
|
10
|
+
type: 'okapi',
|
|
11
|
+
path: 'incidents/configurations/trespass-reasons',
|
|
12
|
+
records: 'data.value.trespassReasons',
|
|
13
|
+
throwErrors: false
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
static propTypes = {
|
|
18
|
+
resources: PropTypes.object.isRequired,
|
|
19
|
+
handleFetchedTrespassReasons: PropTypes.func,
|
|
20
|
+
reloadKey: PropTypes.number // not required (invoked by Settings <TrespassReasonsPaneset> on new tr)
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
componentDidMount() {
|
|
24
|
+
this.fetchRecords();
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
componentDidUpdate(prevProps) {
|
|
28
|
+
// if parent bumped reloadKey make stripes refetch now
|
|
29
|
+
if (this.props.reloadKey !== prevProps.reloadKey) {
|
|
30
|
+
this.props.mutator.trespassReasons.reset?.();
|
|
31
|
+
this.props.mutator.trespassReasons.GET?.();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const resourceChanged =
|
|
35
|
+
this.props.resources.trespassReasons !==
|
|
36
|
+
prevProps.resources.trespassReasons;
|
|
37
|
+
|
|
38
|
+
if (resourceChanged) {
|
|
39
|
+
this.fetchRecords();
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
fetchRecords = () => {
|
|
44
|
+
const trBody = this.props.resources.trespassReasons;
|
|
45
|
+
if (!trBody?.hasLoaded || trBody?.isPending) return; // don't hit trespassReasons context value w/ partial
|
|
46
|
+
|
|
47
|
+
const reasons = trBody?.records;
|
|
48
|
+
if (Array.isArray(reasons)) {
|
|
49
|
+
this.context.setTrespassReasons(reasons)
|
|
50
|
+
} else {
|
|
51
|
+
console.error(
|
|
52
|
+
`Error: skip setter, records not array`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
render() {
|
|
58
|
+
return null;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
GetTrespassReasons.contextType = IncidentContext;
|
|
63
|
+
|
|
64
|
+
export default stripesConnect(
|
|
65
|
+
GetTrespassReasons,
|
|
66
|
+
'@spokane-folio/security-incident'
|
|
67
|
+
);
|
|
@@ -0,0 +1,51 @@
|
|
|
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 GetTrespassTemplates extends React.Component {
|
|
7
|
+
static contextType = IncidentContext;
|
|
8
|
+
static manifest = Object.freeze({
|
|
9
|
+
trespassTemplates: {
|
|
10
|
+
type: 'okapi',
|
|
11
|
+
path: 'incidents/configurations/trespass-templates',
|
|
12
|
+
records: 'data.value.templates',
|
|
13
|
+
throwErrors: false // prevent error modal if empty on first pass
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
static propTypes = {
|
|
18
|
+
resources: PropTypes.object.isRequired,
|
|
19
|
+
handleFetchedTrespassTemplates: PropTypes.func,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
componentDidMount() {
|
|
23
|
+
this.fetchRecords();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
componentDidUpdate(prevProps) {
|
|
27
|
+
const resourceChanged =
|
|
28
|
+
this.props.resources.trespassTemplates !==
|
|
29
|
+
prevProps.resources.trespassTemplates;
|
|
30
|
+
|
|
31
|
+
if (resourceChanged) {
|
|
32
|
+
this.fetchRecords();
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
fetchRecords = () => {
|
|
37
|
+
const res = this.props.resources.trespassTemplates;
|
|
38
|
+
if (!res?.hasLoaded) return;
|
|
39
|
+
|
|
40
|
+
const trespassTemplatesList = res?.records;
|
|
41
|
+
if (!Array.isArray(trespassTemplatesList)) return;
|
|
42
|
+
|
|
43
|
+
this.context.setTrespassTemplates(trespassTemplatesList);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
render() {
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default stripesConnect(GetTrespassTemplates, '@spokane-folio/security-incident');
|