Skip to content

Firefly III: a personal finances manager

Show excluded words in UI

Sobuno058a0f9fb229
diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php
index 6bf2204c3b..09eb820c54 100644
--- a/app/Http/Controllers/SearchController.php
+++ b/app/Http/Controllers/SearchController.php
@@ -84,11 +84,12 @@ class SearchController extends Controller
// words from query and operators:
$query = $searcher->getWordsAsString();
+ $excludedWords = $searcher->getExcludedWordsAsString();
$operators = $searcher->getOperators();
$invalidOperators = $searcher->getInvalidOperators();
$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'));
}
/**
diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php
index e6c445b231..e37b90e282 100644
--- a/app/Support/Search/OperatorQuerySearch.php
+++ b/app/Support/Search/OperatorQuerySearch.php
@@ -123,6 +123,11 @@ class OperatorQuerySearch implements SearchInterface
return implode(' ', $this->words);
}
+ public function getExcludedWordsAsString(): string
+ {
+ return implode(' ', $this->prohibitedWords);
+ }
+
/**
* @throws FireflyException
*/
diff --git a/app/Support/Search/SearchInterface.php b/app/Support/Search/SearchInterface.php
index b9197e9daf..3604cacdd1 100644
--- a/app/Support/Search/SearchInterface.php
+++ b/app/Support/Search/SearchInterface.php
@@ -40,6 +40,7 @@ interface SearchInterface
public function getOperators(): Collection;
public function getWordsAsString(): string;
+ public function getExcludedWordsAsString(): string;
public function hasModifiers(): bool;
diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php
index bd38b2404d..65e810481c 100644
--- a/resources/lang/en_US/firefly.php
+++ b/resources/lang/en_US/firefly.php
@@ -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_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_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.',
// old
diff --git a/resources/views/search/index.twig b/resources/views/search/index.twig
index b48dfd069e..f4346c55b1 100644
--- a/resources/views/search/index.twig
+++ b/resources/views/search/index.twig
@@ -43,6 +43,11 @@
{{ trans('firefly.search_for_query', {query: query|escape})|raw }}
</p>
{% endif %}
+ {% if '' != excludedWords %}
+ <p>
+ {{ trans('firefly.search_for_excluded_words', {excluded_words: excludedWords|escape})|raw }}
+ </p>
+ {% endif %}
{% if invalidOperators|length > 0 %}
<p>{{ trans('firefly.invalid_operators_list') }}</p>
@@ -70,7 +75,7 @@
</div>
</div>
</div>
- {% if query or operators|length > 0 %}
+ {% if query or excludedWords or operators|length > 0 %}
<div class="row result_row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box search_box">
@@ -125,7 +130,7 @@
</div>
</div>
{% endif %}
- {% if query == "" and operators|length == 0 %}
+ {% if query == "" and excludedWords == "" and operators|length == 0 %}
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="box">