Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Språksamlingane
beta.ordbok.uib.no
Commits
a31dc85b
Commit
a31dc85b
authored
May 18, 2022
by
Henrik Askjer
Browse files
improve has_content
parent
f11c073d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/components/Article.vue
View file @
a31dc85b
...
...
@@ -67,19 +67,6 @@ function find_sub_articles(definition) {
}
}
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
'
,
...
...
@@ -202,15 +189,20 @@ export default {
else
{
return
}
}
,
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
}
,
for
(
const
definition
of
this
.
article
.
body
.
definitions
)
{
for
(
const
element
of
definition
.
elements
)
{
if
([
'
explanation
'
,
'
example
'
,
'
compound_list
'
,
'
definition
'
].
includes
(
element
.
type_
))
{
return
true
}
}
}
return
false
}
}
,
components
:
{
DefElement
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment