From 691040e999766f56004b72667924a721101a0552 Mon Sep 17 00:00:00 2001
From: Henrik Askjer <henrik.askjer@uib.no>
Date: Mon, 11 Oct 2021 16:41:16 +0200
Subject: [PATCH] add pos selection

---
 src/components/Autocomplete.vue   |  2 +-
 src/components/DictionaryView.vue | 48 +++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/src/components/Autocomplete.vue b/src/components/Autocomplete.vue
index 9cf14acb..8249f9d1 100644
--- a/src/components/Autocomplete.vue
+++ b/src/components/Autocomplete.vue
@@ -92,7 +92,7 @@
           this.items.push({q: q, label: q, time: time, search: search})
         }
         let self = this
-        self.api.get('suggest?', {params: {q: q, dict: self.$parent.lang, n: 80, scope: 'w', stage: self.$parent.stage}})
+        self.api.get('suggest?', {params: {q: q, dict: self.$parent.lang, n: 80, scope: 'w', stage: self.$parent.stage, wc: self.$parent.pos_selected.tag}})
             .then(async (response) => {
                         if (self.$refs.autocomplete.searchInput == q & self.suggesting) {
 
diff --git a/src/components/DictionaryView.vue b/src/components/DictionaryView.vue
index dbf6de10..d850a523 100644
--- a/src/components/DictionaryView.vue
+++ b/src/components/DictionaryView.vue
@@ -1,6 +1,7 @@
 <template>
   <main>
     <div class="search_container">
+      <div class="top_bar" fluid>
       <div class="lang_select_container">
         <v-radio-group row v-model="lang" @change="update_lang_form">
           <template v-slot:label tabindex="1">
@@ -28,6 +29,23 @@
             </template>
           </v-radio>
         </v-radio-group>
+      </div>
+        <div class="pos_select_container">
+          <v-select
+            dense
+            rounded
+            disable-lookup
+            flat
+            return-object
+            item-text="label"
+            outlined
+            hide-details=""
+            :menu-props="{maxHeight: $vuetify.breakpoint.name === 'xs' ? 190 : 500, transition: 'fade-transition', allowOverflow: true}"
+            v-model="pos_selected"
+            :items="pos"
+            label="Avgrens etter ordklasse"
+          ></v-select>
+        </div>
       </div>
       <Autocomplete v-on:submit="select_result" :api="get_search_endpoint">
       </Autocomplete>
@@ -96,6 +114,19 @@ const api = setup({
 })
 
 
+const posOptions = [
+  {label: "Alle ordklasser"},
+  {label: "substantiv", tag: "NOUN"},
+  {label: "pronomen", tag: "PRON"},
+  {label: "determinativ", tag: "DET"},
+  {label: "adjektiv", tag: "ADJ"},
+  {label: "konjunksjon", tag: "CCONJ"},
+  {label: "subjunksjon", tag: "SCONJ"},
+  {label: "adverb", tag: "ADV"},
+  {label: "preposisjon", tag: "ADP"},
+  {label: "verb", tag: "VERB"},
+  {label: "interjeksjon", tag: "INTJ"},
+]
 
 
 
@@ -232,6 +263,8 @@ export default {
       article_key: 0,
       search_results: [],
       lang: 'bob,nob',
+      pos_selected: {label: "Alle ordklasser"},
+      pos: posOptions,
       waiting_for_articles: true,
       waiting_for_metadata: true,
       article: null,
@@ -449,10 +482,25 @@ div.monthly details, div.monthly h3 {
   color: var(--v-primary-base);
 }
 
+.top_bar {
+  display: -webkit-box;
+  -webkit-box-orient: horizontal;
+  flex-direction: row;
+  flex-wrap: wrap;
+  vertical-align: bottom !important;
+  padding-bottom: 10px;
+}
+
 .lang_select_container {
   padding-left: 10px;
 }
 
+.pos_select_container {
+  padding-left: 10px;
+  padding-right: 10px;
+  padding-bottom: 0px;
+}
+
 li.suggestion {
   font-weight: bold;
   padding-left: 20px;
-- 
GitLab