aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2017-05-15 10:15:39 +0200
committerThomas Citharel <tcit@tcit.fr>2017-05-25 19:09:52 +0200
commit4fa9470f36b9dc8b000b06c7742c921a1df71e42 (patch)
treec317e4c728891574bf8df49a237751bedc4a6d74
parent22a4b20ed04a9c709fbbe3e254ad8b2d7757a38b (diff)
downloadwallabag-4fa9470f36b9dc8b000b06c7742c921a1df71e42.tar.gz
wallabag-4fa9470f36b9dc8b000b06c7742c921a1df71e42.tar.zst
wallabag-4fa9470f36b9dc8b000b06c7742c921a1df71e42.zip
changes and default actions
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
-rwxr-xr-xapp/Resources/static/themes/material/index.js10
-rw-r--r--src/Wallabag/CoreBundle/Controller/NotificationsController.php19
-rw-r--r--src/Wallabag/CoreBundle/Notifications/InfoAction.php13
-rw-r--r--src/Wallabag/CoreBundle/Notifications/NoAction.php13
-rw-r--r--src/Wallabag/CoreBundle/Notifications/OkAction.php13
-rw-r--r--src/Wallabag/CoreBundle/Notifications/YesAction.php13
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/Notification/notifications.html.twig31
7 files changed, 93 insertions, 19 deletions
diff --git a/app/Resources/static/themes/material/index.js b/app/Resources/static/themes/material/index.js
index e16749f6..ba4552b8 100755
--- a/app/Resources/static/themes/material/index.js
+++ b/app/Resources/static/themes/material/index.js
@@ -77,12 +77,12 @@ $(document).ready(() => {
77 $('.progress .determinate').css('width', `${scrollPercent}%`); 77 $('.progress .determinate').css('width', `${scrollPercent}%`);
78 }); 78 });
79 79
80 $('.notification').on('click', () => { 80 $('.notification .notification-action').on('click', (e) => {
81 $.ajax({ 81 const id = parseInt($(e.target).attr('data-id'), 10);
82 url: Routing.generate('notification-archive-all'), 82 fetch(Routing.generate('notification-archive', { notification: id }), { credentials: 'same-origin' }).then(() => {
83 method: 'GET', 83 $(e.target).parents('.notification').removeClass('light-blue lighten-5');
84 }).done(() => {
85 $('#notifications').sideNav('hide'); 84 $('#notifications').sideNav('hide');
86 }); 85 });
86 return true;
87 }); 87 });
88}); 88});
diff --git a/src/Wallabag/CoreBundle/Controller/NotificationsController.php b/src/Wallabag/CoreBundle/Controller/NotificationsController.php
index 24870b37..0717ff47 100644
--- a/src/Wallabag/CoreBundle/Controller/NotificationsController.php
+++ b/src/Wallabag/CoreBundle/Controller/NotificationsController.php
@@ -6,6 +6,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller; 6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\Response; 8use Symfony\Component\HttpFoundation\Response;
9use Wallabag\CoreBundle\Entity\Notification;
9 10
10class NotificationsController extends Controller 11class NotificationsController extends Controller
11{ 12{
@@ -35,4 +36,22 @@ class NotificationsController extends Controller
35 36
36 return $this->redirectToRoute('notifications-all'); 37 return $this->redirectToRoute('notifications-all');
37 } 38 }
39
40 /**
41 * @Route("/notifications/read/{notification}", name="notification-archive")
42 *
43 * @param Notification $notification
44 * @return Response
45 */
46 public function markNotificationsAsReadAction(Notification $notification)
47 {
48 $em = $this->getDoctrine()->getManager();
49
50 $notification->setRead(true);
51
52 $em->persist($notification);
53 $em->flush();
54
55 return $this->redirectToRoute('notifications-all');
56 }
38} 57}
diff --git a/src/Wallabag/CoreBundle/Notifications/InfoAction.php b/src/Wallabag/CoreBundle/Notifications/InfoAction.php
new file mode 100644
index 00000000..56567903
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/InfoAction.php
@@ -0,0 +1,13 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5class InfoAction extends Action {
6
7 public function __construct($link)
8 {
9 $this->link = $link;
10 $this->label = 'Info';
11 $this->type = Action::TYPE_INFO;
12 }
13}
diff --git a/src/Wallabag/CoreBundle/Notifications/NoAction.php b/src/Wallabag/CoreBundle/Notifications/NoAction.php
new file mode 100644
index 00000000..73c92796
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/NoAction.php
@@ -0,0 +1,13 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5class NoAction extends Action {
6
7 public function __construct($link)
8 {
9 $this->link = $link;
10 $this->label = 'No';
11 $this->type = Action::TYPE_NO;
12 }
13}
diff --git a/src/Wallabag/CoreBundle/Notifications/OkAction.php b/src/Wallabag/CoreBundle/Notifications/OkAction.php
new file mode 100644
index 00000000..2b4dde03
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/OkAction.php
@@ -0,0 +1,13 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5class OkAction extends Action {
6
7 public function __construct($link)
8 {
9 $this->link = $link;
10 $this->label = 'OK';
11 $this->type = Action::TYPE_OK;
12 }
13}
diff --git a/src/Wallabag/CoreBundle/Notifications/YesAction.php b/src/Wallabag/CoreBundle/Notifications/YesAction.php
new file mode 100644
index 00000000..340733ff
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Notifications/YesAction.php
@@ -0,0 +1,13 @@
1<?php
2
3namespace Wallabag\CoreBundle\Notifications;
4
5class YesAction extends Action {
6
7 public function __construct($link)
8 {
9 $this->link = $link;
10 $this->label = 'Yes';
11 $this->type = Action::TYPE_YES;
12 }
13}
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/Notification/notifications.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/Notification/notifications.html.twig
index bc72c704..7c0f8c44 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/Notification/notifications.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/Notification/notifications.html.twig
@@ -7,7 +7,7 @@
7 <div class="col l6 offset-l3"> 7 <div class="col l6 offset-l3">
8 <ul class="collection"> 8 <ul class="collection">
9 {% for notification in notifications | slice(0, 10) %} 9 {% for notification in notifications | slice(0, 10) %}
10 <li class="collection-item avatar{% if not notification.read %} light-blue lighten-5{% else %} grey-text{% endif %}"> 10 <li class="notification collection-item avatar{% if not notification.read %} light-blue lighten-5{% else %} grey-text{% endif %}">
11 <i class="material-icons circle">{% spaceless %} 11 <i class="material-icons circle">{% spaceless %}
12 {% if notification.type == constant('TYPE_ADMIN', notification) %} 12 {% if notification.type == constant('TYPE_ADMIN', notification) %}
13 build 13 build
@@ -18,20 +18,23 @@
18 {% endif %} 18 {% endif %}
19 {% endspaceless %}</i> 19 {% endspaceless %}</i>
20 <span class="title">{{ notification.title }}</span> 20 <span class="title">{{ notification.title }}</span>
21 <p><em>{{ notification.timestamp | date }}</p> 21 <p><em>{{ notification.timestamp | date }}</em></p>
22 <div class="secondary-content"> 22 <div class="secondary-content">
23 {% for action in notification.actions %} 23 {% if not notification.read %}
24 <a class="btn waves-effect waves-light {% spaceless %} 24 {% for action in notification.actions %}
25 {% if action.type == constant('TYPE_OK', action) %} 25 <a class="notification-action btn waves-effect waves-light {% spaceless %}
26 {% elseif action.type == constant('TYPE_YES', action) %} 26 {% if action.type == constant('TYPE_OK', action) %}
27 cyan 27 {% elseif action.type == constant('TYPE_YES', action) %}
28 {% elseif action.type == constant('TYPE_NO', action) %} 28 cyan
29 red 29 {% elseif action.type == constant('TYPE_NO', action) %}
30 {% elseif action.type == constant('TYPE_INFO', action) %} 30 red
31 blue-grey 31 {% elseif action.type == constant('TYPE_INFO', action) %}
32 {% endif %} 32 blue-grey
33 {% endspaceless %}" href="{{ action.link }}">{{ action.label }}</a> 33 {% endif %}
34 {% endfor %} 34 {% endspaceless %}" data-id="{{ notification.id }}" href="{{ action.link }}">{{ action.label }}</a>
35 {% endfor %}
36 <button class="notification-action waves-effect waves-teal btn-flat" data-id="{{ notification.id }}"><i data-id="{{ notification.id }}" class="material-icons">check</i></button>
37 {% endif %}
35 </div> 38 </div>
36 </li> 39 </li>
37 {% endfor %} 40 {% endfor %}