diff --git a/afrc/src/afrc/Search/SearchPage.vue b/afrc/src/afrc/Search/SearchPage.vue index cb74c6f..3329957 100644 --- a/afrc/src/afrc/Search/SearchPage.vue +++ b/afrc/src/afrc/Search/SearchPage.vue @@ -12,6 +12,7 @@ import arches from "arches"; import SimpleSearchFilter from "@/afrc/Search/components/SimpleSearchFilter.vue"; import SearchResultItem from "@/afrc/Search/components/SearchResultItem.vue"; +import SearchItemDetails from "@/afrc/Search/components/SearchItemDetails.vue"; import InteractiveMap from "@/afrc/Search/components/InteractiveMap/InteractiveMap.vue"; import { fetchMapData } from "@/afrc/Search/api.ts"; import type { GenericObject } from "@/afrc/Search/types"; @@ -21,6 +22,7 @@ let query = getQueryObject(null); let queryString = ref(JSON.stringify(query)); let searchResults = ref([]); let resultsCount = ref("calculating..."); +let resultSelected = ref(""); const showMap = ref(false); const basemaps: Ref = ref([]); const overlays: Ref = ref([]); @@ -31,6 +33,7 @@ const toast = useToast(); const { $gettext } = useGettext(); provide("resultsSelected", resultsSelected); +provide("resultSelected", resultSelected); watch(queryString, () => { doQuery(); @@ -181,7 +184,11 @@ onMounted(async () => { /> - +
+ +
{ :overlays="overlays" :sources="sources" :include-drawer="false" + :popup-enabled="false" />
@@ -260,6 +268,7 @@ section.afrc-search-results-panel { flex-grow: 1; margin: 15px; overflow-y: auto; + min-width: 350px; } .search-result-list { display: flex; diff --git a/afrc/src/afrc/Search/api.ts b/afrc/src/afrc/Search/api.ts index 2654d2f..172117c 100644 --- a/afrc/src/afrc/Search/api.ts +++ b/afrc/src/afrc/Search/api.ts @@ -60,5 +60,15 @@ export const createRequest = (url: string) => { }; }; +export const fetchResourceData = (resourceId: string) => { + const url = `${arches.urls["api_resources"](resourceId)}?format=json&v=beta`; + return createRequest(url)(); +}; + +export const fetchImageData = (imageResourceIds: string[]) => { + const url = `${arches.urls["api-file-data"]}?resourceids=${imageResourceIds.join(",")}`; + return createRequest(url)(); +}; + export const fetchSettings = createRequest(arches.urls["api-settings"]); export const fetchMapData = createRequest(arches.urls["api-map-data"]); diff --git a/afrc/src/afrc/Search/components/InteractiveMap/InteractiveMap.vue b/afrc/src/afrc/Search/components/InteractiveMap/InteractiveMap.vue index 2dfef91..4ea7a33 100644 --- a/afrc/src/afrc/Search/components/InteractiveMap/InteractiveMap.vue +++ b/afrc/src/afrc/Search/components/InteractiveMap/InteractiveMap.vue @@ -33,6 +33,7 @@ const props = defineProps<{ basemaps: Basemap[]; sources: MapSource[]; includeDrawer: boolean; + popupEnabled: boolean; }>(); const map: Ref = ref(null); @@ -116,6 +117,7 @@ function updateSelectedDrawnFeature(feature: Feature) { :overlays="overlays" :sources="sources" :is-drawing-enabled="true" + :is-popup-enabled="popupEnabled" @map-initialized=" (mapInstance) => { map = mapInstance; diff --git a/afrc/src/afrc/Search/components/InteractiveMap/components/MapComponent.vue b/afrc/src/afrc/Search/components/InteractiveMap/components/MapComponent.vue index 8d6f06f..df9bc98 100644 --- a/afrc/src/afrc/Search/components/InteractiveMap/components/MapComponent.vue +++ b/afrc/src/afrc/Search/components/InteractiveMap/components/MapComponent.vue @@ -66,6 +66,7 @@ interface Props { isDrawingEnabled?: boolean; drawnFeatures?: Feature[]; drawnFeaturesBuffer?: Buffer; + isPopupEnabled?: boolean; } const props = withDefaults(defineProps(), { @@ -76,6 +77,7 @@ const props = withDefaults(defineProps(), { isDrawingEnabled: false, drawnFeatures: () => [], drawnFeaturesBuffer: undefined, + isPopupEnabled: false, }); const { @@ -86,9 +88,11 @@ const { isDrawingEnabled, drawnFeatures, drawnFeaturesBuffer, + isPopupEnabled, } = props; let resultsSelected = inject("resultsSelected") as Ref; +let resultSelected = inject("resultSelected") as Ref; const emits = defineEmits([ "mapInitialized", @@ -143,15 +147,17 @@ watch( }, ); -watch(clickedFeatures, () => { - if (popupInstance.value) { - popupInstance.value.remove(); - } - popupInstance.value = new maplibregl.Popup() - .setLngLat(clickedCoordinates.value) - .setDOMContent(popupContainer.value!.$el) - .addTo(map.value!); -}); +if (isPopupEnabled) { + watch(clickedFeatures, () => { + if (popupInstance.value) { + popupInstance.value.remove(); + } + popupInstance.value = new maplibregl.Popup() + .setLngLat(clickedCoordinates.value) + .setDOMContent(popupContainer.value!.$el) + .addTo(map.value!); + }); +} onMounted(() => { createMap(); @@ -386,6 +392,7 @@ function addOverlayToMap(overlay: MapLayer) { clickedCoordinates.value = [e.lngLat.lng, e.lngLat.lat]; clickedFeatures.value = features; resultsSelected.value = []; + resultSelected.value = ""; const uniqueResourceIds = new Set( features.map( (feature) => @@ -393,8 +400,10 @@ function addOverlayToMap(overlay: MapLayer) { ), ); resultsSelected.value = Array.from(uniqueResourceIds); + resultSelected.value = resultsSelected.value[0]; } else { resultsSelected.value = []; + resultSelected.value = ""; } }; diff --git a/afrc/src/afrc/Search/components/MapView.vue b/afrc/src/afrc/Search/components/MapView.vue deleted file mode 100644 index aaa40b4..0000000 --- a/afrc/src/afrc/Search/components/MapView.vue +++ /dev/null @@ -1,19 +0,0 @@ - - - - - diff --git a/afrc/src/afrc/Search/components/SearchItemDetails.vue b/afrc/src/afrc/Search/components/SearchItemDetails.vue new file mode 100644 index 0000000..da70979 --- /dev/null +++ b/afrc/src/afrc/Search/components/SearchItemDetails.vue @@ -0,0 +1,158 @@ + + + + + \ No newline at end of file diff --git a/afrc/src/afrc/Search/components/SearchResultItem.vue b/afrc/src/afrc/Search/components/SearchResultItem.vue index fba9f7c..e77f341 100644 --- a/afrc/src/afrc/Search/components/SearchResultItem.vue +++ b/afrc/src/afrc/Search/components/SearchResultItem.vue @@ -7,6 +7,7 @@ import Button from "primevue/button"; import arches from "arches"; const resultsSelected = inject("resultsSelected") as Ref; +const resultSelected = inject("resultSelected") as Ref; const props = defineProps({ searchResult: { @@ -15,13 +16,17 @@ const props = defineProps({ }, }); +function highlightResult(resourceid: string) { + if (!resultSelected.value) { + resultsSelected.value = [resourceid]; + } +} + function selectResult(resourceid: string) { + resultSelected.value = resourceid; resultsSelected.value = [resourceid]; } -function clearResult() { - resultsSelected.value = []; -}