Skip to content

Firefly III: a personal finances manager

Move stuff to sortableTable class

James Cole17621a33e665
diff --git a/resources/assets/v3/js/pages/accounts/index.js b/resources/assets/v3/js/pages/accounts/index.js
index effe71227f..cf3a7b2fa9 100644
--- a/resources/assets/v3/js/pages/accounts/index.js
+++ b/resources/assets/v3/js/pages/accounts/index.js
@@ -40,9 +40,9 @@ let index = function () {
objectType: "invalid",
accounts: [],
page: 1,
+ totalPages: 1,
i18next: null,
anonymous: false,
- totalPages: 1,
loadingPage: true,
convertToPrimary: false,
active: true,
@@ -73,6 +73,7 @@ let index = function () {
sortableTable: null,
init() {
+ this.sortableTable = new sortableTable("main");
// prepare some variables:
const address = window.location.href.split("?")[0].split("/");
this.objectType = address[address.length - 1].substring(0, 15);
@@ -108,7 +109,6 @@ let index = function () {
direction: this.defaultSortDirection,
});
- this.sortableTable = new sortableTable("main");
this.sortableTable.sortColumn = this.defaultSortColumn;
this.sortableTable.storageKey = this.storageKey;
this.sortableTable.sortDirection = this.defaultSortDirection;
@@ -337,12 +337,12 @@ let index = function () {
});
return false;
},
- capturePageNavigation() {
- document.querySelectorAll("a.page-link").forEach((el) => {
- el.removeEventListener("click", this.handleFunc);
- el.addEventListener("click", this.handleFunc);
- });
- },
+ // capturePageNavigation() {
+ // document.querySelectorAll("a.page-link").forEach((el) => {
+ // el.removeEventListener("click", this.handleFunc);
+ // el.addEventListener("click", this.handleFunc);
+ // });
+ // },
};
};
diff --git a/resources/assets/v3/js/pages/shared/sortable-tables.js b/resources/assets/v3/js/pages/shared/sortable-tables.js
index eefcc2d194..38ab95a061 100644
--- a/resources/assets/v3/js/pages/shared/sortable-tables.js
+++ b/resources/assets/v3/js/pages/shared/sortable-tables.js
@@ -25,6 +25,7 @@ export class sortableTable {
storageKey = "";
disableRefresh = false;
parent = null;
+ isFiltering = true;
constructor(tableId) {
this.tableId = tableId;
@@ -95,6 +96,14 @@ export class sortableTable {
}
});
}
+ capturePageNavigation() {
+ console.log('capturePageNavigation()');
+ document.querySelectorAll("a.page-link").forEach((el) => {
+ console.log('Catch clicks.');
+ el.removeEventListener("click", this.handleFunc);
+ el.addEventListener("click", this.handleFunc);
+ });
+ }
clickColumnTitle(event) {
let parent = event.currentTarget.parentNode;
diff --git a/resources/views/accounts/index.blade.php b/resources/views/accounts/index.blade.php
index 66756c7f34..58c76da742 100644
--- a/resources/views/accounts/index.blade.php
+++ b/resources/views/accounts/index.blade.php
@@ -374,7 +374,7 @@
:linkTitle="__('firefly.make_new_'. $objectType . '_account')"/>
</div>
</div>
- <template x-if="0 === accounts.length && true === active && false === loadingPage && false === isFiltering">
+ <template x-if="0 === accounts.length && true === active && false === loadingPage && false === sortableTable.isFiltering">
<x-empty-page :route="route('accounts.create', [$objectType]) . '?_from=' . urlencode($FF3_FROM)"
type="accounts" :object-type="$objectType"/>
</template>
diff --git a/resources/views/components/elements/alpine/page-navigation.blade.php b/resources/views/components/elements/alpine/page-navigation.blade.php
index 4bd2a514d6..dca716aba9 100644
--- a/resources/views/components/elements/alpine/page-navigation.blade.php
+++ b/resources/views/components/elements/alpine/page-navigation.blade.php
@@ -1,4 +1,4 @@
-<template x-if="totalPages > 1" x-effect="capturePageNavigation()">
+<template x-if="totalPages > 1" x-effect="sortableTable ? sortableTable.capturePageNavigation() : null">
<div class="m-2">
<nav>
<ul class="pagination">