]> BookStack Code Mirror - bookstack/commitdiff
Only output hidden user filters when not set to 'me' 3770/head
authorAllan <redacted>
Thu, 6 Oct 2022 17:25:47 +0000 (19:25 +0200)
committerAllan <redacted>
Thu, 6 Oct 2022 17:25:47 +0000 (19:25 +0200)
resources/views/search/all.blade.php
tests/Entity/EntitySearchTest.php

index 85e6d1b7b525d6ba715030de7c583679f8ad8ea3..96b14f6e534c6931d92e61698bf51e35e368541a 100644 (file)
                         @include('search.parts.date-filter', ['name' => 'created_after', 'filters' => $options->filters])
                         @include('search.parts.date-filter', ['name' => 'created_before', 'filters' => $options->filters])
 
-                        @if(isset($options->filters['created_by']))
+                        @if(isset($options->filters['created_by']) && $options->filters['created_by'] !== "me")
                             <input type="hidden" name="filters[created_by]" value="{{ $options->filters['created_by'] }}">
                         @endif
-                        @if(isset($options->filters['updated_by']))
+                        @if(isset($options->filters['updated_by']) && $options->filters['updated_by'] !== "me")
                             <input type="hidden" name="filters[updated_by]" value="{{ $options->filters['updated_by'] }}">
                         @endif
 
index cdb500a45ccdeb71b70382881b4303c05e3c542d..3cfd928203f5e6801ae069e8e12ec858f6bd002c 100644 (file)
@@ -448,8 +448,15 @@ class EntitySearchTest extends TestCase
 
     public function test_searches_with_user_filters_adds_them_into_advanced_search_form()
     {
-        $resp = $this->asEditor()->get('/search?term=' . urlencode('test {updated_by:me} {created_by:dan}'));
-        $this->withHtml($resp)->assertElementExists('form input[type="hidden"][name="filters[updated_by]"][value="me"]');
-        $this->withHtml($resp)->assertElementExists('form input[type="hidden"][name="filters[created_by]"][value="dan"]');
+        $resp = $this->asEditor()->get('/search?term=' . urlencode('test {updated_by:dan} {created_by:dan}'));
+        $this->withHtml($resp)->assertElementExists('form input[name="filters[updated_by]"][value="dan"]');
+        $this->withHtml($resp)->assertElementExists('form input[name="filters[created_by]"][value="dan"]');
+    }
+
+    public function test_searches_with_user_filters_using_me_adds_them_into_advanced_search_form()
+    {
+        $resp = $this->asEditor()->get('/search?term=' . urlencode('test {updated_by:me} {created_by:me}'));
+        $this->withHtml($resp)->assertElementExists('form input[name="filters[updated_by]"][value="me"][checked="checked"]');
+        $this->withHtml($resp)->assertElementExists('form input[name="filters[created_by]"][value="me"][checked="checked"]');
     }
 }