Skip to content

Firefly III: a personal finances manager

Include top pagination.

James Cole8b371fd693e1
diff --git a/resources/assets/v3/js/boot/bootstrap.js b/resources/assets/v3/js/boot/bootstrap.js
index bdd4056941..0a43486feb 100644
--- a/resources/assets/v3/js/boot/bootstrap.js
+++ b/resources/assets/v3/js/boot/bootstrap.js
@@ -83,7 +83,6 @@ getFreshVariable("lastActivity")
loadTranslations(replacedLanguage, replacedLocale)
.then(function () {
window.i18next = i18next;
- document.getElementById('test-box').innerText = i18next.t("config.html_language", {lng: 'nl-NL'});
const event = new Event("firefly-iii-bootstrapped");
document.dispatchEvent(event);
window.bootstrapped = true;
diff --git a/resources/assets/v3/js/pages/accounts/index.js b/resources/assets/v3/js/pages/accounts/index.js
index c7b252278a..f91caac3a0 100644
--- a/resources/assets/v3/js/pages/accounts/index.js
+++ b/resources/assets/v3/js/pages/accounts/index.js
@@ -27,9 +27,11 @@ import Put from "../../api/model/account/put.js";
import Get from "../../api/model/account/get.js";
import {format} from "date-fns";
import formatMoney from "../../util/format-money.js";
+import i18next from "i18next";
window.enableDates = false;
+
let index = function () {
return {
listPageSize: 50,
@@ -38,6 +40,7 @@ let index = function () {
accounts: [],
sortDirection: 'asc',
page: 1,
+ totalPages: 1,
init() {
const page = window.location.href.split('?')[0].split("/");
this.objectType = page[page.length - 1].substring(0, 15);
@@ -54,7 +57,7 @@ let index = function () {
// get accounts by initial sort.
document.querySelectorAll('table.sortable th').forEach((el) => {
- console.log('El', el);
+ // console.log('El', el);
el.addEventListener('click', (event) => {
let newColumn = event.currentTarget.dataset.column;
if (newColumn === this.sortColumn) {
@@ -102,11 +105,13 @@ let index = function () {
(new Get).list({
active: active,
sort: sort,
+ page: this.page,
type: this.objectType,
start: start,
end: end
}).then((response) => {
this.accounts = [];
+ this.totalPages = parseInt(response.data.meta.pagination.total_pages);
for (let i = 1; i < response.data.data.length; i++) {
if (Object.hasOwn(response.data.data, i)) {
let current = response.data.data[i];
@@ -130,7 +135,7 @@ let index = function () {
lastActivity = i18next.t('firefly.never');
noLastActivity = true;
}
- console.log(current);
+ //console.log(current);
let account = {
id: parseInt(current.id),
name: current.attributes.name,
diff --git a/resources/views/accounts/index.blade.php b/resources/views/accounts/index.blade.php
index 8a0933ab79..b5d11cfa98 100644
--- a/resources/views/accounts/index.blade.php
+++ b/resources/views/accounts/index.blade.php
@@ -6,12 +6,42 @@
<div class="card" id="account-index-{{ $objectType }}">
<x-elements.card-header-with-menu :cardTitle="trans('firefly.'.$objectType.'_accounts')" :route="route('accounts.create', $objectType) . '?_from=' . urlencode($FF3_FROM)" :linkTitle="__('firefly.make_new_'. $objectType . '_account')"/>
<div class="card-body p-0">
- {{--
- <x-lists.accounts :accounts="$accounts" :objectType="$objectType" :page="$page ?? 1" />
- --}}
- <div class="m-2">
- TODO Pagination be here.
- </div>
+ <template x-if="totalPages > 1">
+ <div class="m-2">
+ <nav>
+ <ul class="pagination">
+ <li :class="{'page-item': true, 'disabled': 1 === page}" aria-disabled="true" aria-label="{{ __('pagination.previous') }}">
+ <template x-if="1 === page">
+ <span class="page-link" aria-hidden="true">‹</span>
+ </template>
+ <template x-if="page > 1">
+ <a class="page-link" :href="'./accounts/'+objectType+'?page=' + (page - 1)" rel="prev" aria-label="{{ __('pagination.previous') }}">‹</a>
+ </template>
+ </li>
+ <template x-for="current in totalPages" :key="current">
+ <li class="page-item" :class="{'page-item': true, 'active': current === page}">
+ <template x-if="current !== page">
+ <a class="page-link" :href="'./accounts/'+objectType+'?page=' + current" x-text="current" :aria-label="current"></a>
+ </template>
+ <template x-if="current === page">
+ <span class="page-link" x-text="current"></span>
+ </template>
+ </li>
+ </template>
+
+ <li class="page-item">
+ <template x-if="totalPages === page">
+ <span class="page-link" aria-hidden="true">›</span>
+ </template>
+ <template x-if="totalPages > page">
+ <a class="page-link" :href="'./accounts/'+objectType+'?page=' + (page +1)" rel="next" aria-label="{{ __('pagination.next') }}">›</a>
+ </template>
+
+ </li>
+ </ul>
+ </nav>
+ </div>
+ </template>
<table class="table table-valign-middle table-sm table-hover sortable">
<thead>
<tr>
@@ -169,12 +199,11 @@
</template>
</tbody>
</table>
-
-
- <div class="m-2">
- TODO Pagination be here.
- </div>
-
+ <template x-if="totalPages > 1">
+ <div class="m-2">
+ TODO Pagination be here.
+ </div>
+ </template>
</div>
<x-elements.card-footer-with-menu :route="route('accounts.create', $objectType) . '?_from=' . urlencode($FF3_FROM)" :linkTitle="__('firefly.make_new_'. $objectType . '_account')" />
</div>