Add filter by map bounds checkbox to SelectionPanel
All checks were successful
Build Docker Image / build (push) Successful in 3m36s
All checks were successful
Build Docker Image / build (push) Successful in 3m36s
- Remove map search input (was wrong implementation) - Add checkbox "In map area" to filter list by visible map bounds - Filter products/hubs/suppliers when checkbox is enabled - Disable "load more" when filtering by bounds (client-side only)
This commit is contained in:
@@ -14,6 +14,17 @@
|
|||||||
:placeholder="searchPlaceholder"
|
:placeholder="searchPlaceholder"
|
||||||
class="input input-sm w-full bg-white/50 border-base-300/50 text-base-content placeholder:text-base-content/50"
|
class="input input-sm w-full bg-white/50 border-base-300/50 text-base-content placeholder:text-base-content/50"
|
||||||
/>
|
/>
|
||||||
|
<!-- Filter by map bounds checkbox -->
|
||||||
|
<label class="flex items-center gap-2 mt-2 text-sm cursor-pointer text-base-content/80 hover:text-base-content">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
:checked="filterByBounds"
|
||||||
|
class="checkbox checkbox-sm checkbox-primary"
|
||||||
|
@change="emit('update:filter-by-bounds', ($event.target as HTMLInputElement).checked)"
|
||||||
|
/>
|
||||||
|
<Icon name="lucide:map" size="14" />
|
||||||
|
<span>{{ $t('catalog.search.filterByMap') }}</span>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- List -->
|
<!-- List -->
|
||||||
@@ -96,12 +107,14 @@ const props = defineProps<{
|
|||||||
loading?: boolean
|
loading?: boolean
|
||||||
loadingMore?: boolean
|
loadingMore?: boolean
|
||||||
hasMore?: boolean
|
hasMore?: boolean
|
||||||
|
filterByBounds?: boolean
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
'select': [type: string, item: Item]
|
'select': [type: string, item: Item]
|
||||||
'close': []
|
'close': []
|
||||||
'load-more': []
|
'load-more': []
|
||||||
|
'update:filter-by-bounds': [value: boolean]
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|||||||
@@ -38,29 +38,6 @@
|
|||||||
<span class="text-white text-sm">{{ $t('common.loading') }}</span>
|
<span class="text-white text-sm">{{ $t('common.loading') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Map search input (top LEFT, next to panel or at left edge) -->
|
|
||||||
<div
|
|
||||||
class="absolute top-[116px] z-20 hidden lg:block"
|
|
||||||
:class="showPanel ? 'left-[420px]' : 'left-4'"
|
|
||||||
>
|
|
||||||
<div class="flex items-center gap-2 bg-white/80 backdrop-blur-md rounded-full shadow-lg border border-white/40 px-4 py-2 w-64">
|
|
||||||
<Icon name="lucide:search" size="18" class="text-base-content/60 flex-shrink-0" />
|
|
||||||
<input
|
|
||||||
v-model="mapSearchQuery"
|
|
||||||
type="text"
|
|
||||||
:placeholder="$t('catalog.search.searchOnMap')"
|
|
||||||
class="flex-1 bg-transparent outline-none text-sm text-base-content placeholder:text-base-content/50"
|
|
||||||
/>
|
|
||||||
<button
|
|
||||||
v-if="mapSearchQuery"
|
|
||||||
class="text-base-content/40 hover:text-base-content transition-colors"
|
|
||||||
@click="mapSearchQuery = ''"
|
|
||||||
>
|
|
||||||
<Icon name="lucide:x" size="16" />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- View toggle (top RIGHT overlay, below header) - works in both modes -->
|
<!-- View toggle (top RIGHT overlay, below header) - works in both modes -->
|
||||||
<div class="absolute top-[116px] right-4 z-20 hidden lg:block">
|
<div class="absolute top-[116px] right-4 z-20 hidden lg:block">
|
||||||
<div class="flex gap-1 bg-black/30 backdrop-blur-md rounded-lg p-1 border border-white/10">
|
<div class="flex gap-1 bg-black/30 backdrop-blur-md rounded-lg p-1 border border-white/10">
|
||||||
@@ -252,9 +229,6 @@ const mapRef = ref<{ flyTo: (lat: number, lng: number, zoom?: number) => void }
|
|||||||
// Selected item from map click
|
// Selected item from map click
|
||||||
const selectedMapItem = ref<MapItem | null>(null)
|
const selectedMapItem = ref<MapItem | null>(null)
|
||||||
|
|
||||||
// Map search query
|
|
||||||
const mapSearchQuery = ref('')
|
|
||||||
|
|
||||||
// Mobile panel state
|
// Mobile panel state
|
||||||
const mobilePanelExpanded = ref(false)
|
const mobilePanelExpanded = ref(false)
|
||||||
|
|
||||||
@@ -317,5 +291,5 @@ const flyTo = (lat: number, lng: number, zoom = 8) => {
|
|||||||
mapRef.value?.flyTo(lat, lng, zoom)
|
mapRef.value?.flyTo(lat, lng, zoom)
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({ flyTo })
|
defineExpose({ flyTo, currentBounds })
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<CatalogPage
|
<CatalogPage
|
||||||
|
ref="catalogPageRef"
|
||||||
:loading="isLoading"
|
:loading="isLoading"
|
||||||
:use-server-clustering="true"
|
:use-server-clustering="true"
|
||||||
:cluster-node-type="clusterNodeType"
|
:cluster-node-type="clusterNodeType"
|
||||||
@@ -8,6 +9,7 @@
|
|||||||
:items="[]"
|
:items="[]"
|
||||||
:show-panel="showPanel"
|
:show-panel="showPanel"
|
||||||
@select="onMapSelect"
|
@select="onMapSelect"
|
||||||
|
@bounds-change="onBoundsChange"
|
||||||
>
|
>
|
||||||
<!-- Panel slot - shows selection list OR quote results -->
|
<!-- Panel slot - shows selection list OR quote results -->
|
||||||
<template #panel>
|
<template #panel>
|
||||||
@@ -15,15 +17,17 @@
|
|||||||
<SelectionPanel
|
<SelectionPanel
|
||||||
v-if="selectMode"
|
v-if="selectMode"
|
||||||
:select-mode="selectMode"
|
:select-mode="selectMode"
|
||||||
:products="products"
|
:products="filteredProducts"
|
||||||
:hubs="hubs"
|
:hubs="filteredHubs"
|
||||||
:suppliers="suppliers"
|
:suppliers="filteredSuppliers"
|
||||||
:loading="selectionLoading"
|
:loading="selectionLoading"
|
||||||
:loading-more="selectionLoadingMore"
|
:loading-more="selectionLoadingMore"
|
||||||
:has-more="selectionHasMore"
|
:has-more="selectionHasMore && !filterByBounds"
|
||||||
|
:filter-by-bounds="filterByBounds"
|
||||||
@select="onSelectItem"
|
@select="onSelectItem"
|
||||||
@close="cancelSelect"
|
@close="cancelSelect"
|
||||||
@load-more="onLoadMore"
|
@load-more="onLoadMore"
|
||||||
|
@update:filter-by-bounds="filterByBounds = $event"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Quote results: show offers after search -->
|
<!-- Quote results: show offers after search -->
|
||||||
@@ -39,6 +43,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { GetOffersDocument } from '~/composables/graphql/public/exchange-generated'
|
import { GetOffersDocument } from '~/composables/graphql/public/exchange-generated'
|
||||||
|
import type { MapBounds } from '~/components/catalog/CatalogMap.vue'
|
||||||
|
|
||||||
definePageMeta({
|
definePageMeta({
|
||||||
layout: 'topnav'
|
layout: 'topnav'
|
||||||
@@ -49,6 +54,28 @@ const { execute } = useGraphQL()
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const localePath = useLocalePath()
|
const localePath = useLocalePath()
|
||||||
|
|
||||||
|
// Ref to CatalogPage for accessing bounds
|
||||||
|
const catalogPageRef = ref<{ currentBounds: Ref<MapBounds | null> } | null>(null)
|
||||||
|
|
||||||
|
// Filter by map bounds state
|
||||||
|
const filterByBounds = ref(false)
|
||||||
|
const currentMapBounds = ref<MapBounds | null>(null)
|
||||||
|
|
||||||
|
// Handle bounds change from map
|
||||||
|
const onBoundsChange = (bounds: MapBounds) => {
|
||||||
|
currentMapBounds.value = bounds
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if item is within map bounds
|
||||||
|
const isInBounds = (item: any, bounds: MapBounds | null): boolean => {
|
||||||
|
if (!bounds) return true
|
||||||
|
if (!item.latitude || !item.longitude) return false
|
||||||
|
const lat = Number(item.latitude)
|
||||||
|
const lng = Number(item.longitude)
|
||||||
|
return lat >= bounds.south && lat <= bounds.north
|
||||||
|
&& lng >= bounds.west && lng <= bounds.east
|
||||||
|
}
|
||||||
|
|
||||||
const {
|
const {
|
||||||
catalogMode,
|
catalogMode,
|
||||||
selectMode,
|
selectMode,
|
||||||
@@ -69,6 +96,22 @@ const { items: products, isLoading: productsLoading, isLoadingMore: productsLoad
|
|||||||
const { items: hubs, isLoading: hubsLoading, isLoadingMore: hubsLoadingMore, canLoadMore: hubsCanLoadMore, loadMore: loadMoreHubs, init: initHubs } = useCatalogHubs()
|
const { items: hubs, isLoading: hubsLoading, isLoadingMore: hubsLoadingMore, canLoadMore: hubsCanLoadMore, loadMore: loadMoreHubs, init: initHubs } = useCatalogHubs()
|
||||||
const { items: suppliers, isLoading: suppliersLoading, isLoadingMore: suppliersLoadingMore, canLoadMore: suppliersCanLoadMore, loadMore: loadMoreSuppliers, init: initSuppliers } = useCatalogSuppliers()
|
const { items: suppliers, isLoading: suppliersLoading, isLoadingMore: suppliersLoadingMore, canLoadMore: suppliersCanLoadMore, loadMore: loadMoreSuppliers, init: initSuppliers } = useCatalogSuppliers()
|
||||||
|
|
||||||
|
// Filtered items by map bounds
|
||||||
|
const filteredProducts = computed(() => {
|
||||||
|
if (!filterByBounds.value || !currentMapBounds.value) return products.value
|
||||||
|
return products.value.filter((p: any) => isInBounds(p, currentMapBounds.value))
|
||||||
|
})
|
||||||
|
|
||||||
|
const filteredHubs = computed(() => {
|
||||||
|
if (!filterByBounds.value || !currentMapBounds.value) return hubs.value
|
||||||
|
return hubs.value.filter((h: any) => isInBounds(h, currentMapBounds.value))
|
||||||
|
})
|
||||||
|
|
||||||
|
const filteredSuppliers = computed(() => {
|
||||||
|
if (!filterByBounds.value || !currentMapBounds.value) return suppliers.value
|
||||||
|
return suppliers.value.filter((s: any) => isInBounds(s, currentMapBounds.value))
|
||||||
|
})
|
||||||
|
|
||||||
// Selection loading state
|
// Selection loading state
|
||||||
const selectionLoading = computed(() => {
|
const selectionLoading = computed(() => {
|
||||||
if (selectMode.value === 'product') return productsLoading.value
|
if (selectMode.value === 'product') return productsLoading.value
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"searchProducts": "Search products...",
|
"searchProducts": "Search products...",
|
||||||
"searchSuppliers": "Search suppliers...",
|
"searchSuppliers": "Search suppliers...",
|
||||||
"searchHubs": "Search hubs...",
|
"searchHubs": "Search hubs...",
|
||||||
"searchOnMap": "Search on map..."
|
"filterByMap": "In map area"
|
||||||
},
|
},
|
||||||
"hero": {
|
"hero": {
|
||||||
"title": "Find the best offer",
|
"title": "Find the best offer",
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
"searchProducts": "Поиск товаров...",
|
"searchProducts": "Поиск товаров...",
|
||||||
"searchSuppliers": "Поиск поставщиков...",
|
"searchSuppliers": "Поиск поставщиков...",
|
||||||
"searchHubs": "Поиск хабов...",
|
"searchHubs": "Поиск хабов...",
|
||||||
"searchOnMap": "Поиск на карте..."
|
"filterByMap": "В области карты"
|
||||||
},
|
},
|
||||||
"hero": {
|
"hero": {
|
||||||
"title": "Найдите лучшее предложение",
|
"title": "Найдите лучшее предложение",
|
||||||
|
|||||||
Reference in New Issue
Block a user