From a92a3574b3e4a92850b8542502dcf3836b1501cd Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Tue, 17 May 2022 12:11:53 +1000
Subject: Make search suggestions include non-alt-names

---
 src/components/SearchModal.vue | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

(limited to 'src/components/SearchModal.vue')

diff --git a/src/components/SearchModal.vue b/src/components/SearchModal.vue
index bc77a39..e78a2f1 100644
--- a/src/components/SearchModal.vue
+++ b/src/components/SearchModal.vue
@@ -5,7 +5,7 @@ import InfoIcon from './icon/InfoIcon.vue';
 import {LayoutNode} from '../layout';
 import type {TolMap} from '../tol';
 
-type SearchSugg = {name: string, altName: string}; // Represents a search string suggestion
+type SearchSugg = {name: string, canonicalName: string | null}; // Represents a search string suggestion
 type SearchSuggResponse = [SearchSugg[], boolean]; // Holds search suggestions and an indication of if there was more
 
 // Displays a search box, and sends search requests
@@ -46,7 +46,8 @@ export default defineComponent({
 			if (this.focusedSuggIdx == null){
 				this.resolveSearch((this.$refs.searchInput as HTMLInputElement).value.toLowerCase())
 			} else {
-				this.resolveSearch(this.searchSuggs[this.focusedSuggIdx].name);
+				let sugg = this.searchSuggs[this.focusedSuggIdx]
+				this.resolveSearch(sugg.canonicalName || sugg.name);
 			}
 		},
 		resolveSearch(tolNodeName: string){
@@ -159,11 +160,12 @@ export default defineComponent({
 			<div class="absolute top-[100%] w-full">
 				<div v-for="(sugg, idx) of searchSuggs"
 					:style="{backgroundColor: idx == focusedSuggIdx ? '#a3a3a3' : 'white'}"
-					class="border p-1 hover:underline hover:cursor-pointer" @click="resolveSearch(sugg.name)">
+					class="border p-1 hover:underline hover:cursor-pointer"
+					@click="resolveSearch(sugg.canonicalName || sugg.name)">
 					<info-icon :style="infoIconStyles"
 						class="float-right text-stone-500 hover:text-stone-900 hover:cursor-pointer"
-						@click.stop="onInfoIconClick(sugg.name)"/>
-					{{sugg.name == sugg.altName ? sugg.name : `${sugg.altName} (aka ${sugg.name})`}}
+						@click.stop="onInfoIconClick(sugg.canonicalName || sugg.name)"/>
+					{{sugg.canonicalName == null ? sugg.name : `${sugg.name} (aka ${sugg.canonicalName})`}}
 				</div>
 				<div v-if="searchHasMoreSuggs" class="bg-white px-1 text-center border">...</div>
 			</div>
-- 
cgit v1.2.3

