]> BookStack Code Mirror - bookstack/commitdiff
Merge branch 'development' into bugfix/fix-being-unable-to-clear-filters
authorDan Brown <redacted>
Sat, 15 Oct 2022 14:12:55 +0000 (15:12 +0100)
committerDan Brown <redacted>
Sat, 15 Oct 2022 14:12:55 +0000 (15:12 +0100)
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 51fac48b2c4097749ba0a16f5c6d481279185251..c309f2167954b3f99ce344c13fef926cb2280946 100644 (file)
@@ -446,8 +446,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"]');
     }
 }