-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat-5691]: wfs objects detail panel (#2842)
* refactor map-data-to-selectable-feature * Fix test case * add mapper for caterpillar object data * add test cases * fix test * add test case map-to-selectable-feature * add test cases * remove selectable component when feature is selected * show description of status in detail panel * fix status on detail panel * re-add datapunt key * fix typo * Fix types
- Loading branch information
Showing
23 changed files
with
620 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 17 additions & 5 deletions
22
...ident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/get-feature-type.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
// SPDX-License-Identifier: MPL-2.0 | ||
// Copyright (C) 2023 Gemeente Amsterdam | ||
import { getFeatureType } from './get-feature-type' | ||
import { mockContainerFeatureTypes } from './test/mock-feature-types' | ||
import { mockGlasContainer } from './test/mock-objects' | ||
import { | ||
mockContainerFeatureTypes, | ||
mockCaterpillarFeatureTypes, | ||
} from './test/mock-feature-types' | ||
import { mockContainers, mockCaterpillarFeature } from './test/mock-objects' | ||
|
||
describe('getFeatureType', () => { | ||
it('should return the correct feature type', () => { | ||
const result = getFeatureType(mockGlasContainer, mockContainerFeatureTypes) | ||
it('should return the container feature type', () => { | ||
const result = getFeatureType(mockContainers[0], mockContainerFeatureTypes) | ||
|
||
expect(result).toEqual(mockContainerFeatureTypes[2]) | ||
expect(result).toEqual(mockContainerFeatureTypes[1]) | ||
}) | ||
|
||
it('should return the caterpillar feature type', () => { | ||
const result = getFeatureType( | ||
mockCaterpillarFeature[0], | ||
mockCaterpillarFeatureTypes | ||
) | ||
|
||
expect(result).toEqual(mockCaterpillarFeatureTypes[0]) | ||
}) | ||
}) |
15 changes: 6 additions & 9 deletions
15
...s/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/get-feature-type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
// SPDX-License-Identifier: MPL-2.0 | ||
// Copyright (C) 2023 Gemeente Amsterdam | ||
import type { Feature } from 'geojson' | ||
// Copyright (C) 2024 Gemeente Amsterdam | ||
import type { Feature } from 'signals/incident/components/form/MapSelectors/types' | ||
|
||
import type { FeatureType } from '../../../../types' | ||
|
||
export const getFeatureType = ( | ||
feature: Feature, | ||
featureTypes: FeatureType[] | ||
): FeatureType => | ||
featureTypes.find( | ||
({ typeField, typeValue }) => feature.properties?.[typeField] === typeValue | ||
) as FeatureType | ||
export const getFeatureType = (feature: Feature, featureTypes: FeatureType[]) => | ||
featureTypes.find(({ typeField, typeValue }) => { | ||
return feature.properties?.[typeField] === typeValue | ||
}) |
40 changes: 0 additions & 40 deletions
40
...cident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/get-object-type.test.ts
This file was deleted.
Oops, something went wrong.
29 changes: 0 additions & 29 deletions
29
...ls/incident/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/get-object-type.ts
This file was deleted.
Oops, something went wrong.
27 changes: 27 additions & 0 deletions
27
...omponents/form/MapSelectors/Asset/Selector/WfsLayer/utils/is-caterpillar-category.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { isCaterpillarCategory } from './is-caterpillar-category' | ||
import { mockCaterpillarFeatureGeo } from './test/mock-objects' | ||
|
||
describe('isCaterpillarCategory', () => { | ||
it('should return true when feature id is a number and species is in properties', () => { | ||
expect(isCaterpillarCategory(mockCaterpillarFeatureGeo[0])).toBe(true) | ||
}) | ||
|
||
it('should return true when feature id is a number and species is in properties array', () => { | ||
expect(isCaterpillarCategory(mockCaterpillarFeatureGeo[1])).toBe(true) | ||
}) | ||
|
||
it('should return false when feature id is not a number', () => { | ||
expect( | ||
isCaterpillarCategory({ ...mockCaterpillarFeatureGeo[0], id: undefined }) | ||
).toBe(false) | ||
}) | ||
|
||
it('should return false when species is not in properties', () => { | ||
expect( | ||
isCaterpillarCategory({ | ||
...mockCaterpillarFeatureGeo[0], | ||
properties: [{ type: 'tree' }], | ||
}) | ||
).toBe(false) | ||
}) | ||
}) |
10 changes: 10 additions & 0 deletions
10
...ent/components/form/MapSelectors/Asset/Selector/WfsLayer/utils/is-caterpillar-category.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { Feature as FeatureGeo } from 'geojson' | ||
|
||
export const isCaterpillarCategory = (feature: FeatureGeo) => { | ||
return ( | ||
typeof feature.id === 'number' && | ||
feature.properties && | ||
// properties is an object or an array with a species | ||
('species' in feature.properties || 'species' in feature.properties[0]) | ||
) | ||
} |
Oops, something went wrong.