Skip to content

Commit

Permalink
feat(@dpc-sdp/ripple-ui-maps): 🚧 wip on adding maps search
Browse files Browse the repository at this point in the history
  • Loading branch information
dylankelly committed Oct 16, 2023
1 parent 38d1d58 commit 08e417a
Show file tree
Hide file tree
Showing 13 changed files with 751 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ Feature: Data driven map
And I wait 30 seconds
Then the landing page component "TideDataDrivenMap" should exist

# Scenario: School buildings
# Given the page endpoint for path "/school-buildings" returns fixture "/data-driven-map/schools/page" with status 200
# # Given the "/api/tide/elasticsearch/sdp_data_pipelines_scl/_search" network request is stubbed with fixture "/data-driven-map/csl/response" and status 200 as alias "cslReq"
# Given I visit the page "/school-buildings"
# And I wait 30 seconds
# Then the landing page component "TideDataDrivenMap" should exist
@focus
Scenario: School buildings
Given the page endpoint for path "/school-buildings" returns fixture "/data-driven-map/schools/page" with status 200
Given I visit the page "/school-buildings"
And I wait 30 seconds
Then the landing page component "TideDataDrivenMap" should exist
29 changes: 1 addition & 28 deletions examples/nuxt-app/test/fixtures/data-driven-map/csl/page.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,7 @@
"fields": ["suburb^3", "street^2", "offence_location"]
}
},
"userFilters": [
{
"id": "suburb",
"component": "TideSearchFilterDropdown",
"filter": {
"type": "terms",
"value": "suburb"
},
"aggregations": {
"field": "suburb",
"source": "elastic"
},
"props": {
"id": "suburb",
"label": "Elastic aggregation test",
"placeholder": "Select suburb",
"type": "RplFormDropdown",
"multiple": true,
"options": [
{
"id": "1",
"label": "Hard coded",
"value": "Hard coded"
}
]
}
}
],
"userFilters": [],
"globalFilters": [],
"tableConfig": {
"props": {
Expand Down
119 changes: 34 additions & 85 deletions examples/nuxt-app/test/fixtures/data-driven-map/schools/page.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "Schools",
"title": "Custom collection",
"changed": "2022-11-02T12:47:29+11:00",
"created": "2022-11-02T12:47:29+11:00",
"type": "landing_page",
Expand All @@ -16,6 +16,14 @@
},
"headerComponents": [],
"bodyComponents": [
{
"uuid": "a99aa287-7fac-430b-864e-3a1b044460b1",
"component": "TideLandingPageContent",
"id": "969",
"props": {
"html": "<p>This is a collection of grants which have some content above them</p>"
}
},
{
"uuid": "55555555-5555-5555-5555-555555555555",
"component": "TideDataDrivenMap",
Expand All @@ -24,109 +32,50 @@
"props": {
"searchListingConfig": {
"searchProvider": "elasticsearch",
"index": "sdp_data_pipelines_scl",
"index": "elasticsearch_index_production_node",
"resultsPerPage": 20,
"labels": {
"submit": "Search",
"placeholder": "Enter suburb, postcode, streetname or offence location"
}
},
"queryConfig": {
"multi_match": {
"query": "{{query}}",
"fields": ["suburb^3", "street^2", "offence_location"]
"placeholder": "Enter school name"
}
},
"userFilters": [
{
"id": "termFilter",
"component": "TideSearchFilterDropdown",
"filter": {
"type": "term",
"value": "termFilter.keyword"
},
"aggregations": {
"field": "termFilter",
"source": "taxonomy"
},
"props": {
"id": "termFilter",
"label": "Term filter example",
"placeholder": "Select a colour",
"multiple": true,
"options": [
{
"id": "1",
"label": "Red",
"value": "Red"
},
{
"id": "2",
"label": "Green",
"value": "Green"
},
{
"id": "3",
"label": "Blue",
"value": "Blue"
}
]
}
},
{
"id": "termsFilter",
"id": "pintypes",
"component": "TideSearchFilterDropdown",
"filter": {
"type": "terms",
"value": "termsFilter.keyword"
"value": "field_mappintype_value"
},
"aggregations": {
"field": "termsFilter",
"source": "taxonomy"
"field": "field_mappintype_value",
"source": "elastic"
},
"props": {
"id": "termsFilter",
"label": "Terms filter example",
"placeholder": "Select a colour",
"id": "pintypes",
"label": "Filter by",
"placeholder": "Select suburb",
"type": "RplFormDropdown",
"multiple": true,
"options": [
{
"id": "1",
"label": "Orange",
"value": "Orange"
},
{
"id": "2",
"label": "Purple",
"value": "Purple"
},
{
"id": "3",
"label": "Yellow",
"value": "Yellow"
}
]
"options": []
}
}
],
"globalFilters": [],
"globalFilters": [
{ "terms": { "type": ["project_infrastructure"] } },
{ "terms": { "field_node_site": [622] } },
{ "exists": { "field": "field_latitude_value" } }
],
"tableConfig": {
"props": {
"columns": [
{
"label": "Suburb",
"key": "suburb",
"isArray": false
},
{
"label": "Location",
"key": "street",
"isArray": false
"label": "Name",
"key": "title"
},
{
"label": "Last annual test",
"key": "last_annual_test",
"isArray": false
"label": "Project type",
"key": "field_mappintype_value"
}
]
}
Expand All @@ -135,15 +84,15 @@
"props": {
"popup": {
"title": {
"objKey": "suburb"
"objKey": "_source.title"
},
"content": {
"objKey": "suburb"
"objKey": "_source.field_about_project_processed"
}
},
"latObjPath": "_source.latitude",
"lngObjPath": "_source.longitude",
"titleObjPath": "_source.suburb"
"latObjPath": "_source.field_latitude_value[0]",
"lngObjPath": "_source.field_longitude_value[0]",
"titleObjPath": "_source.title[0]"
}
}
}
Expand Down
81 changes: 81 additions & 0 deletions packages/ripple-tide-search/components/TideSearchAddressLookup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<template>
<div class="tide-search-address-lookup">
<RplSearchBar
inputLabel="Enter a search term"
:submitLabel="false"
:inputValue="inputValue"
:suggestions="results"
:showNoResults="true"
:debounce="5000"
placeholder="Search by address, postcode or suburb"
:getSuggestionVal="(itm:any) => itm.name"
@submit="submitAction"
@update:input-value="onUpdate"
>
<template #suggestion="{ option: { option } }">
<span>{{ option.name }}</span>
<RplChip
v-if="option?.council"
class="rpl-u-margin-l-4"
:label="option?.council"
></RplChip>
</template>
</RplSearchBar>
</div>
</template>

<script setup lang="ts">
import { ref } from '#imports'
import { useDebounceFn } from '@vueuse/core'
import { useRippleEvent } from '@dpc-sdp/ripple-ui-core'
interface Props {
addresses: boolean
lgas: boolean
suburbs: boolean
}
const props = withDefaults(defineProps<Props>(), {
addresses: true,
lgas: true,
suburbs: true
})
const results = ref([])
const inputValue = ref('')
type addressResultType = {
name: string
latitude: number
longitude: number
}
const emit = defineEmits<{
(e: 'update', payload: addressResultType): void
}>()
const { emitRplEvent } = useRippleEvent('tide-address-lookup', emit)
async function submitAction(e: any) {
const item = e.value
emitRplEvent('update', item)
}
const onUpdate = useDebounceFn(async (q: string): Promise<void> => {
const res: { results: addressResultType[] } = await $fetch(
'/api/services/address',
{
query: {
q,
suburbs: props.suburbs,
addresses: props.addresses,
lgas: props.lgas
}
}
)
if (res.results && res.results.length > 0) {
results.value = res.results
} else if (q === '') {
results.value = []
}
}, 300)
</script>
Loading

0 comments on commit 08e417a

Please sign in to comment.