From e568bccd1a0d6f1deb1ef61f46786dbc546fda8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ole=20Volds=C3=A6ter?= <ole.voldsater@uib.no>
Date: Fri, 25 Sep 2020 12:56:36 +0200
Subject: [PATCH] =?UTF-8?q?paradigmer=20i=20samme=20b=C3=B8yningsgruppe=20?=
 =?UTF-8?q?i=20samme=20tabell?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/components/Header.vue | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/components/Header.vue b/src/components/Header.vue
index d35a6f00..97f4300f 100644
--- a/src/components/Header.vue
+++ b/src/components/Header.vue
@@ -6,12 +6,12 @@
       <details title="Klikk for å se bøyninger">
         <summary>{{group_list}}</summary>
         <div class="inflection">
-          <div v-for="(lemma, index) in lemmas" :key="index">
+          <div v-for="(lemma, index) in inflection_groups_by_lemma" :key="index">
             <h4>{{lemma.lemma}}</h4>
-            <component  v-for="(std, index) in lemma.paradigm_info"
-                        :key="index"
-                        :is="std.inflection_group.replace('/', '_')"
-                        :standardisations="[std]"></component>
+            <component  v-for="grp in Object.keys(lemma.inflection_groups)"
+                        :key="grp.replace('/', '_')"
+                        :is="grp.replace('/', '_')"
+                        :standardisations="lemma.inflection_groups[grp]"></component>
           </div>
         </div>
       </details>
@@ -41,6 +41,18 @@ export default {
   computed: {
     group_list: function() {
       return helpers.group_list(this.lemmas)
+    },
+    inflection_groups_by_lemma: function() {
+      return this.lemmas.map(
+        function(lemma_){
+          let inflection_groups = lemma_.paradigm_info.reduce((acc, std) =>  Object.assign(acc, {[std.inflection_group]: []}), {})
+          lemma_.paradigm_info.forEach(std => inflection_groups[std.inflection_group].push(std))
+          return {
+            lemma: lemma_.lemma,
+            inflection_groups: inflection_groups
+          }
+        }
+      )
     }
   },
   components: {
-- 
GitLab