From 5771c735103c3dff78d957b1b6f40a8c59ef265d Mon Sep 17 00:00:00 2001 From: "Huy Tran (Harry)" Date: Sat, 25 Sep 2021 16:26:02 +1000 Subject: [PATCH] fix: add uuid to capture detail dialog and top filter (#166) --- src/api/treeTrackerApi.js | 1 + src/components/CaptureDetailDialog.js | 5 +++++ src/components/FilterTop.js | 11 +++++++++++ src/components/tests/verify.test.js | 3 +++ src/models/Filter.js | 5 +++++ src/models/Filter.test.js | 5 +++++ 6 files changed, 30 insertions(+) diff --git a/src/api/treeTrackerApi.js b/src/api/treeTrackerApi.js index 4aaf134ee..0ca6d7ede 100644 --- a/src/api/treeTrackerApi.js +++ b/src/api/treeTrackerApi.js @@ -21,6 +21,7 @@ export default { limit: rowsPerPage, skip, fields: { + uuid: true, imageUrl: true, lat: true, lon: true, diff --git a/src/components/CaptureDetailDialog.js b/src/components/CaptureDetailDialog.js index 509d9a1ff..79cd31a11 100644 --- a/src/components/CaptureDetailDialog.js +++ b/src/components/CaptureDetailDialog.js @@ -185,6 +185,11 @@ function CaptureDetailDialog(props) { copy: true, link: true, }, + { + label: 'Capture UUID', + value: capture.uuid, + copy: true, + }, { label: 'Planter Identifier', value: capture.planterIdentifier, diff --git a/src/components/FilterTop.js b/src/components/FilterTop.js index c3c158b3c..5be85328b 100644 --- a/src/components/FilterTop.js +++ b/src/components/FilterTop.js @@ -79,6 +79,7 @@ function Filter(props) { const filterOptionAll = 'All'; const dateStartDefault = null; const dateEndDefault = null; + const [uuid, setUUID] = useState(filter?.uuid || ''); const [captureId, setCaptureId] = useState(filter?.captureId || ''); const [planterId, setPlanterId] = useState(filter?.planterId || ''); const [deviceId, setDeviceId] = useState(filter?.deviceIdentifier || ''); @@ -123,6 +124,7 @@ function Filter(props) { e.preventDefault(); // save the filer to context for editing & submit const filter = new FilterModel(); + filter.uuid = uuid; filter.captureId = captureId; filter.planterId = planterId; filter.deviceIdentifier = deviceId; @@ -140,6 +142,7 @@ function Filter(props) { function handleReset() { // reset form values, except 'approved' and 'active' which we'll keep + setUUID(''); setCaptureId(''); setPlanterId(''); setDeviceId(''); @@ -290,6 +293,14 @@ function Filter(props) { value={captureId} onChange={(e) => setCaptureId(e.target.value)} /> + setUUID(e.target.value)} + /> { beforeEach(() => { filter = new Filter(); + filter.uuid = '11942400-6617-4c6c-bf5e'; filter.captureId = 10; filter.dateStart = '2019-07-25'; filter.dateEnd = '2019-07-30'; @@ -15,6 +16,10 @@ describe('Filter, with initial values about this filter object', () => { filter.planterIdentifier = '1'; }); + it('getWhereObj() should be: ', () => { + expect(filter.getWhereObj()).toEqual(expect.objectContaining({ uuid: '11942400-6617-4c6c-bf5e' })); + }); + it('getWhereObj() should be: ', () => { expect(filter.getWhereObj()).toEqual(expect.objectContaining({ id: 10 })); });