Show excluded words in UI

This commit is contained in:
Sobuno
2025-01-03 00:08:11 +01:00
parent 0c955efa8b
commit 058a0f9fb2
5 changed files with 16 additions and 3 deletions

View File

@@ -84,11 +84,12 @@ class SearchController extends Controller
// words from query and operators: // words from query and operators:
$query = $searcher->getWordsAsString(); $query = $searcher->getWordsAsString();
$excludedWords = $searcher->getExcludedWordsAsString();
$operators = $searcher->getOperators(); $operators = $searcher->getOperators();
$invalidOperators = $searcher->getInvalidOperators(); $invalidOperators = $searcher->getInvalidOperators();
$subTitle = (string) trans('breadcrumbs.search_result', ['query' => $fullQuery]); $subTitle = (string) trans('breadcrumbs.search_result', ['query' => $fullQuery]);
return view('search.index', compact('query', 'operators', 'page', 'rule', 'fullQuery', 'subTitle', 'ruleId', 'ruleChanged', 'invalidOperators')); return view('search.index', compact('query', 'excludedWords', 'operators', 'page', 'rule', 'fullQuery', 'subTitle', 'ruleId', 'ruleChanged', 'invalidOperators'));
} }
/** /**

View File

@@ -123,6 +123,11 @@ class OperatorQuerySearch implements SearchInterface
return implode(' ', $this->words); return implode(' ', $this->words);
} }
public function getExcludedWordsAsString(): string
{
return implode(' ', $this->prohibitedWords);
}
/** /**
* @throws FireflyException * @throws FireflyException
*/ */

View File

@@ -40,6 +40,7 @@ interface SearchInterface
public function getOperators(): Collection; public function getOperators(): Collection;
public function getWordsAsString(): string; public function getWordsAsString(): string;
public function getExcludedWordsAsString(): string;
public function hasModifiers(): bool; public function hasModifiers(): bool;

View File

@@ -330,6 +330,7 @@ return [
'search_found_transactions' => 'Firefly III found :count transaction in :time seconds.|Firefly III found :count transactions in :time seconds.', 'search_found_transactions' => 'Firefly III found :count transaction in :time seconds.|Firefly III found :count transactions in :time seconds.',
'search_found_more_transactions' => 'Firefly III found more than :count transactions in :time seconds.', 'search_found_more_transactions' => 'Firefly III found more than :count transactions in :time seconds.',
'search_for_query' => 'Firefly III is searching for transactions with all of these words in them: <span class="text-info">:query</span>', 'search_for_query' => 'Firefly III is searching for transactions with all of these words in them: <span class="text-info">:query</span>',
'search_for_excluded_words' => 'Firefly III is searching for transactions with none of these words in them: <span class="text-info">:excluded_words</span>',
'invalid_operators_list' => 'These search parameters are not valid and have been ignored.', 'invalid_operators_list' => 'These search parameters are not valid and have been ignored.',
// old // old

View File

@@ -43,6 +43,11 @@
{{ trans('firefly.search_for_query', {query: query|escape})|raw }} {{ trans('firefly.search_for_query', {query: query|escape})|raw }}
</p> </p>
{% endif %} {% endif %}
{% if '' != excludedWords %}
<p>
{{ trans('firefly.search_for_excluded_words', {excluded_words: excludedWords|escape})|raw }}
</p>
{% endif %}
{% if invalidOperators|length > 0 %} {% if invalidOperators|length > 0 %}
<p>{{ trans('firefly.invalid_operators_list') }}</p> <p>{{ trans('firefly.invalid_operators_list') }}</p>
@@ -70,7 +75,7 @@
</div> </div>
</div> </div>
</div> </div>
{% if query or operators|length > 0 %} {% if query or excludedWords or operators|length > 0 %}
<div class="row result_row"> <div class="row result_row">
<div class="col-lg-12 col-md-12 col-sm-12"> <div class="col-lg-12 col-md-12 col-sm-12">
<div class="box search_box"> <div class="box search_box">
@@ -125,7 +130,7 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% if query == "" and operators|length == 0 %} {% if query == "" and excludedWords == "" and operators|length == 0 %}
<div class="row"> <div class="row">
<div class="col-lg-12 col-md-12 col-sm-12"> <div class="col-lg-12 col-md-12 col-sm-12">
<div class="box"> <div class="box">