diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-06-10 15:00:52 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-06-10 15:00:52 +0200 |
commit | e8911f7c09fa9d8009d7c7ee9fb0c181d2ffbc31 (patch) | |
tree | b778069a347addc274496020f9c2bc9327320d0d | |
parent | 873f6b8e03079d11fab541aa5b0bc6f8fe2d645e (diff) | |
download | wallabag-e8911f7c09fa9d8009d7c7ee9fb0c181d2ffbc31.tar.gz wallabag-e8911f7c09fa9d8009d7c7ee9fb0c181d2ffbc31.tar.zst wallabag-e8911f7c09fa9d8009d7c7ee9fb0c181d2ffbc31.zip |
Add isPublic filter on entries
16 files changed, 76 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 9a7dd4e7..365030c7 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -685,6 +685,16 @@ class Entry | |||
685 | } | 685 | } |
686 | 686 | ||
687 | /** | 687 | /** |
688 | * Used in the entries filter so it's more explicit for the end user than the uid. | ||
689 | * | ||
690 | * @return bool | ||
691 | */ | ||
692 | public function isPublic() | ||
693 | { | ||
694 | return null !== $this->uid; | ||
695 | } | ||
696 | |||
697 | /** | ||
688 | * @return string | 698 | * @return string |
689 | */ | 699 | */ |
690 | public function getHttpStatus() | 700 | public function getHttpStatus() |
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index 556578d1..6a4c485f 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | |||
@@ -150,6 +150,20 @@ class EntryFilterType extends AbstractType | |||
150 | }, | 150 | }, |
151 | 'label' => 'entry.filters.preview_picture_label', | 151 | 'label' => 'entry.filters.preview_picture_label', |
152 | ]) | 152 | ]) |
153 | ->add('isPublic', CheckboxFilterType::class, [ | ||
154 | 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { | ||
155 | if (false === $values['value']) { | ||
156 | return; | ||
157 | } | ||
158 | |||
159 | // is_public isn't a real field | ||
160 | // we should use the "uid" field to determine if the entry has been made public | ||
161 | $expression = $filterQuery->getExpr()->isNotNull($values['alias'].'.uid'); | ||
162 | |||
163 | return $filterQuery->createCondition($expression); | ||
164 | }, | ||
165 | 'label' => 'entry.filters.is_public_label', | ||
166 | ]) | ||
153 | ->add('language', ChoiceFilterType::class, [ | 167 | ->add('language', ChoiceFilterType::class, [ |
154 | 'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())), | 168 | 'choices' => array_flip($this->repository->findDistinctLanguageByUser($this->user->getId())), |
155 | 'label' => 'entry.filters.language_label', | 169 | 'label' => 'entry.filters.language_label', |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 5e7afe27..02dd04f2 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | |||
@@ -186,6 +186,8 @@ entry: | |||
186 | unread_label: 'Ulæst' | 186 | unread_label: 'Ulæst' |
187 | preview_picture_label: 'Har et vist billede' | 187 | preview_picture_label: 'Har et vist billede' |
188 | preview_picture_help: 'Forhåndsvis billede' | 188 | preview_picture_help: 'Forhåndsvis billede' |
189 | # is_public_label: 'Has a public link' | ||
190 | # is_public_help: 'Public link' | ||
189 | language_label: 'Sprog' | 191 | language_label: 'Sprog' |
190 | # http_status_label: 'HTTP status' | 192 | # http_status_label: 'HTTP status' |
191 | reading_time: | 193 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index 00468575..f6ccdae0 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | |||
@@ -187,6 +187,8 @@ entry: | |||
187 | unread_label: 'Ungelesene' | 187 | unread_label: 'Ungelesene' |
188 | preview_picture_label: 'Vorschaubild vorhanden' | 188 | preview_picture_label: 'Vorschaubild vorhanden' |
189 | preview_picture_help: 'Vorschaubild' | 189 | preview_picture_help: 'Vorschaubild' |
190 | # is_public_label: 'Has a public link' | ||
191 | # is_public_help: 'Public link' | ||
190 | language_label: 'Sprache' | 192 | language_label: 'Sprache' |
191 | http_status_label: 'HTTP-Status' | 193 | http_status_label: 'HTTP-Status' |
192 | reading_time: | 194 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 572084c1..902c3046 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | |||
@@ -187,6 +187,8 @@ entry: | |||
187 | unread_label: 'Unread' | 187 | unread_label: 'Unread' |
188 | preview_picture_label: 'Has a preview picture' | 188 | preview_picture_label: 'Has a preview picture' |
189 | preview_picture_help: 'Preview picture' | 189 | preview_picture_help: 'Preview picture' |
190 | is_public_label: 'Has a public link' | ||
191 | is_public_help: 'Public link' | ||
190 | language_label: 'Language' | 192 | language_label: 'Language' |
191 | http_status_label: 'HTTP status' | 193 | http_status_label: 'HTTP status' |
192 | reading_time: | 194 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 0f2a4a7b..afd6a7b1 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | |||
@@ -187,6 +187,8 @@ entry: | |||
187 | unread_label: 'Sin leer' | 187 | unread_label: 'Sin leer' |
188 | preview_picture_label: 'Tiene imagen de previsualización' | 188 | preview_picture_label: 'Tiene imagen de previsualización' |
189 | preview_picture_help: 'Imagen de previsualización' | 189 | preview_picture_help: 'Imagen de previsualización' |
190 | # is_public_label: 'Has a public link' | ||
191 | # is_public_help: 'Public link' | ||
190 | language_label: 'Idioma' | 192 | language_label: 'Idioma' |
191 | http_status_label: 'Código de estado HTTP' | 193 | http_status_label: 'Código de estado HTTP' |
192 | reading_time: | 194 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index a8900489..545514b3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | |||
@@ -187,6 +187,8 @@ entry: | |||
187 | unread_label: 'خواندهنشده' | 187 | unread_label: 'خواندهنشده' |
188 | preview_picture_label: 'دارای عکس پیشنمایش' | 188 | preview_picture_label: 'دارای عکس پیشنمایش' |
189 | preview_picture_help: 'پیشنمایش عکس' | 189 | preview_picture_help: 'پیشنمایش عکس' |
190 | # is_public_label: 'Has a public link' | ||
191 | # is_public_help: 'Public link' | ||
190 | language_label: 'زبان' | 192 | language_label: 'زبان' |
191 | # http_status_label: 'HTTP status' | 193 | # http_status_label: 'HTTP status' |
192 | reading_time: | 194 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 6969b67b..e9e75efa 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | |||
@@ -187,6 +187,8 @@ entry: | |||
187 | unread_label: "Non lus" | 187 | unread_label: "Non lus" |
188 | preview_picture_label: "A une photo" | 188 | preview_picture_label: "A une photo" |
189 | preview_picture_help: "Photo" | 189 | preview_picture_help: "Photo" |
190 | is_public_label: 'A une lien public' | ||
191 | is_public_help: 'Lien public' | ||
190 | language_label: "Langue" | 192 | language_label: "Langue" |
191 | http_status_label: "Statut HTTP" | 193 | http_status_label: "Statut HTTP" |
192 | reading_time: | 194 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index c2007057..0597d3e3 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | |||
@@ -187,6 +187,8 @@ entry: | |||
187 | # unread_label: 'Unread' | 187 | # unread_label: 'Unread' |
188 | preview_picture_label: "Ha un'immagine di anteprima" | 188 | preview_picture_label: "Ha un'immagine di anteprima" |
189 | preview_picture_help: 'Immagine di anteprima' | 189 | preview_picture_help: 'Immagine di anteprima' |
190 | # is_public_label: 'Has a public link' | ||
191 | # is_public_help: 'Public link' | ||
190 | language_label: 'Lingua' | 192 | language_label: 'Lingua' |
191 | # http_status_label: 'HTTP status' | 193 | # http_status_label: 'HTTP status' |
192 | reading_time: | 194 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index 3ac472d0..c172a0f6 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | |||
@@ -187,6 +187,8 @@ entry: | |||
187 | unread_label: 'Pas legits' | 187 | unread_label: 'Pas legits' |
188 | preview_picture_label: 'A un imatge' | 188 | preview_picture_label: 'A un imatge' |
189 | preview_picture_help: 'Imatge' | 189 | preview_picture_help: 'Imatge' |
190 | # is_public_label: 'Has a public link' | ||
191 | # is_public_help: 'Public link' | ||
190 | language_label: 'Lenga' | 192 | language_label: 'Lenga' |
191 | http_status_label: 'Estatut HTTP' | 193 | http_status_label: 'Estatut HTTP' |
192 | reading_time: | 194 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index fa672387..82d16767 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | |||
@@ -187,6 +187,8 @@ entry: | |||
187 | unread_label: 'Nieprzeczytane' | 187 | unread_label: 'Nieprzeczytane' |
188 | preview_picture_label: 'Posiada podgląd obrazu' | 188 | preview_picture_label: 'Posiada podgląd obrazu' |
189 | preview_picture_help: 'Podgląd obrazu' | 189 | preview_picture_help: 'Podgląd obrazu' |
190 | # is_public_label: 'Has a public link' | ||
191 | # is_public_help: 'Public link' | ||
190 | language_label: 'Język' | 192 | language_label: 'Język' |
191 | http_status_label: 'Status HTTP' | 193 | http_status_label: 'Status HTTP' |
192 | reading_time: | 194 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml index 896ccb04..b75567d6 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pt.yml | |||
@@ -187,6 +187,8 @@ entry: | |||
187 | unread_label: 'Não Lido' | 187 | unread_label: 'Não Lido' |
188 | preview_picture_label: 'Possui uma imagem de preview' | 188 | preview_picture_label: 'Possui uma imagem de preview' |
189 | preview_picture_help: 'Imagem de preview' | 189 | preview_picture_help: 'Imagem de preview' |
190 | # is_public_label: 'Has a public link' | ||
191 | # is_public_help: 'Public link' | ||
190 | language_label: 'Idioma' | 192 | language_label: 'Idioma' |
191 | # http_status_label: 'HTTP status' | 193 | # http_status_label: 'HTTP status' |
192 | reading_time: | 194 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index c447dc9b..95df573d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | |||
@@ -187,6 +187,8 @@ entry: | |||
187 | unread_label: 'Necitite' | 187 | unread_label: 'Necitite' |
188 | preview_picture_label: 'Are o imagine de previzualizare' | 188 | preview_picture_label: 'Are o imagine de previzualizare' |
189 | preview_picture_help: 'Previzualizare imagine' | 189 | preview_picture_help: 'Previzualizare imagine' |
190 | # is_public_label: 'Has a public link' | ||
191 | # is_public_help: 'Public link' | ||
190 | language_label: 'Limbă' | 192 | language_label: 'Limbă' |
191 | # http_status_label: 'HTTP status' | 193 | # http_status_label: 'HTTP status' |
192 | reading_time: | 194 | reading_time: |
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig index 0ba6f4f4..6c26d5bf 100644 --- a/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig +++ b/src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/entries.html.twig | |||
@@ -127,6 +127,11 @@ | |||
127 | {{ form_widget(form.previewPicture) }} | 127 | {{ form_widget(form.previewPicture) }} |
128 | {{ form_label(form.previewPicture) }} | 128 | {{ form_label(form.previewPicture) }} |
129 | </div> | 129 | </div> |
130 | |||
131 | <div class="input-field"> | ||
132 | {{ form_widget(form.isPublic) }} | ||
133 | {{ form_label(form.isPublic) }} | ||
134 | </div> | ||
130 | </div> | 135 | </div> |
131 | 136 | ||
132 | <div id="filter-language" class="filter-group"> | 137 | <div id="filter-language" class="filter-group"> |
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 6f657b18..5ba42057 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 | |||
@@ -103,6 +103,15 @@ | |||
103 | </div> | 103 | </div> |
104 | 104 | ||
105 | <div class="col s12"> | 105 | <div class="col s12"> |
106 | <label>{{ 'entry.filters.is_public_help'|trans }}</label> | ||
107 | </div> | ||
108 | |||
109 | <div class="input-field col s12 with-checkbox"> | ||
110 | {{ form_widget(form.isPublic) }} | ||
111 | {{ form_label(form.isPublic) }} | ||
112 | </div> | ||
113 | |||
114 | <div class="col s12"> | ||
106 | {{ form_label(form.language) }} | 115 | {{ form_label(form.language) }} |
107 | </div> | 116 | </div> |
108 | 117 | ||
@@ -121,10 +130,12 @@ | |||
121 | <div class="col s12"> | 130 | <div class="col s12"> |
122 | {{ form_label(form.readingTime) }} | 131 | {{ form_label(form.readingTime) }} |
123 | </div> | 132 | </div> |
133 | |||
124 | <div class="input-field col s6"> | 134 | <div class="input-field col s6"> |
125 | {{ form_widget(form.readingTime.left_number, {'type': 'number'}) }} | 135 | {{ form_widget(form.readingTime.left_number, {'type': 'number'}) }} |
126 | <label for="entry_filter_readingTime_left_number">{{ 'entry.filters.reading_time.from'|trans }}</label> | 136 | <label for="entry_filter_readingTime_left_number">{{ 'entry.filters.reading_time.from'|trans }}</label> |
127 | </div> | 137 | </div> |
138 | |||
128 | <div class="input-field col s6"> | 139 | <div class="input-field col s6"> |
129 | {{ form_widget(form.readingTime.right_number, {'type': 'number'}) }} | 140 | {{ form_widget(form.readingTime.right_number, {'type': 'number'}) }} |
130 | <label for="entry_filter_readingTime_right_number">{{ 'entry.filters.reading_time.to'|trans }}</label> | 141 | <label for="entry_filter_readingTime_right_number">{{ 'entry.filters.reading_time.to'|trans }}</label> |
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php index 8f5c372d..853f37f2 100644 --- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php +++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | |||
@@ -860,6 +860,20 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
860 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | 860 | $this->assertCount(1, $crawler->filter('div[class=entry]')); |
861 | } | 861 | } |
862 | 862 | ||
863 | public function testFilterOnIsPublic() | ||
864 | { | ||
865 | $this->logInAs('admin'); | ||
866 | $this->useTheme('baggy'); | ||
867 | $client = $this->getClient(); | ||
868 | |||
869 | $crawler = $client->request('GET', '/unread/list'); | ||
870 | $form = $crawler->filter('button[id=submit-filter]')->form(); | ||
871 | $form['entry_filter[isPublic]']->tick(); | ||
872 | |||
873 | $crawler = $client->submit($form); | ||
874 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | ||
875 | } | ||
876 | |||
863 | public function testPreviewPictureFilter() | 877 | public function testPreviewPictureFilter() |
864 | { | 878 | { |
865 | $this->logInAs('admin'); | 879 | $this->logInAs('admin'); |