1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2024-11-23 03:12:32 +01:00

Only output hidden user filters when not set to 'me'

This commit is contained in:
Allan 2022-10-06 19:25:47 +02:00
parent a090720241
commit d4143c3101
2 changed files with 12 additions and 5 deletions

View File

@ -61,10 +61,10 @@
@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

View 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"]');
}
}