Skip to content

Firefly III: a personal finances manager

Take filter from URL, do not break when there is zero results, does not yet show the button.

James Coled5d47f05f332
diff --git a/resources/assets/v3/js/pages/accounts/index.js b/resources/assets/v3/js/pages/accounts/index.js
index 07a40760eb..07c4fef701 100644
--- a/resources/assets/v3/js/pages/accounts/index.js
+++ b/resources/assets/v3/js/pages/accounts/index.js
@@ -52,6 +52,7 @@ let index = function () {
sums: {},
debts: {},
differences: {},
+ isFiltering: false,
filter: {
name: "",
},
@@ -92,9 +93,16 @@ let index = function () {
updateFilterValue(field, newValue) {
console.log("Update", field, newValue);
this.filter[field] = newValue;
+ if('' !== newValue) {
+ this.isFiltering = true;
+ }
+ if('' === newValue) {
+ this.isFiltering = false;
+ }
this.updateHistory();
this.downloadAccounts();
},
+
init() {
this.$watch("filter.name", (value) => this.updateFilterValue("name", value));
@@ -113,7 +121,11 @@ let index = function () {
const params = new Proxy(new URLSearchParams(window.location.search), {
get: (searchParams, prop) => searchParams.get(prop),
});
-
+ // shitty solution but for now it works.
+ if('' !== params['filter[name]']) {
+ this.filter.name = params['filter[name]'];
+ this.isFiltering = true;
+ }
if ("expense" === this.objectType || "revenue" === this.objectType) {
defaultSortColumn = "name";
}
@@ -161,6 +173,9 @@ let index = function () {
document.querySelector(`em.search-button[data-column="${column}"]`).classList.remove("d-none");
document.querySelector(`div.search-filter[data-column="${column}"] input`).value = "";
+ // remove class from parent if was used to sort
+ document.querySelector(`th.sortable_sorted[data-column="${column}"]`).classList.remove("is-searching");
+
let input = document.querySelector(`div.search-filter[data-column="${column}"]`);
input.classList.add("d-none");
@@ -177,6 +192,8 @@ let index = function () {
el.classList.add("d-none");
document.querySelector(`span.title[data-column="${column}"]`).classList.add("d-none");
document.querySelector(`span.search-spacer[data-column="${column}"]`).classList.add("d-none");
+ // add class to parent if it's used to sort
+ document.querySelector(`th.sortable_sorted[data-column="${column}"]`).classList.add("is-searching");
// show search input
let input = document.querySelector(`div.search-filter[data-column="${column}"]`);
@@ -342,7 +359,7 @@ let index = function () {
}
this.loadingPage = false;
this.loadingNewSort = false;
- if (0 === this.accounts.length) {
+ if (0 === this.accounts.length && false === this.isFiltering) {
document.querySelectorAll(".data-holder").forEach((el) => {
el.classList.add("d-none");
});
diff --git a/resources/assets/v3/sass/app.scss b/resources/assets/v3/sass/app.scss
index 4a0bdc3cf1..e148d94ca5 100644
--- a/resources/assets/v3/sass/app.scss
+++ b/resources/assets/v3/sass/app.scss
@@ -58,10 +58,10 @@ table.sortable thead th.sortable span {
.search-button {
cursor: pointer;
}
-table.sortable th.sortable.sortable_sorted.sortable_sorted_asc:before {
+table.sortable th.sortable.sortable_sorted.sortable_sorted_asc:not(th.is-searching):before {
content: " \25B4";
}
-table.sortable th.sortable.sortable_sorted.sortable_sorted_desc:before {
+table.sortable th.sortable.sortable_sorted.sortable_sorted_desc:not(th.is-searching):before {
content: " \25BE";
}
diff --git a/resources/views/accounts/index.blade.php b/resources/views/accounts/index.blade.php
index 11fce6ffd4..2a95b499d5 100644
--- a/resources/views/accounts/index.blade.php
+++ b/resources/views/accounts/index.blade.php
@@ -315,7 +315,7 @@
:linkTitle="__('firefly.make_new_'. $objectType . '_account')"/>
</div>
</div>
- <template x-if="0 === accounts.length && true === active && false === loadingPage">
+ <template x-if="0 === accounts.length && true === active && false === loadingPage && false === isFiltering">
<x-empty-page :route="route('accounts.create', [$objectType]) . '?_from=' . urlencode($FF3_FROM)"
type="accounts" :object-type="$objectType"/>
</template>