virtual sample : add dynamic comments count attribute on track buttons
This commit is contained in:
parent
7153da14eb
commit
db7b6171f7
1 changed files with 9 additions and 0 deletions
|
|
@ -9,6 +9,7 @@
|
|||
:aria-controls="track.slug"
|
||||
:style="`--btn-image: url(${getFrontViewUrl(track)});`"
|
||||
@click="selectTrack(track)"
|
||||
:data-comments="getCommentsCount(track)"
|
||||
>
|
||||
<span>{{ track.title }}</span>
|
||||
</button>
|
||||
|
|
@ -136,6 +137,14 @@ function removeTrack(track) {
|
|||
(activeTrack) => activeTrack.title !== track.title
|
||||
);
|
||||
}
|
||||
|
||||
function getCommentsCount(track) {
|
||||
let count = 0;
|
||||
for (const file of track.files) {
|
||||
count += file?.comments?.length || 0;
|
||||
}
|
||||
return count > 0 ? count : undefined;
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue