diff --git a/src/components/Header.vue b/src/components/Header.vue index d35a6f00685f3e7015c182ad7a12e69193b191b9..97f4300fb0ac578f41d369ab07e2b77ee6eced54 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: {