Fix number of entries in tag/list

Fix #2006
This commit is contained in:
Nicolas Lœuillet 2016-05-03 21:12:40 +02:00
parent 9b57bac8b9
commit 12c697562e
No known key found for this signature in database
GPG key ID: 5656BE27E1E34D0A
3 changed files with 14 additions and 2 deletions

View file

@ -117,4 +117,16 @@ class Tag
{
return $this->entries;
}
public function getEntriesByUser($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>
{% 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.getEntriesByUser(app.user.id) | length }})</li>
{% endfor %}
</ul>
{% endblock %}

View file

@ -9,7 +9,7 @@
<br />
<ul class="row data">
{% 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.getEntriesByUser(app.user.id) | length }})</li>
{% endfor %}
</ul>
{% endblock %}