From 2ab48497797441164e7f57fca2660097d93398ca Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Mon, 25 Apr 2022 01:33:08 +1000
Subject: Adapt to handle open-tree-of-life data

Added data_otol/ with script that converts data from 'Open Tree of Life' release 13.4 into a JSON form.
Moved old tree-of-life data and images into data_tol_old/.
Added TolMap type to tol.ts, changed TolNode, and adapted other code to handle it.
Temporarily disabling tile images until image data is added.
---
 src/components/SearchModal.vue | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

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

diff --git a/src/components/SearchModal.vue b/src/components/SearchModal.vue
index 91f06ae..22b6896 100644
--- a/src/components/SearchModal.vue
+++ b/src/components/SearchModal.vue
@@ -1,15 +1,13 @@
 <script lang="ts">
 import {defineComponent, PropType} from 'vue';
 import SearchIcon from './icon/SearchIcon.vue';
-import {TolNode} from '../tol';
 import {LayoutNode} from '../layout';
+import type {TolMap} from '../tol';
 
 // Displays a search box, and sends search requests
 export default defineComponent({
 	props: {
-		// Map from tree-of-life node names to TolNode objects
-		tolMap: {type: Object as PropType<Map<string,TolNode>>, required: true},
-		// Options
+		tolMap: {type: Object as PropType<TolMap>, required: true},
 		uiOpts: {type: Object, required: true},
 	},
 	methods: {
@@ -20,15 +18,14 @@ export default defineComponent({
 		},
 		onSearchEnter(){
 			let input = this.$refs.searchInput as HTMLInputElement;
-			let tolNode = this.tolMap.get(input.value);
-			if (tolNode == null){
+			if (this.tolMap.hasOwnProperty(input.value)){
+				this.$emit('search-node', input.value);
+			} else {
 				input.value = '';
 				// Trigger failure animation
 				input.classList.remove('animate-red-then-fade');
 				input.offsetWidth; // Triggers reflow
 				input.classList.add('animate-red-then-fade');
-			} else {
-				this.$emit('search-node', tolNode);
 			}
 		},
 		focusInput(){
-- 
cgit v1.2.3

