diff options
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/AncestryBar.vue | 2 | ||||
| -rw-r--r-- | src/components/SearchModal.vue | 9 | ||||
| -rw-r--r-- | src/components/Tile.vue | 4 | ||||
| -rw-r--r-- | src/components/TileInfoModal.vue | 40 |
4 files changed, 21 insertions, 34 deletions
diff --git a/src/components/AncestryBar.vue b/src/components/AncestryBar.vue index 8f31900..a56568c 100644 --- a/src/components/AncestryBar.vue +++ b/src/components/AncestryBar.vue @@ -3,7 +3,7 @@ import {defineComponent, PropType} from 'vue'; import Tile from './Tile.vue' import {LayoutNode} from '../layout'; import type {LayoutOptions} from '../layout'; -import type {TolMap} from '../tol'; +import type {TolMap} from '../lib'; // Displays a sequence of nodes, representing ancestors from a tree-of-life root to a currently-active root export default defineComponent({ diff --git a/src/components/SearchModal.vue b/src/components/SearchModal.vue index 9ea10c8..4ea5cea 100644 --- a/src/components/SearchModal.vue +++ b/src/components/SearchModal.vue @@ -3,10 +3,7 @@ import {defineComponent, PropType} from 'vue'; import SearchIcon from './icon/SearchIcon.vue'; import InfoIcon from './icon/InfoIcon.vue'; import {LayoutNode} from '../layout'; -import type {TolMap} from '../tol'; - -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 +import type {TolMap, SearchSugg, SearchSuggResponse} from '../lib'; // Displays a search box, and sends search requests export default defineComponent({ @@ -107,8 +104,8 @@ export default defineComponent({ return response.json() }) .then((results: SearchSuggResponse) => { - this.searchSuggs = results[0]; - this.searchHasMoreSuggs = results[1]; + this.searchSuggs = results.suggs; + this.searchHasMoreSuggs = results.hasMore; this.focusedSuggIdx = null; }) .catch(error => { diff --git a/src/components/Tile.vue b/src/components/Tile.vue index 9bbff51..29b4856 100644 --- a/src/components/Tile.vue +++ b/src/components/Tile.vue @@ -3,8 +3,8 @@ import {defineComponent, PropType} from 'vue'; import InfoIcon from './icon/InfoIcon.vue'; import {LayoutNode} from '../layout'; import type {LayoutOptions} from '../layout'; -import type {TolMap} from '../tol'; -import {TolNode} from '../tol'; +import type {TolMap} from '../lib'; +import {TolNode} from '../lib'; import {capitalizeWords} from '../lib'; // Displays one, or a hierarchy of, tree-of-life nodes, as a 'tile' diff --git a/src/components/TileInfoModal.vue b/src/components/TileInfoModal.vue index 45b3192..bd6cc5d 100644 --- a/src/components/TileInfoModal.vue +++ b/src/components/TileInfoModal.vue @@ -4,18 +4,10 @@ import CloseIcon from './icon/CloseIcon.vue'; import Tile from './Tile.vue' import {LayoutNode} from '../layout'; import type {LayoutOptions} from '../layout'; -import type {TolMap} from '../tol'; -import {TolNode} from '../tol'; +import type {TolMap} from '../lib'; +import {TolNode, DescInfo, ImgInfo, TileInfoResponse} from '../lib'; import {capitalizeWords} from '../lib'; -type DescInfo = {text: string, fromRedirect: boolean, wikiId: number, fromDbp: boolean}; -type ImgInfo = {imgId: number, imgSrc: 'eol' | 'enwiki', url: string, license: string, artist: string, credit: string} -type TileInfoResponse = { - tolNode: null | TolNode, - descData: null | DescInfo | [DescInfo, DescInfo], - imgData: null | ImgInfo | [ImgInfo, ImgInfo], -}; - // Displays information about a tree-of-life node export default defineComponent({ data(){ @@ -123,18 +115,16 @@ export default defineComponent({ fetch(url.toString()) .then(response => response.json()) .then(obj => { - if (obj != null){ - this.tolNode = obj.nodeObj; - if (!Array.isArray(obj.descData)){ - this.descInfo = obj.descData; - } else { - [this.descInfo1, this.descInfo2] = obj.descData; - } - if (!Array.isArray(obj.imgData)){ - this.imgInfo = obj.imgData; - } else { - [this.imgInfo1, this.imgInfo2] = obj.imgData; - } + this.tolNode = obj.tolNode; + if (!Array.isArray(obj.descData)){ + this.descInfo = obj.descData; + } else { + [this.descInfo1, this.descInfo2] = obj.descData; + } + if (!Array.isArray(obj.imgData)){ + this.imgInfo = obj.imgData; + } else { + [this.imgInfo1, this.imgInfo2] = obj.imgData; } }); }, @@ -164,7 +154,7 @@ export default defineComponent({ <div v-else-if="!Array.isArray(tolNode.imgName)"> <div :style="imgStyles"/> <ul v-if="imgInfo != null"> - <li>Obtained via: {{imgInfo.imgSrc}}</li> + <li>Obtained via: {{imgInfo.src}}</li> <li>License: <a :href="licenseToUrl(imgInfo.license)">{{imgInfo.license}}</a></li> <li><a :href="imgInfo.url" class="underline">Source URL</a></li> <li>Artist: {{imgInfo.artist}}</li> @@ -174,7 +164,7 @@ export default defineComponent({ <div v-else> <div v-if="tolNode.imgName[0] != null" :style="firstImgStyles"/> <ul v-if="imgInfo1 != null"> - <li>Obtained via: {{imgInfo1.imgSrc}}</li> + <li>Obtained via: {{imgInfo1.src}}</li> <li>License: <a :href="licenseToUrl(imgInfo1.license)">{{imgInfo1.license}}</a></li> <li><a :href="imgInfo1.url" class="underline">Source URL</a></li> <li>Artist: {{imgInfo1.artist}}</li> @@ -182,7 +172,7 @@ export default defineComponent({ </ul> <div v-if="tolNode.imgName[1] != null" :style="secondImgStyles"/> <ul v-if="imgInfo2 != null"> - <li>Obtained via: {{imgInfo2.imgSrc}}</li> + <li>Obtained via: {{imgInfo2.src}}</li> <li>License: <a :href="licenseToUrl(imgInfo2.license)">{{imgInfo2.license}}</a></li> <li><a :href="imgInfo2.url" class="underline">Source URL</a></li> <li>Artist: {{imgInfo2.artist}}</li> |
