aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2020-04-24 09:37:23 +0200
committerGitHub <noreply@github.com>2020-04-24 09:37:23 +0200
commit8a8a78a64c116caf81aaa4339906298bdc0e32e0 (patch)
tree43b1ec77eeb062ee618f017a3dc09cd42491c695 /src
parent31e3a233a457ee986d1cb347f7d02752159d5750 (diff)
parent467327771aea031c0ad6e7ab0e8f5a97ba69a8e2 (diff)
downloadwallabag-8a8a78a64c116caf81aaa4339906298bdc0e32e0.tar.gz
wallabag-8a8a78a64c116caf81aaa4339906298bdc0e32e0.tar.zst
wallabag-8a8a78a64c116caf81aaa4339906298bdc0e32e0.zip
Merge pull request #4326 from wallabag/mass-actions
Added mass actions for Material design in list view
Diffstat (limited to 'src')
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php42
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_mass_checkbox.html.twig3
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig1
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig17
4 files changed, 63 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index ba5bfbe2..9b2954e7 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -21,6 +21,48 @@ use Wallabag\CoreBundle\Form\Type\SearchEntryType;
21class EntryController extends Controller 21class EntryController extends Controller
22{ 22{
23 /** 23 /**
24 * @Route("/mass", name="mass_action")
25 *
26 * @return \Symfony\Component\HttpFoundation\Response
27 */
28 public function massAction(Request $request)
29 {
30 $em = $this->getDoctrine()->getManager();
31 $values = $request->request->all();
32
33 $action = 'toggle-read';
34 if (isset($values['toggle-star'])) {
35 $action = 'toggle-star';
36 } elseif (isset($values['delete'])) {
37 $action = 'delete';
38 }
39
40 if (isset($values['entry-checkbox'])) {
41 foreach ($values['entry-checkbox'] as $id) {
42 /** @var Entry * */
43 $entry = $this->get('wallabag_core.entry_repository')->findById((int) $id)[0];
44
45 $this->checkUserAction($entry);
46
47 if ('toggle-read' === $action) {
48 $entry->toggleArchive();
49 } elseif ('toggle-star' === $action) {
50 $entry->toggleStar();
51 } elseif ('delete' === $action) {
52 $this->get('event_dispatcher')->dispatch(EntryDeletedEvent::NAME, new EntryDeletedEvent($entry));
53 $em->remove($entry);
54 }
55 }
56
57 $em->flush();
58 }
59
60 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'));
61
62 return $this->redirect($redirectUrl);
63 }
64
65 /**
24 * @param int $page 66 * @param int $page
25 * 67 *
26 * @Route("/search/{page}", name="search", defaults={"page" = 1}) 68 * @Route("/search/{page}", name="search", defaults={"page" = 1})
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_mass_checkbox.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_mass_checkbox.html.twig
new file mode 100644
index 00000000..d35d8db1
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/Card/_mass_checkbox.html.twig
@@ -0,0 +1,3 @@
1<div class="entry-checkbox">
2 <input type="checkbox" data-js="entry-checkbox" name="entry-checkbox[]" value="{{ entry.id }}" />
3</div>
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig
index 6a095035..cb2f6f74 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/_card_list.html.twig
@@ -1,4 +1,5 @@
1<div class="card-stacked"> 1<div class="card-stacked">
2 {% include "@WallabagCore/themes/material/Entry/Card/_mass_checkbox.html.twig" with {'entry': entry} only %}
2 <div class="card-preview"> 3 <div class="card-preview">
3 <a href="{{ path('view', { 'id': entry.id }) }}"> 4 <a href="{{ path('view', { 'id': entry.id }) }}">
4 {% set previewClassModifier = entry.previewPicture ? '' : ' preview--default' %} 5 {% set previewClassModifier = entry.previewPicture ? '' : ' preview--default' %}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
index 0cd00cfd..f7912b1c 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
@@ -24,6 +24,7 @@
24 {% if currentRoute == 'homepage' %} 24 {% if currentRoute == 'homepage' %}
25 {% set currentRoute = 'unread' %} 25 {% set currentRoute = 'unread' %}
26 {% endif %} 26 {% endif %}
27 <form name="form_mass_action" action="{{ path('mass_action') }}" method="post">
27 <div class="results"> 28 <div class="results">
28 <div class="nb-results"> 29 <div class="nb-results">
29 {{ 'entry.list.number_on_the_page'|transchoice(entries.count) }} 30 {{ 'entry.list.number_on_the_page'|transchoice(entries.count) }}
@@ -38,6 +39,21 @@
38 </div> 39 </div>
39 40
40 <ul class="{% if listMode == 1 %}collection{% else %}row data{% endif %}"> 41 <ul class="{% if listMode == 1 %}collection{% else %}row data{% endif %}">
42
43 <li class="mass-buttons">
44 {% if entries.count > 0 and listMode == 1 %}
45 <span>
46 <input id="selectAll" type="checkbox" data-toggle="[data-js='entry-checkbox']" data-js="checkboxes-toggle" />&nbsp;
47 </span>
48
49 <span>
50 <button class="btn cyan darken-1" type="submit" name="toggle-read" title="{{ 'entry.list.toogle_as_read'|trans }}"><i class="material-icons">done</i></button>
51 <button class="btn cyan darken-1" type="submit" name="toggle-star" title="{{ 'entry.list.toogle_as_star'|trans }}" ><i class="material-icons">star</i></button>
52 <button class="btn cyan darken-1" type="submit" name="delete" title="{{ 'entry.list.delete'|trans }}"><i class="material-icons">delete</i></button>
53 </span>
54 {% endif %}
55 </li>
56
41 {% for entry in entries %} 57 {% for entry in entries %}
42 <li id="entry-{{ entry.id|e }}" class="entry col {% if listMode == 0 %}l3 m6{% else %}collection-item{% endif %} s12"> 58 <li id="entry-{{ entry.id|e }}" class="entry col {% if listMode == 0 %}l3 m6{% else %}collection-item{% endif %} s12">
43 {% if listMode == 1 %} 59 {% if listMode == 1 %}
@@ -50,6 +66,7 @@
50 </li> 66 </li>
51 {% endfor %} 67 {% endfor %}
52 </ul> 68 </ul>
69</form>
53 70
54 {% if entries.getNbPages > 1 %} 71 {% if entries.getNbPages > 1 %}
55 <div class="results"> 72 <div class="results">