From d8c29e8dcc925b6013880f66e690fa6b006d9154 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Fri, 6 Jan 2023 20:23:45 +1100
Subject: Implement filtering by event categories

Filter events in display and search suggestions.
Make server queries allow specification of multiple categories.
Make settings modal avoid disabling all categories.
---
 src/components/SearchModal.vue | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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

diff --git a/src/components/SearchModal.vue b/src/components/SearchModal.vue
index 65d2496..96d23bd 100644
--- a/src/components/SearchModal.vue
+++ b/src/components/SearchModal.vue
@@ -28,7 +28,7 @@
 </template>
 
 <script setup lang="ts">
-import {ref, computed, onMounted, onUnmounted, PropType} from 'vue';
+import {ref, computed, onMounted, PropType} from 'vue';
 import SearchIcon from './icon/SearchIcon.vue';
 import InfoIcon from './icon/InfoIcon.vue';
 import {HistEvent, queryServer, EventInfoJson, jsonToEventInfo, SuggResponseJson} from '../lib';
@@ -93,6 +93,11 @@ async function onInput(){
 		input: input.value,
 		limit: String(store.searchSuggLimit),
 	});
+	// Check if any event categories are disabled
+	if (Object.values(store.ctgs).some((b: boolean) => !b)){
+		let visibleCtgs = Object.entries(store.ctgs).filter(([, enabled]) => enabled).map(([ctg, ]) => ctg);
+		urlParams.append('ctgs', visibleCtgs.join('.'));
+	}
 	// Code for querying server
 	pendingReqParams.value = urlParams;
 	pendingReqInput.value = input.value;
-- 
cgit v1.2.3

