Skip to content
Snippets Groups Projects
Commit 2ed40eab authored by Petr.Kalashnikov's avatar Petr.Kalashnikov
Browse files

Merge branch 'fikse_tomme_forklaringer' into 'master'

Fikse tomme forklaringer

See merge request spraksamlingane/beta.ordbok.uib.no!6
parents 998e8c62 c632bc8d
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@
<DefElement v-for="(element, index) in article.body.etymology" :dictionary="dictionary" :key="index" :body='element' @article-click="article_link_click" />
</ul>
</section>
<section class="definitions">
<section class="definitions" v-if="has_content">
<h3>{{def_label}}</h3>
<ol>
<Definition v-for="definition in article.body.definitions" :dictionary="dictionary" :level="1" :key="definition.id" :body='definition' @article-click="article_link_click" />
......@@ -55,6 +55,20 @@ function find_sub_articles(definition) {
return sub_art_list
}
function find_content(definition) {
let content_list = []
let sub_definitions = definition.elements.filter(el => el.type_ == 'definition')
sub_definitions.forEach((subdef, i) => {
content_list = content_list.concat(find_content(subdef))
})
let content_nodes = definition.elements.filter(el => ['explanation', 'example', 'compound_list'].includes(el.type_))
content_list = content_list.concat(content_nodes)
return content_list
}
export default {
name: 'Article',
props: {
......@@ -78,6 +92,9 @@ export default {
},
sub_articles: function() {
return this.article.body.definitions.reduce((acc, val) => acc.concat(find_sub_articles(val)), []).sort((s1, s2) => s1.lemmas[0].localeCompare(s2.lemmas[0]))
},
has_content: function() {
return this.article.body.definitions.reduce((acc, val) => acc.concat(find_content(val)), []).length > 0
}
},
components: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment