]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Add isPublic filter on entries
authorJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 10 Jun 2017 13:00:52 +0000 (15:00 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Sat, 10 Jun 2017 13:00:52 +0000 (15:00 +0200)
16 files changed:
src/Wallabag/CoreBundle/Entity/Entry.php
src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
src/Wallabag/CoreBundle/Resources/translations/messages.da.yml
src/Wallabag/CoreBundle/Resources/translations/messages.de.yml
src/Wallabag/CoreBundle/Resources/translations/messages.en.yml
src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/translations/messages.it.yml
src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml
src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml
src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/material/Entry/entries.html.twig
tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php

index 9a7dd4e7b77e43613e7a1048a847fda7afb724d4..365030c7b8b79bcb85e3de039866d5fb57606fad 100644 (file)
@@ -684,6 +684,16 @@ class Entry
         $this->uid = null;
     }
 
+    /**
+     * Used in the entries filter so it's more explicit for the end user than the uid.
+     *
+     * @return bool
+     */
+    public function isPublic()
+    {
+        return null !== $this->uid;
+    }
+
     /**
      * @return string
      */
index 556578d1a7bf6cc896d2888a07dd70c503a85c26..6a4c485f6d696f4525c354c1865ea3d7c0a6b3e4 100644 (file)
@@ -150,6 +150,20 @@ class EntryFilterType extends AbstractType
                 },
                 'label' => 'entry.filters.preview_picture_label',
             ])
