1- <script setup>
1+ <script setup lang="ts" >
22import {
33 faAngleDown ,
44 faAngleUp ,
@@ -8,18 +8,20 @@ import {
88 faWrench ,
99} from " @fortawesome/free-solid-svg-icons" ;
1010import { FontAwesomeIcon } from " @fortawesome/vue-fontawesome" ;
11- import ToolFavoriteButton from " components/Tool/Buttons/ToolFavoriteButton" ;
12- import { useFormattedToolHelp } from " composables/formattedToolHelp" ;
1311import { computed , ref } from " vue" ;
1412
13+ import { useFormattedToolHelp } from " @/composables/formattedToolHelp" ;
14+
1515import GButton from " ../BaseComponents/GButton.vue" ;
1616import GLink from " @/components/BaseComponents/GLink.vue" ;
17+ import ToolFavoriteButton from " @/components/Tool/Buttons/ToolFavoriteButton.vue" ;
1718
19+ // TODO: Refactor props to use defineProps with types (best practices)
1820const props = defineProps ({
1921 id: { type: String , required: true },
2022 name: { type: String , required: true },
2123 section: { type: String , required: true },
22- ontologies: { type: Array , default: null },
24+ ontologies: { type: Array < string > , default: null },
2325 description: { type: String , default: null },
2426 summary: { type: String , default: null },
2527 help: { type: String , default: null },
@@ -30,7 +32,11 @@ const props = defineProps({
3032 owner: { type: String , default: null },
3133});
3234
33- const emit = defineEmits ([" open" ]);
35+ // TODO: For tool open emit, consider adding event as param to allow for opening tool in new tab
36+ const emit = defineEmits <{
37+ (e : " open" ): void ;
38+ (e : " apply-filter" , filter : string , value : string ): void ;
39+ }>();
3440
3541const showHelp = ref (false );
3642
@@ -42,6 +48,10 @@ const formattedToolHelp = computed(() => {
4248 return " " ;
4349 }
4450});
51+
52+ /** We add double quotes to the section filter since the backend Whoosh search
53+ * requires it for exact matches, and the `Filtering` class only does single quotes. */
54+ const quotedSection = computed (() => (props .section ? ` "${props .section }" ` : " " ));
4555 </script >
4656
4757<template >
@@ -86,7 +96,8 @@ const formattedToolHelp = computed(() => {
8696 <div class =" tool-list-item-content" >
8797 <div class =" d-flex flex-gapx-1 py-2" >
8898 <span v-if =" props.section" class =" tag info" >
89- <b >Section:</b > <GLink thin :to =" `/tools/list?section=${props.section}`" >{{ section }}</GLink >
99+ <b >Section:</b >
100+ <GLink thin @click =" () => emit('apply-filter', 'section', quotedSection)" >{{ section }}</GLink >
90101 </span >
91102
92103 <span v-if =" !props.local" class =" tag info" >
@@ -101,12 +112,13 @@ const formattedToolHelp = computed(() => {
101112
102113 <span v-if =" props.owner" class =" tag success" >
103114 <FontAwesomeIcon :icon =" faUser" />
104- <b >Owner:</b > <GLink thin :to =" `/tools/list?owner=${props.owner}`" >{{ props.owner }}</GLink >
115+ <b >Owner:</b >
116+ <GLink thin @click =" () => emit('apply-filter', 'owner', props.owner)" >{{ props.owner }}</GLink >
105117 </span >
106118
107119 <span v-if =" props.ontologies && props.ontologies.length > 0" >
108120 <span v-for =" ontology in props.ontologies" :key =" ontology" class =" tag toggle" >
109- <GLink thin :to = " `/tools/list?ontology=${ ontology}` " >{{ ontology }}</GLink >
121+ <GLink thin @click = " () => emit('apply-filter', ' ontology', ontology) " >{{ ontology }}</GLink >
110122 </span >
111123 </span >
112124 </div >
0 commit comments