@@ -4,7 +4,7 @@ import { ref, computed, watch } from 'vue'
44const props = defineProps ({
55 results: {
66 type: Object ,
7- default : () => ({ matches: [], divisions: [] })
7+ default : () => ({ matches: [], divisions: [], searchTerm : ' ' })
88 }
99})
1010
@@ -16,6 +16,26 @@ const sortedResults = computed(() => {
1616 return [... props .results .matches ].sort ((a , b ) => a .name .localeCompare (b .name ))
1717})
1818
19+ // Compute the results title based on the type of search
20+ const resultsTitle = computed (() => {
21+ if (props .results .matches .length === 0 ) {
22+ return ' No Results'
23+ }
24+
25+ // If there's a search term, it's a text-based search
26+ if (props .results .searchTerm ) {
27+ return ` Search Results for "${ props .results .searchTerm } " - ${ props .results .matches .length } Results`
28+ }
29+
30+ // If there's exactly one division, it's from a map click
31+ if (props .results .divisions .length === 1 ) {
32+ return ` Division ${ props .results .divisions [0 ]} - ${ props .results .matches .length } Results`
33+ }
34+
35+ // Default case
36+ return ` ${ props .results .matches .length } Results`
37+ })
38+
1939// Watch for changes in results to auto-expand/collapse
2040watch (() => props .results .matches .length , (newCount ) => {
2141 // Auto-expand if there are any results
@@ -37,7 +57,7 @@ const toggleExpand = () => {
3757<template >
3858 <div class =" search-results" :class =" { expanded: isExpanded }" >
3959 <div class =" results-header" @click =" toggleExpand" >
40- <span class =" result-count" >{{ props.results.matches.length }} Results </span >
60+ <span class =" result-count" >{{ resultsTitle }}</span >
4161 <button class =" expand-button" >
4262 {{ isExpanded ? '▼' : '▲' }}
4363 </button >
0 commit comments