Merge pull request #3536 from wallabag/tag-link-3534

Fix broken link to remove tags from entries
This commit is contained in:
Nicolas Lœuillet 2018-01-03 20:37:57 +01:00 committed by GitHub
commit 410216f435
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 3 deletions

View file

@ -9,7 +9,7 @@
<div class="{{ subClass|default('original grey-text') }}"> <div class="{{ subClass|default('original grey-text') }}">
<a href="{{ entry.url|e }}" target="_blank" title="{{ entry.domainName|removeWww }}" class="tool grey-text">{{ entry.domainName|removeWww }}</a> <a href="{{ entry.url|e }}" target="_blank" title="{{ entry.domainName|removeWww }}" class="tool grey-text">{{ entry.domainName|removeWww }}</a>
{% if withTags is defined %} {% if withTags is defined %}
{% include "@WallabagCore/themes/material/Entry/_tags.html.twig" with {'tags': entry.tags | slice(0, 3), 'listClass': ' hide-on-med-and-down'} only %} {% include "@WallabagCore/themes/material/Entry/_tags.html.twig" with {'tags': entry.tags | slice(0, 3), 'entryId': entry.id, 'listClass': ' hide-on-med-and-down'} only %}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View file

@ -4,7 +4,7 @@
<li class="chip"> <li class="chip">
<a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a> <a href="{{ path('tag_entries', {'slug': tag.slug}) }}">{{ tag.label }}</a>
{% if withRemove %} {% if withRemove %}
<a href="{{ path('remove_tag', { 'entry': entry.id, 'tag': tag.id }) }}" onclick="return confirm('{{ 'entry.confirm.delete_tag'|trans|escape('js') }}')"> <a href="{{ path('remove_tag', { 'entry': entryId, 'tag': tag.id }) }}" onclick="return confirm('{{ 'entry.confirm.delete_tag'|trans|escape('js') }}')">
<i class="material-icons vertical-align-middle">delete</i> <i class="material-icons vertical-align-middle">delete</i>
</a> </a>
{% endif %} {% endif %}

View file

@ -268,7 +268,7 @@
</li> </li>
{% endif %} {% endif %}
</ul> </ul>
{% include "@WallabagCore/themes/material/Entry/_tags.html.twig" with {'tags': entry.tags, 'withRemove': true} only %} {% include "@WallabagCore/themes/material/Entry/_tags.html.twig" with {'tags': entry.tags, 'entryId': entry.id, 'withRemove': true} only %}
</div> </div>
<div class="input-field nav-panel-add-tag" style="display: none"> <div class="input-field nav-panel-add-tag" style="display: none">

View file

@ -6,6 +6,7 @@ use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
use Wallabag\CoreBundle\Entity\Config; use Wallabag\CoreBundle\Entity\Config;
use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\SiteCredential; use Wallabag\CoreBundle\Entity\SiteCredential;
use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Helper\ContentProxy; use Wallabag\CoreBundle\Helper\ContentProxy;
class EntryControllerTest extends WallabagCoreTestCase class EntryControllerTest extends WallabagCoreTestCase
@ -1478,4 +1479,23 @@ class EntryControllerTest extends WallabagCoreTestCase
$this->assertSame('email_tracking.pdf', $content->getTitle()); $this->assertSame('email_tracking.pdf', $content->getTitle());
$this->assertSame('example.com', $content->getDomainName()); $this->assertSame('example.com', $content->getDomainName());
} }
public function testEntryDeleteTagLink()
{
$this->logInAs('admin');
$client = $this->getClient();
$em = $client->getContainer()->get('doctrine.orm.entity_manager');
$entry = $em->getRepository('WallabagCoreBundle:Entry')->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
$tag = $entry->getTags()[0];
$crawler = $client->request('GET', '/view/' . $entry->getId());
// As long as the deletion link of a tag is following
// a link to the tag view, we take the second one to retrieve
// the deletion link of the first tag
$link = $crawler->filter('body div#article div.tools ul.tags li.chip a')->extract('href')[1];
$this->assertSame(sprintf('/remove-tag/%s/%s', $entry->getId(), $tag->getId()), $link);
}
} }