Merge pull request #2020 from wallabag/fix-number-entries-per-tag

Fix number of entries in tag/list
This commit is contained in:
Jeremy Benoist 2016-05-07 11:09:37 +02:00
commit f54de6817e
3 changed files with 14 additions and 2 deletions

View file

@ -117,4 +117,16 @@ class Tag
{ {
return $this->entries; return $this->entries;
} }
public function getEntriesByUserId($userId)
{
$filteredEntries = new ArrayCollection();
foreach ($this->entries as $entry) {
if ($entry->getUser()->getId() === $userId) {
$filteredEntries->add($entry);
}
}
return $filteredEntries;
}
} }

View file

@ -9,7 +9,7 @@
<ul> <ul>
{% for tag in tags %} {% for tag in tags %}
<li id="tag-{{ tag.id|e }}">{{tag.label}} ({{ tag.entries.getValues | length }})</li> <li id="tag-{{ tag.id|e }}">{{tag.label}} ({{ tag.getEntriesByUserId(app.user.id) | length }})</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endblock %} {% endblock %}

View file

@ -9,7 +9,7 @@
<br /> <br />
<ul class="row data"> <ul class="row data">
{% for tag in tags %} {% for tag in tags %}
<li id="tag-{{ tag.id|e }}" class="col l4 m6 s12">{{tag.label}} ({{ tag.entries.getValues | length }})</li> <li id="tag-{{ tag.id|e }}" class="col l4 m6 s12">{{tag.label}} ({{ tag.getEntriesByUserId(app.user.id) | length }})</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endblock %} {% endblock %}