+            ->add('isPublic', CheckboxFilterType::class, [
+                'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
+                    if (false === $values['value']) {
+                        return;
+                    }
+
+                    // is_public isn't a real field
+                    // we should use the "uid" field to determine if the entry has been made public
+                    $expression = $filterQuery->getExpr()->isNotNull($values['alias'].'.uid');
+
+                    return $filterQuery->createCondition($expression);
+                },
+                'label' => 'entry.filters.is_public_label',
+            ])
             ->add('language', ChoiceFilterType::class, [
                 'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())),
                 'label' => 'entry.filters.language_label',
index 5e7afe27b13f6905a255b2d3af768d34ee3a5078..02dd04f2e4e18f0d4ed7e5581c6472e71715f2f7 100644 (file)
@@ -186,6 +186,8 @@ entry:
         unread_label: 'Ulæst'
         preview_picture_label: 'Har et vist billede'
         preview_picture_help: 'Forhåndsvis billede'
+        # is_public_label: 'Has a public link'
+        # is_public_help: 'Public link'
         language_label: 'Sprog'
         # http_status_label: 'HTTP status'
         reading_time:
index 00468575967ea1563c08dc9a6262b3e1d8a0a272..f6ccdae0ace50ebfbcdf732d3e6c59eabd593581 100644 (file)
@@ -187,6 +187,8 @@ entry:
         unread_label: 'Ungelesene'
         preview_picture_label: 'Vorschaubild vorhanden'
         preview_picture_help: 'Vorschaubild'
+        # is_public_label: 'Has a public link'
+        # is_public_help: 'Public link'
         language_label: 'Sprache'
         http_status_label: 'HTTP-Status'
         reading_time:
index 572084c175c27bf35cba6a08019630c4e8655616..902c3046e39cbecc5e729f58192f98cb7b495b86 100644 (file)
@@ -187,6 +187,8 @@ entry:
         unread_label: 'Unread'
         preview_picture_label: 'Has a preview picture'
         preview_picture_help: 'Preview picture'
+        is_public_label: 'Has a public link'
+        is_public_help: 'Public link'
         language_label: 'Language'
         http_status_label: 'HTTP status'
         reading_time:
index 0f2a4a7b207c55494c4ce8bbb8cd1b4d0a1b4518..afd6a7b15e94036cc27b6f25633787a9e1e9747f 100644 (file)
@@ -187,6 +187,8 @@ entry:
         unread_label: 'Sin leer'
         preview_picture_label: 'Tiene imagen de previsualización'
         preview_picture_help: 'Imagen de previsualización'
+        # is_public_label: 'Has a public link'
+        # is_public_help: 'Public link'
         language_label: 'Idioma'
         http_status_label: 'Código de estado HTTP'
         reading_time:
index a8900489d82dc6d7ffec197feab20cf6c92bce1e..545514b3b3c0533d8377354125f82089ac727d9a 100644 (file)
@@ -187,6 +187,8 @@ entry:
         unread_label: 'خوانده‌نشده'
         preview_picture_label: 'دارای عکس پیش‌نمایش'
         preview_picture_help: 'پیش‌نمایش عکس'
+        # is_public_label: 'Has a public link'
+        # is_public_help: 'Public link'
         language_label: 'زبان'
         # http_status_label: 'HTTP status'
         reading_time:
index 6969b67b68d8b1fd05921b0ff2e236882774f6a6..e9e75efa3f8b4cd8a80b3f7686597e7d8608c568 100644 (file)
@@ -187,6 +187,8 @@ entry:
         unread_label: "Non lus"
         preview_picture_label: "A une photo"
         preview_picture_help: "Photo"
+        is_public_label: 'A une lien public'
+        is_public_help: 'Lien public'
         language_label: "Langue"
         http_status_label: "Statut HTTP"
         reading_time:
index c20070570114c648f6a7014f0d50347554559764..0597d3e3a5a30f64d4720cf88848423cb4cb51c7 100644 (file)
@@ -187,6 +187,8 @@ entry:
         # unread_label: 'Unread'
         preview_picture_label: "Ha un'immagine di anteprima"
         preview_picture_help: 'Immagine di anteprima'
+        # is_public_label: 'Has a public link'
+        # is_public_help: 'Public link'
         language_label: 'Lingua'
         # http_status_label: 'HTTP status'
         reading_time:
index 3ac472d03731651802a2025d9fb7bf58dbe5dae3..c172a0f6b1d1c49498c8f4e16c6095112ccb9734 100644 (file)
@@ -187,6 +187,8 @@ entry:
         unread_label: 'Pas legits'
         preview_picture_label: 'A un imatge'
         preview_picture_help: 'Imatge'
+        # is_public_label: 'Has a public link'
+        # is_public_help: 'Public link'
         language_label: 'Lenga'
         http_status_label: 'Estatut HTTP'
         reading_time:
index fa6723871eaa85c1891dde04dbc8d25c355f075f..82d167671ac492356519e72fe32fb332a735c6e8 100644 (file)
@@ -187,6 +187,8 @@ entry:
         unread_label: 'Nieprzeczytane'
         preview_picture_label: 'Posiada podgląd obrazu'
         preview_picture_help: 'Podgląd obrazu'
+        # is_public_label: 'Has a public link'
+        # is_public_help: 'Public link'
         language_label: 'Język'
         http_status_label: 'Status HTTP'
         reading_time:
index 896ccb04d4579ff447eeea7f0fcafde08a647c75..b75567d62562c7971ddd7b88617134c8caaae4b8 100644 (file)
@@ -187,6 +187,8 @@ entry:
         unread_label: 'Não Lido'
         preview_picture_label: 'Possui uma imagem de preview'
         preview_picture_help: 'Imagem de preview'
+        # is_public_label: 'Has a public link'
+        # is_public_help: 'Public link'
         language_label: 'Idioma'
         # http_status_label: 'HTTP status'
         reading_time:
index c447dc9bf65e25b7743b400ff31bc82aa96ca4e3..95df573dd3261a885245632623451dc996e383d8 100644 (file)
@@ -187,6 +187,8 @@ entry:
         unread_label: 'Necitite'
         preview_picture_label: 'Are o imagine de previzualizare'
         preview_picture_help: 'Previzualizare imagine'
+        # is_public_label: 'Has a public link'
+        # is_public_help: 'Public link'
         language_label: 'Limbă'
         # http_status_label: 'HTTP status'
         reading_time:
index 0ba6f4f48371bbada89e51027550159141a1b43d..6c26d5bf4f716861408a0abd29677bf5f753ffec 100644 (file)
                     {{ form_widget(form.previewPicture) }}
                     {{ form_label(form.previewPicture) }}
                 </div>
+
+                <div class="input-field">
+                    {{ form_widget(form.isPublic) }}
+                    {{ form_label(form.isPublic) }}
+                </div>
             </div>
 
             <div id="filter-language" class="filter-group">
index 6f657b1807f44dac95af9ad98637f4f2ad53d6b3..5ba420575a759d46325420ca2cdd8fe8e7c7565c 100644 (file)
                     {{ form_label(form.previewPicture) }}
                 </div>
 
+                <div class="col s12">
+                    <label>{{ 'entry.filters.is_public_help'|trans }}</label>
+                </div>
+
+                <div class="input-field col s12 with-checkbox">
+                    {{ form_widget(form.isPublic) }}
+                    {{ form_label(form.isPublic) }}
+                </div>
+
                 <div class="col s12">
                     {{ form_label(form.language) }}
                 </div>
                 <div class="col s12">
                     {{ form_label(form.readingTime) }}
                 </div>
+
                 <div class="input-field col s6">
                     {{ form_widget(form.readingTime.left_number, {'type': 'number'}) }}
                     <label for="entry_filter_readingTime_left_number">{{ 'entry.filters.reading_time.from'|trans }}</label>
                 </div>
+
                 <div class="input-field col s6">
                     {{ form_widget(form.readingTime.right_number, {'type': 'number'}) }}
                     <label for="entry_filter_readingTime_right_number">{{ 'entry.filters.reading_time.to'|trans }}</label>
index 8f5c372d83bc92356b2ab8e9daec60fb371a3640..853f37f2378cabbcc75a7ba3352aaefad98d4e7b 100644 (file)
@@ -860,6 +860,20 @@ class EntryControllerTest extends WallabagCoreTestCase
         $this->assertCount(1, $crawler->filter('div[class=entry]'));
     }
 
+    public function testFilterOnIsPublic()
+    {
+        $this->logInAs('admin');
+        $this->useTheme('baggy');
+        $client = $this->getClient();
+
+        $crawler = $client->request('GET', '/unread/list');
+        $form = $crawler->filter('button[id=submit-filter]')->form();
+        $form['entry_filter[isPublic]']->tick();
+
+        $crawler = $client->submit($form);
+        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+    }
+
     public function testPreviewPictureFilter()
     {
         $this->logInAs('admin');