]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
First draft
authorNicolas Lœuillet <nicolas@loeuillet.org>
Wed, 22 Apr 2020 08:05:12 +0000 (10:05 +0200)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Wed, 29 Apr 2020 14:39:29 +0000 (16:39 +0200)
app/Resources/static/themes/material/index.js
app/config/config.yml
src/Wallabag/CoreBundle/Controller/EntryController.php
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entry.html.twig

index d8f5628cd5cf866f2ebdb7c848ec7d91ee1d7764..185ac1e068c09abf0979f4c53e77a20356523002 100755 (executable)
@@ -120,4 +120,30 @@ $(document).ready(() => {
       });
     });
   }
+
+  $('.markasread').on('click', () => {
+    const article = document.getElementById('article');
+    const link = document.getElementById('link-archive');
+    const articleId = article.dataset.id;
+    const xhr = new XMLHttpRequest();
+
+    xhr.onload = function toggleArchive() {
+      if (xhr.status === 200) {
+        const previousStatus = document.getElementById('archive-icon').innerHTML;
+        let status = link.dataset.iconUnread;
+        let label = link.dataset.labelUnread;
+        if (previousStatus === 'unarchive') {
+          status = link.dataset.iconRead;
+          label = link.dataset.labelRead;
+        }
+        document.getElementById('archive-icon').innerHTML = status;
+        document.getElementById('archive-label').innerHTML = label;
+        window.Materialize.toast(xhr.responseText, 4000);
+      }
+    };
+
+    const url = `${Routing.generate('archive_entry', { id: articleId })}?some_var_name=true`;
+    xhr.open('GET', url, false);
+    xhr.send(null);
+  });
 });
index 4eea0531b4d9a77d1789165015c6108113699381..f87835cfd171ec77815993c45626c301c0271804 100644 (file)
@@ -373,6 +373,7 @@ fos_js_routing:
         - howto
         - fos_user_security_logout
         - new
+        - archive_entry
 
 jms_serializer:
     handlers:
index 9b2954e7d5d0525711ac4a61dec9cbae3f6eeda1..5fc6fc555e71ff6d9a7b1ffab3f07db333ed290b 100644 (file)
@@ -7,6 +7,7 @@ use Pagerfanta\Adapter\DoctrineORMAdapter;
 use Pagerfanta\Exception\OutOfRangeCurrentPageException;
 use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
 use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Component\HttpFoundation\JsonResponse;
 use Symfony\Component\HttpFoundation\Request;
 use Symfony\Component\Routing\Annotation\Route;
 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
@@ -371,6 +372,11 @@ class EntryController extends Controller
             $message = 'flashes.entry.notice.entry_archived';
         }
 
+        if ($request->query->get('some_var_name')) {
+
+            return new JsonResponse($this->get('translator')->trans($message));
+        }
+
         $this->get('session')->getFlashBag()->add(
             'notice',
             $message
@@ -381,6 +387,8 @@ class EntryController extends Controller
         return $this->redirect($redirectUrl);
     }
 
+    
+
     /**
      * Changes starred status for an entry.
      *
index 527b1afca471344c24e3eca51b9631e73334a2e9..899a8a7f20bedc0a32bdb08a72a4c7109b3854b0 100644 (file)
@@ -67,9 +67,9 @@
         {% endif %}
 
         <li class="bold hide-on-med-and-down">
-            <a class="waves-effect collapsible-header markasread" title="{{ markAsReadLabel|trans }}" href="{{ path('archive_entry', { 'id': entry.id }) }}" id="markAsRead">
-                <i class="material-icons small">{% if entry.isArchived == 0 %}done{% else %}unarchive{% endif %}</i>
-                <span>{{ markAsReadLabel|trans }}</span>
+            <a class="waves-effect collapsible-header markasread" title="{{ markAsReadLabel|trans }}" href="#" data-icon-read="done" data-icon-unread="unarchive" data-label-read="{{ 'entry.view.left_menu.set_as_read'|trans }}" data-label-unread="{{ 'entry.view.left_menu.set_as_unread'|trans }}" id="link-archive">
+                <i class="material-icons small" id="archive-icon">{% if entry.isArchived == 0 %}done{% else %}unarchive{% endif %}</i>
+                <span id="archive-label">{{ markAsReadLabel|trans }}</span>
             </a>
             <div class="collapsible-body"></div>
         </li>
 {% endblock %}
 
 {% block content %}
-    <div id="article">
+    <div id="article" data-id="{{ entry.id }}">
         <header class="mbm">
             <h1><span{% if entry.language is defined and entry.language is not null %} lang="{{ entry.getHTMLLanguage() }}"{% endif %}>{{ entry.title|striptags|default('entry.default_title'|trans)|raw }}</span> <a href="{{ path('edit', { 'id': entry.id }) }}" title="{{ 'entry.view.edit_title'|trans }}"><i class="material-icons grey-text">create</i></a></h1>
         </header>
             </ul>
         </div>
     </div>
-
 <script id="annotationroutes" type="application/json">
 {
     "prefix": "",