-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/search-listing-hide-form-option
# Conflicts: # packages/ripple-tide-search/types.ts
- Loading branch information
Showing
174 changed files
with
135,645 additions
and
608 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
171 changes: 171 additions & 0 deletions
171
examples/nuxt-app/components/global/VSBAProjectAreaLayer.vue
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,171 @@ | ||
<template> | ||
<ol-vector-layer | ||
v-if="results.length > 0" | ||
:title="layerIdentifier" | ||
:zIndex="1" | ||
> | ||
<ol-source-vector :zIndex="0" :url="areaUrl" :format="shapeFormat"> | ||
</ol-source-vector> | ||
<ol-style> | ||
<ol-style-stroke :color="lineColor" width="2"></ol-style-stroke> | ||
<ol-style-fill :color="fillColor"></ol-style-fill> | ||
</ol-style> | ||
</ol-vector-layer> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { GeoJSON } from 'ol/format' | ||
import { Style, Fill, Stroke } from 'ol/style' | ||
import { computed, inject, onMounted, nextTick } from 'vue' | ||
interface Props { | ||
results: any[] | ||
lineColor?: string | Number[] | ||
fillColor?: string | Number[] | ||
areaDataKey?: string | ||
} | ||
const props = withDefaults(defineProps<Props>(), { | ||
results: () => [], | ||
lineColor: () => [102, 102, 102, 1], | ||
fillColor: () => [26, 26, 26, 0.1], | ||
areaDataKey: 'field_postcode' | ||
}) | ||
const areas = computed(() => { | ||
const matches = props.results.filter((itm) => { | ||
return !itm.lat && itm[props.areaDataKey] | ||
}) | ||
return matches | ||
}) | ||
const mappedAreas = computed(() => { | ||
return areas.value.map((area) => `'${area[props.areaDataKey]}'`) | ||
}) | ||
const shapeFormat = new GeoJSON() | ||
const areaUrl = computed(() => { | ||
const baseArcGISURL = | ||
'https://services6.arcgis.com/GB33F62SbDxJjwEL/ArcGIS/rest/services/Vicmap_Admin/FeatureServer/14/query' | ||
const query = `postcode IN (${mappedAreas.value.join(',')})` | ||
const inSR = '4326' | ||
return `${baseArcGISURL}?where=${query}&geometryType=esriGeometryEnvelope&inSR=${inSR}&spatialRel=esriSpatialRelIntersects&units=esriSRUnit_Meter&returnGeodetic=false&outFields=postcode&returnGeometry=true&returnCentroid=false&f=pgeojson&token=` | ||
}) | ||
const { rplMapRef, popup } = inject('rplMapInstance') | ||
const defaultStyleFn = new Style({ | ||
fill: new Fill({ | ||
color: props.fillColor | ||
}), | ||
stroke: new Stroke({ | ||
color: props.lineColor, | ||
width: 2 | ||
}) | ||
}) | ||
const mouseOverStyleFn = new Style({ | ||
fill: new Fill({ | ||
color: [26, 26, 26, 0.15] | ||
}), | ||
stroke: new Stroke({ | ||
color: props.lineColor, | ||
width: 2 | ||
}) | ||
}) | ||
const layerIdentifier = 'shapeLayer' | ||
const centerOnPopup = (map, popup, offset = { y: -100, x: 0 }) => { | ||
const view = map.getView() | ||
const resolution = view.getResolution() | ||
const offsetCoord = [ | ||
popup.value.position[0] + offset.x * resolution, | ||
popup.value.position[1] + offset.y * resolution | ||
] | ||
view.animate({ | ||
center: offsetCoord, | ||
duration: 600 | ||
}) | ||
} | ||
onMounted(async () => { | ||
await nextTick() | ||
if (rplMapRef.value) { | ||
const map = rplMapRef.value | ||
// Get reference to shapeLayer by title identifier | ||
const allLayers = map.getLayers().getArray() | ||
const shapeLayer = Array.from(allLayers).find( | ||
(layer) => layer.get('title') === layerIdentifier | ||
) | ||
// shapeLayer.dispatchChangeEvent() | ||
// define filter for getting only shapeLayer | ||
const layerFilter = (feature, layer) => { | ||
if (layer.get('title') === layerIdentifier) { | ||
return feature | ||
} | ||
} | ||
map.on('singleclick', function (evt) { | ||
const clickedFeatures = [] | ||
// We need to keep track of features that are clicked outside of the shape layer, so that pins can take priority over the shape | ||
const outOfLayerClickedFeatures = [] | ||
// Get the features at the click position | ||
map.forEachFeatureAtPixel( | ||
evt.pixel, | ||
(f, layer) => { | ||
if (layer.get('title') === layerIdentifier) { | ||
clickedFeatures.push(f) | ||
} else { | ||
outOfLayerClickedFeatures.push(f) | ||
} | ||
}, | ||
{ | ||
hitTolerance: 5 | ||
} | ||
) | ||
if (outOfLayerClickedFeatures.length || !clickedFeatures.length) { | ||
return | ||
} | ||
const feature = clickedFeatures[0] | ||
const matchingResult = areas.value.filter((itm) => { | ||
return itm.field_postcode[0] === feature?.get('postcode') | ||
}) | ||
popup.value.isArea = true | ||
popup.value.feature = Array.isArray(matchingResult) | ||
? matchingResult | ||
: [matchingResult] | ||
popup.value.isOpen = true | ||
popup.value.position = evt.coordinate | ||
centerOnPopup(map, popup) | ||
}) | ||
// Add a pointermove event listener to the map to detect shape hover | ||
map.on('pointermove', function (evt) { | ||
// Get the features at the mouse position | ||
const feature = map.forEachFeatureAtPixel(evt.pixel, layerFilter, { | ||
hitTolerance: 5 | ||
}) | ||
// reset all shapes not hovered | ||
if (shapeLayer) { | ||
const shapeSource = shapeLayer.getSource() | ||
if (shapeSource) { | ||
const shapeFeatures = shapeSource.getFeatures() | ||
if (shapeFeatures) { | ||
shapeFeatures.forEach(function (feature) { | ||
feature.setStyle(defaultStyleFn) | ||
}) | ||
} | ||
} | ||
} | ||
// Change the style for the hovered shape on mouseover | ||
if (feature) { | ||
document.querySelector('canvas').style.cursor = 'pointer' | ||
feature.setStyle(mouseOverStyleFn) | ||
} | ||
}) | ||
} | ||
}) | ||
</script> |
52 changes: 52 additions & 0 deletions
52
examples/nuxt-app/components/global/VsbaMapPopupContent.vue
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,52 @@ | ||
<template> | ||
<div class="vsba-map-popup-content"> | ||
<h4 class="rpl-type-p-small">What's happening?</h4> | ||
|
||
<p | ||
v-if="feature.field_project_title?.length === 1" | ||
class="rpl-type-p-small" | ||
> | ||
{{ feature.title[0] }} | ||
</p> | ||
<RplContent v-else class="vsba-map-popup-list"> | ||
<ul> | ||
<li v-for="project in feature.field_project_title" :key="project"> | ||
{{ project }} | ||
</li> | ||
</ul> | ||
</RplContent> | ||
<p class="rpl-type-p-small rpl-u-margin-t-3"> | ||
<RplTextLink :url="formatUrl(feature.url[0])"> | ||
View {{ feature.title[0] }} | ||
</RplTextLink> | ||
</p> | ||
</div> | ||
</template> | ||
<script setup lang="ts"> | ||
interface Props { | ||
feature: any | ||
} | ||
const props = withDefaults(defineProps<Props>(), {}) | ||
const formatUrl = (str) => str.replace(/\/site-(\d+)/, '') | ||
</script> | ||
<style> | ||
.vsba-map-popup-content { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
.vsba-map-popup-list ul { | ||
margin: 0; | ||
font-size: var(--rpl-type-size-1); | ||
line-height: var(--rpl-type-lh-3); | ||
letter-spacing: var(--rpl-type-ls-1); | ||
} | ||
.vsba-map-popup-list ul li:before { | ||
top: 0.6rem; | ||
} | ||
</style> |
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
21 changes: 21 additions & 0 deletions
21
examples/nuxt-app/test/features/data-table/table-filters.feature
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,21 @@ | ||
Feature: Custom Collection | ||
|
||
As an editor I want to be able to add a view of results in a search index to a landing page with filters | ||
|
||
Background: | ||
Given the page endpoint for path "/" returns fixture "/map-table/ise/page" with status 200 | ||
Given the site endpoint returns fixture "/site/reference" with status 200 | ||
And the search autocomplete request is stubbed with "/search-listing/suggestions/none" fixture | ||
Given I am using a "macbook-16" device | ||
|
||
@mockserver | ||
Scenario: On load | ||
Given the "/api/tide/elasticsearch/sdp_data_pipelines_ise/_search" network request is stubbed with fixture "/map-table/ise/response" and status 200 as alias "cslReq" | ||
Given the "/api/tide/elasticsearch/sdp_data_pipelines_ise/_search" aggregation request is stubbed with fixture "/map-table/ise/aggregations" and status 200 as alias "aggReq" | ||
Given I visit the page "/" | ||
Then the landing page component "TideCustomCollection" should exist | ||
And the custom collection component should have a search input bar | ||
And the custom collection component results count should read "Displaying 1-10 of 8269 results" | ||
And the "cslReq" network request should be made to the elasticsearch endpoint | ||
And the "aggReq" network request should be made to the elasticsearch endpoint | ||
And the search listing layout should be "table" |
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
Binary file added
BIN
+664 KB
examples/nuxt-app/test/features/maps/__image_snapshots__/map-cluster-zoom #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+687 KB
...ples/nuxt-app/test/features/maps/__image_snapshots__/map-location-search #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+193 KB
...ples/nuxt-app/test/features/maps/__image_snapshots__/map-no-results #0.diff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+138 KB
examples/nuxt-app/test/features/maps/__image_snapshots__/map-no-results #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+497 KB
examples/nuxt-app/test/features/maps/__image_snapshots__/map-on-load #0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.