Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Groupable accounts, but not entirely complete yet.
James Cole115510361a8e
diff --git a/app/Api/V1/Controllers/Models/Account/ShowController.php b/app/Api/V1/Controllers/Models/Account/ShowController.phpindex f755833a30..376f121df7 100644--- a/app/Api/V1/Controllers/Models/Account/ShowController.php+++ b/app/Api/V1/Controllers/Models/Account/ShowController.php@@ -83,9 +83,8 @@ final class ShowController extends Controller'active' => $active,'date' => $date,] = $request->attributes->all();-// get list of accounts. Count it and split it.- $this->repository->resetAccountOrder();+ // $this->repository->resetAccountOrder();$collection = $this->repository->getAccountsByType($types, $sort, $filter, $active);$count = $collection->count();$dbFields = $this->isAllDatabaseSort($sort, 'Account');diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex 6d56e1fcee..74173e702c 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -261,6 +261,25 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac$allowed = config('firefly.allowed_filter_parameters.Account', []);if (0 !== count($filter)) {foreach ($filter as $field => $search) {+ if('object_group_id' === $field) {+ // left join object_groupables ON object_groupables.object_groupable_id = accounts.id AND object_groupables.object_groupable_type = "FireflyIII\\Models\\Account"+ //where object_groupables.object_group_id=1+ $query->leftJoin('object_groupables', function (JoinClause $join): void {+ $join->on('accounts.id', '=', 'object_groupables.object_groupable_id');+ $join->on('object_groupables.object_groupable_type', '=', DB::raw("'FireflyIII\\\\Models\\\\Account'"));+ });+ $search = (int) $search;+ if(0 !== $search) {+ $query->where('object_groupables.object_group_id', $search);+ }+ if(0 === $search) {+ $query->whereNull('object_groupables.object_group_id');+ }++ continue;+ }++if ('account_number_and_iban' === $field) {$query->leftJoin('account_meta', function (JoinClause $join): void {$join->on('accounts.id', '=', 'account_meta.account_id');@@ -282,6 +301,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac}}+if (0 === $sorted) {if (0 !== count($res)) {$query->orderBy('accounts.order', 'ASC');diff --git a/app/View/Components/Elements/Alpine/PageNavigation.php b/app/View/Components/Elements/Alpine/PageNavigation.phpindex e1d5a49b23..9e36b8b9aa 100644--- a/app/View/Components/Elements/Alpine/PageNavigation.php+++ b/app/View/Components/Elements/Alpine/PageNavigation.php@@ -13,7 +13,7 @@ class PageNavigation extends Component/*** Create a new component instance.*/- public function __construct(public string $sortIdentifier) {}+ public function __construct() {}/*** Get the view / contents that represent the component.diff --git a/config/firefly.php b/config/firefly.phpindex 467cf90d38..7b3af32a8a 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -852,6 +852,7 @@ return ['Account' => ['name','account_number_and_iban',+ 'object_group_id'],'Category' => ['name',diff --git a/resources/assets/v3/js/pages/accounts/index.js b/resources/assets/v3/js/pages/accounts/index.jsindex 52154a4133..72a43274bd 100644--- a/resources/assets/v3/js/pages/accounts/index.js+++ b/resources/assets/v3/js/pages/accounts/index.js@@ -29,7 +29,7 @@ import formatDate from "../../util/format-date.js";import formatMoney from "../../util/format-money.js";import i18next from "i18next";import {addDrag} from "../shared/drag-and-droppable-rows.js";-import {initFromLocalStorage, initFromQueryParams, sortableTable, storeFilterAndSort, updateHistory, respondToSortChange} from "../shared/sortable-tables.js";+import {initFromLocalStorage, initFromQueryParams, respondToSortChange, sortableTable, storeFilterAndSort, updateHistory} from "../shared/sortable-tables.js";window.enableDates = true;@@ -38,16 +38,20 @@ let index = function () {// necessary for indexlistPageSize: 50,objectType: "invalid",- accounts: [],i18next: null,anonymous: false,- loadingPage: true,+ loadingPage: false,convertToPrimary: false,active: true,sums: {},debts: {},differences: {},+ // grouped accounts per object group.+ accounts: [],+ groupedObjects: {},++// default settings for sortable tables.storageKey: "",defaultSortColumns: {"main": "order"},@@ -56,6 +60,7 @@ let index = function () {pageNavUrl: "./accounts/",filter: {},+// sort functions, importedformatMoney: formatMoney,updateHistory: updateHistory,@@ -65,45 +70,59 @@ let index = function () {respondToSortChange: respondToSortChange,sortableTable: null,- init() {- // initialize sortable table.- this.storageKey = "accounts-" + this.objectType + (this.active ? "-active" : "-inactive");- this.defaultSortColumns = "expense" === this.objectType || "revenue" === this.objectType ? {"main": "name"} : this.defaultSortColumns;- this.initFromLocalStorage();- this.initFromQueryParams();-+ launchSortableTable(groupedObjects) {// create sortable table.- let tables = ["main"];- for(let i = 0; i < tables.length; i++) {+ let tables = Object.keys(groupedObjects);+ console.log('All tables are', tables);+ this.sortableTable = new sortableTable(tables);++ for (let i = 0; i < tables.length; i++) {let table = tables[i];this.filter[table] = {};++ // make sure grouped objects is not longer than listPageSize.+ this.sortableTable.totalPages[table] = Math.ceil(groupedObjects[table].total / this.listPageSize);+ // if (groupedObjects[table].accounts.length > this.listPageSize) {+ // console.log('Grouped objects "' + table + '" has ' + groupedObjects[table].accounts.length + ' accounts, which is more than listPageSize of ' + this.listPageSize + '. Will slice.');+ // this.sortableTable.totalPages[table] = Math.ceil(groupedObjects[table].accounts.length / this.listPageSize);+ // groupedObjects[table].accounts = groupedObjects[table].accounts.slice(0, this.listPageSize);+ // }+}- this.sortableTable = new sortableTable(tables);- // prepare some variables. Has nothing to do with sortable table.- const address = window.location.href.split("?")[0].split("/");- this.objectType = address[address.length - 1].substring(0, 15);- this.i18next = i18next;- this.anonymous = window.store.get("anonymous");- this.pageNavUrl = "./accounts/" + this.objectType;- this.active = "inactive-accounts" !== address[address.length - 2];+ this.initFromLocalStorage();+ this.initFromQueryParams();++ console.log('final sort columns', JSON.parse(JSON.stringify(this.defaultSortColumns)));+ console.log('final sort directions', JSON.parse(JSON.stringify(this.defaultSortDirections)));// configure sortable table with final result (not filter).this.sortableTable.sortColumns = this.defaultSortColumns;this.sortableTable.sortDirections = this.defaultSortDirections;this.sortableTable.storageKey = this.storageKey;this.sortableTable.pages = this.defaultPages;-- // initialize sortable table.+ this.groupedObjects = groupedObjects;this.sortableTable.init(this);+ },++ init() {+ // prepare some variables.+ const address = window.location.href.split("?")[0].split("/");+ this.objectType = address[address.length - 1].substring(0, 15);+ this.defaultSortColumns = "expense" === this.objectType || "revenue" === this.objectType ? {"main": "name"} : this.defaultSortColumns;+ this.storageKey = "accounts-" + this.objectType + (this.active ? "-active" : "-inactive");+ this.i18next = i18next;+ this.anonymous = window.store.get("anonymous");+ this.pageNavUrl = "./accounts/" + this.objectType;+ this.active = "inactive-accounts" !== address[address.length - 2];// watch for changes in the sortable table instructions.document.addEventListener("sortable-table-sort-change", this.respondToSortChange.bind(this));- this.downloadObjects();// respond to drag and drop.getVariable("listPageSize").then((listPageSize) => {this.listPageSize = listPageSize;+ this.downloadObjects(null);addDrag();document.addEventListener("firefly-iii-drag-complete", (e) => {for (let i = 0; i < e.detail.length; i++) {@@ -124,13 +143,15 @@ let index = function () {});},- prepareSumArrays(code) {- let keys = ["sums", "differences", "debts"];- for (let i = 0; i < keys.length; i++) {- if (Object.hasOwn(this, keys[i])) {- this[keys[i]][code] = this[keys[i]][code] || 0;- }- }+ prepareSumArrays(group, code) {+ this.sums[group] = this.sums[group] ?? {};+ this.differences[group] = this.differences[group] ?? {};+ this.debts[group] = this.debts[group] ?? {};++ // now add for code:+ this.sums[group][code] = this.sums[group][code] ?? 0;+ this.differences[group][code] = this.differences[group][code] ?? 0;+ this.debts[group][code] = this.debts[group][code] ?? 0;},filterAmounts(account) {// overrule some amounts, set them to zero when "this.anonymous" is true.@@ -157,137 +178,246 @@ let index = function () {}return account;},- downloadObjects() {- // since this function only downloads for table "main", it is safe to extract only "main" from the filter object.- this.sortableTable.loadingNewSort = true;- let sort = "asc" === this.sortableTable.sortDirections["main"] ? this.sortableTable.sortColumns["main"] : "-" + this.sortableTable.sortColumns["main"];-- // catch undefined stuff.- if('-undefined' === sort) {- sort = "asc" === this.defaultSortDirections["main"] ? this.defaultSortColumns["main"] : "-" + this.defaultSortColumns["main"];- }+ downloadObjects(tableId) {+ console.log('DownloadObjects(' + tableId +')');+ let downloadParams = {};+ const locale = window.store.get("locale");+ let downloadedObjectGroups = {};+ const fallBackId = null === tableId ? "ungrouped" : tableId;+ let sort = '-undefined';+ let page = 1;let start = window.store.get("start");let end = window.store.get("end");- this.convertToPrimary = window.store.get("convert_to_primary");- new Get()- .list({+ if (null === tableId) {+ console.log('Download ALL');+ // this.sortableTable.loadingNewSort = true; // TODO fix me.+ this.convertToPrimary = window.store.get("convert_to_primary");+++ // reset ALL+ this.groupedObjects = {};+ this.sums = {};+ this.debts = {};+ this.differences = {};++ // the sort instructions must be part of the group somehow?+ // "main" is not the same as "ungrouped", main is the starting point.++ page = 1;+ if (null !== this.sortableTable) {+ sort = "asc" === this.sortableTable.sortDirections["main"] ? this.sortableTable.sortColumns["main"] : "-" + this.sortableTable.sortColumns["main"];+ page = this.sortableTable.pages["main"];+ }+ // catch undefined stuff.+ if ('-undefined' === sort) {+ sort = "asc" === this.defaultSortDirections["main"] ? this.defaultSortColumns["main"] : "-" + this.defaultSortColumns["main"];+ }+ downloadParams = {+ active: this.active,+ sort: sort,+ limit:1337,+ page: page, // because we download ALL.+ type: this.objectType,+ start: start,+ filter: JSON.parse(JSON.stringify(this.filter))["main"], // same.+ end: end,+ };+ }+ if (null !== tableId) {+ console.log('Download', tableId);+ // reset GROUP+ //this.groupedObjects[tableId] = null;+ this.sums[tableId] = {};+ this.debts[tableId] = {};+ this.differences[tableId] = {};++ sort = "asc" === this.sortableTable.sortDirections[tableId] ? this.sortableTable.sortColumns[tableId] : "-" + this.sortableTable.sortColumns[tableId];+ page = this.sortableTable.pages[tableId];+ let filter = JSON.parse(JSON.stringify(this.filter))[tableId];+ filter.object_group_id = 0;+ if('ungrouped' !== tableId) {+ filter.object_group_id = parseInt(tableId.split("_")[1]);+ }+ downloadParams = {active: this.active,sort: sort,- page: this.sortableTable.pages["main"],+ page: page, // because we download ALL.type: this.objectType,start: start,- filter: JSON.parse(JSON.stringify(this.filter))["main"],+ filter: filter, // same.end: end,- })- .then((response) => {- const locale = window.store.get("locale");- this.accounts = [];- this.sums = {};- this.debts = {};- this.differences = {};-- this.sortableTable.totalPages["main"] = parseInt(response.data.meta.pagination.total_pages);+ };+ }+ new Get().list(downloadParams).then((response) => {+ console.log('After download', downloadParams);+ // safety catch for search.+ if (null !== this.sortableTable) {+ this.sortableTable.totalPages[fallBackId] = parseInt(response.data.meta.pagination.total_pages);const length = response.data.data.length;- if(this.sortableTable.totalPages["main"] <= this.sortableTable.pages["main"] && 0 === length) {- this.sortableTable.pages["main"] = this.sortableTable.totalPages["main"];- this.downloadObjects();+ if (this.sortableTable.totalPages[fallBackId] < this.sortableTable.pages[fallBackId] && 0 === length) {+ this.sortableTable.pages[fallBackId] = this.sortableTable.totalPages[fallBackId];+ console.log('Call downloadObjects again because page is too high for tableId ' + tableId);+ this.downloadObjects(tableId);}- for (let i = 0; i < response.data.data.length; i++) {- if (Object.hasOwn(response.data.data, i)) {- let current = this.filterAmounts(response.data.data[i]);- let cc = current.attributes.currency_code;- let pcc = current.attributes.primary_currency_code;- this.prepareSumArrays(cc);- this.prepareSumArrays(pcc);-- // add formatted amount property.- current = this.createParsedAndFloatingAmounts(current, cc, "");- current = this.createParsedAndFloatingAmounts(current, pcc, "pc_");- //console.log(current);-- if (!this.convertToPrimary) {- this.sums[cc] += current.attributes.current_balance_float;- this.debts[cc] += current.attributes.debt_amount_float;- this.differences[cc] += current.attributes.balance_difference_float;- }- if (this.convertToPrimary) {- this.sums[pcc] += current.attributes.pc_current_balance_float;- this.debts[pcc] += current.attributes.pc_debt_amount_float;- this.differences[pcc] += current.attributes.pc_balance_difference_float;- }- let lastActivity = formatDate(- current.attributes.last_activity,- i18next.t("config.date_time_fns_short", {lng: locale}),- locale,- );-- let noLastActivity = false;- if (null === current.attributes.last_activity) {- lastActivity = i18next.t("firefly.never");- noLastActivity = true;- }- let account = {- id: parseInt(current.id),- name: current.attributes.name,- location: null !== current.attributes.longitude && null !== current.attributes.latitude,- has_attachments: current.attributes.has_attachments,- role: current.attributes.account_role,- iban: this.addSpaces(current.attributes.iban),- account_number: current.attributes.account_number,-- currency_id: parseInt(current.attributes.currency_id),- primary_currency_id: parseInt(current.attributes.primary_currency_id),-- active: current.attributes.active,- last_activity: lastActivity,- no_last_activity: noLastActivity,-- current_balance: current.attributes.current_balance_formatted,- current_balance_float: current.attributes.current_balance_float,- pc_current_balance: current.attributes.pc_current_balance_formatted,- pc_current_balance_float: current.attributes.pc_current_balance_float,-- // current_balance: '1',- // current_balance_float: 2,- // pc_current_balance: '3',- // pc_current_balance_float: 4,-- balance_difference: current.attributes.balance_difference_formatted,- balance_difference_float: current.attributes.balance_difference_float,- pc_balance_difference: current.attributes.pc_balance_difference_formatted,- pc_balance_difference_float: current.attributes.pc_balance_difference_float,-- current_debt: current.attributes.debt_amount_formatted,- current_debt_float: current.attributes.debt_amount_float,- pc_current_debt: current.attributes.pc_debt_amount_formatted,- pc_current_debt_float: current.attributes.pc_debt_amount_float,-- liability_type: i18next.t("firefly.account_type_" + current.attributes.liability_type),- liability_direction: i18next.t(- "firefly.liability_direction_" + current.attributes.liability_direction + "_short",- ),- liability_interest: current.attributes.interest,- liability_interest_period: i18next- .t("firefly.interest_calc_" + current.attributes.interest_period)- .toLowerCase(),+ }+ // process all accounts in this search result.+ console.log('Have ' + response.data.data.length + ' accounts in this search result for tableId ' + tableId);+ for (let i = 0; i < response.data.data.length; i++) {+ if (Object.hasOwn(response.data.data, i)) {+ let current = this.filterAmounts(response.data.data[i]);+ let objectGroupTitle = current.attributes.object_group_title;+ let objectGroupId = parseInt(current.attributes.object_group_id);+ let group = "ungrouped";+++ if (0 !== objectGroupId && null !== objectGroupTitle) {+ group = "group_" + objectGroupId;+ }++ if(!Object.hasOwn(downloadedObjectGroups, group)) {+ console.log('Will create new group "' + group + '"');+ downloadedObjectGroups[group] = {+ group: group,+ id: null === current.attributes.object_group_id ? 0 : parseInt(current.attributes.object_group_id),+ title: null === current.attributes.object_group_title ? 'ungrouped' : current.attributes.object_group_title,+ order: null === current.attributes.object_group_order ? 0 : parseInt(current.attributes.object_group_order),+ accounts: [],+ total: 0,};- this.accounts.push(account);}+ downloadedObjectGroups[group].total += 1;++ if(downloadedObjectGroups[group].accounts.length >= this.listPageSize) {+ continue;+ }++ // console.log('Found account', current.attributes.object_group_title);+ let cc = current.attributes.currency_code;+ let pcc = current.attributes.primary_currency_code;+ this.prepareSumArrays(group, cc);+ this.prepareSumArrays(group, pcc);++ // add formatted amount property.+ current = this.createParsedAndFloatingAmounts(current, cc, "");+ current = this.createParsedAndFloatingAmounts(current, pcc, "pc_");+ //console.log(current);++ if (!this.convertToPrimary) {+ this.sums[group][cc] += current.attributes.current_balance_float;+ this.debts[group][cc] += current.attributes.debt_amount_float;+ this.differences[group][cc] += current.attributes.balance_difference_float;+ }+ if (this.convertToPrimary) {+ this.sums[group][pcc] += current.attributes.pc_current_balance_float;+ this.debts[group][pcc] += current.attributes.pc_debt_amount_float;+ this.differences[group][pcc] += current.attributes.pc_balance_difference_float;+ }+ let lastActivity = formatDate(current.attributes.last_activity, i18next.t("config.date_time_fns_short", {lng: locale}), locale,);++ let noLastActivity = false;+ if (null === current.attributes.last_activity) {+ lastActivity = i18next.t("firefly.never");+ noLastActivity = true;+ }+ // console.log('ID is', parseInt(current.id));+ let account = {+ id: parseInt(current.id),+ name: current.attributes.name,+ object_group_id: parseInt(current.attributes.object_group_id),+ object_group_title: current.attributes.object_group_title,+ location: null !== current.attributes.longitude && null !== current.attributes.latitude,+ has_attachments: current.attributes.has_attachments,+ role: current.attributes.account_role,+ iban: this.addSpaces(current.attributes.iban),+ account_number: current.attributes.account_number,++ currency_id: parseInt(current.attributes.currency_id),+ primary_currency_id: parseInt(current.attributes.primary_currency_id),++ active: current.attributes.active,+ last_activity: lastActivity,+ no_last_activity: noLastActivity,++ current_balance: current.attributes.current_balance_formatted,+ current_balance_float: current.attributes.current_balance_float,+ pc_current_balance: current.attributes.pc_current_balance_formatted,+ pc_current_balance_float: current.attributes.pc_current_balance_float,++ // current_balance: '1',+ // current_balance_float: 2,+ // pc_current_balance: '3',+ // pc_current_balance_float: 4,++ balance_difference: current.attributes.balance_difference_formatted,+ balance_difference_float: current.attributes.balance_difference_float,+ pc_balance_difference: current.attributes.pc_balance_difference_formatted,+ pc_balance_difference_float: current.attributes.pc_balance_difference_float,++ current_debt: current.attributes.debt_amount_formatted,+ current_debt_float: current.attributes.debt_amount_float,+ pc_current_debt: current.attributes.pc_debt_amount_formatted,+ pc_current_debt_float: current.attributes.pc_debt_amount_float,++ liability_type: i18next.t("firefly.account_type_" + current.attributes.liability_type),+ liability_direction: i18next.t(+ "firefly.liability_direction_" + current.attributes.liability_direction + "_short",+ ),+ liability_interest: current.attributes.interest,+ liability_interest_period: i18next+ .t("firefly.interest_calc_" + current.attributes.interest_period)+ .toLowerCase(),+ };+ downloadedObjectGroups[group].accounts.push(account);+ console.log('Grouped objects "'+group+ '" now consists of ' + downloadedObjectGroups[group].accounts.length + " accounts.");+ // this.sortableTable.loadingNewSort[group] = false;}- // console.log(- // "Done downloading accounts.",- // JSON.parse(JSON.stringify(this.filter)),- // this.accounts.length,- // );- this.loadingPage = false;- this.sortableTable.loadingNewSort = false;- this.sortableTable.disableRefresh = false;- if (0 === this.accounts.length && false === this.isFiltering) {- document.querySelectorAll(".data-holder").forEach((el) => {- el.classList.add("d-none");- });- }- });+ }+ console.log('Done with download');+ // after downloading and parsing, THEN do init.+ // initialize sortable table.+ if (null !== tableId) {+ console.log('Table id is', tableId);+ this.sortableTable.loadingNewSorts[tableId] = false;+ //console.log('Type of this.groupedObjects[tableId].accounts is', typeof this.groupedObjects[tableId].accounts, this.groupedObjects[tableId].accounts);+ // console.log('Type of downloadedObjectGroups is', typeof downloadedObjectGroups[tableId].accounts, downloadedObjectGroups[tableId].accounts);+ this.groupedObjects[tableId].accounts = downloadedObjectGroups[tableId].accounts;+ // let newGroups = JSON.parse(JSON.stringify(this.groupedObjects));+ // newGroups[tableId] = downloadedObjectGroups[tableId];+ //this.groupedObjects = newGroups;+ // this.sortableTable.loadingNewSort[tableId] = false;+ }++ // TODO needs to be per table, cannot be done yet.+ if (null === tableId) {+ downloadedObjectGroups = this.sortGroupedObjects(downloadedObjectGroups);+ this.launchSortableTable(downloadedObjectGroups);+ //this.loadingPage = false;+ // this.sortableTable.loadingNewSort = false; // TODO fix me+ //this.sortableTable.disableRefresh = false;+ // if (0 === this.accounts.length && false === this.isFiltering) {+ // document.querySelectorAll(".data-holder").forEach((el) => {+ // el.classList.add("d-none");+ // });+ // }+ }+++ });+++ },+ sortGroupedObjects(downloadedObjectGroups) {+ // turn grouped objects into array:+ let array = Object.keys(downloadedObjectGroups).map((key) => downloadedObjectGroups[key]);+ // sort array by order:+ array.sort((a, b) => a.order - b.order);+ // turn back into object:+ downloadedObjectGroups = {};+ for (let i = 0; i < array.length; i++) {+ let group = array[i].group;+ downloadedObjectGroups[group] = array[i];+ }+ return downloadedObjectGroups;},addSpaces(iban) {if (null === iban) {diff --git a/resources/assets/v3/js/pages/shared/drag-and-droppable-rows.js b/resources/assets/v3/js/pages/shared/drag-and-droppable-rows.jsindex 50f4b11623..09b2f39479 100644--- a/resources/assets/v3/js/pages/shared/drag-and-droppable-rows.js+++ b/resources/assets/v3/js/pages/shared/drag-and-droppable-rows.js@@ -19,7 +19,12 @@*/export function addDrag() {++ // TODO needs query selector ALL.const tbody = document.querySelector(".sortable tbody");+ if(null === tbody) {+ return;+ }let draggedRow = null;// animation Helperdiff --git a/resources/assets/v3/js/pages/shared/sortable-tables.js b/resources/assets/v3/js/pages/shared/sortable-tables.jsindex 90271714e1..0e27f62d56 100644--- a/resources/assets/v3/js/pages/shared/sortable-tables.js+++ b/resources/assets/v3/js/pages/shared/sortable-tables.js@@ -32,49 +32,61 @@ export class sortableTable {storageKey = "";disableRefresh = false;parent = null;- isFiltering = true;- loadingNewSort = true;+ isFiltering = true; // TODO do not use+ loadingNewSort = true; // TODO do not use.filter = {};+ loadingNewSorts = {};++constructor(tableIds) {+ this.tableIds = tableIds;+ }++ init(parent) {+ console.log('Now in sortable tables init()');+//this.tableId = tableId;- for (let i = 0; i < tableIds.length; i++) {- let tableId = tableIds[i];- this.sortColumns[tableId] = "order";- this.sortDirections[tableId] = "asc";+ for (let i = 0; i < this.tableIds.length; i++) {+ let tableId = this.tableIds[i];+ //this.sortColumns[tableId] = this.defaultSortcolumns "order";+ //this.sortDirections[tableId] = "asc";this.pages[tableId] = 1;- this.totalPages[tableId] = 1;- this.tableIds[tableId] = {- sortColumn: "order",- sortDirection: "asc",- page: 1,- };- console.log('Initialized sort table "' + tableId + '"');+ this.totalPages[tableId] = Object.hasOwn(this.totalPages, tableId) ? this.totalPages[tableId] : 1;+ this.loadingNewSorts[tableId] = false;+ // this.tableIds[tableId] = {+ // sortColumn: "order",+ // sortDirection: "asc",+ // page: 1,+ // };+ // console.log('Initialized sort table "' + tableId + '"');+ // console.log('Sort column: ', this.sortColumns[tableId])+ // console.log('Sort direction: ', this.sortDirections[tableId])}- }- init(parent) {+this.handleFunc = this.handlePageClick.bind(this);this.parent = parent;queueMicrotask(() => {console.log('Now calling update header classes from init-queuemicrotask');this.updateHeaderClasses();this.addClickEvents();+ this.addWatch();});- this.addWatch();}addWatch() {+ console.log('Now in addWatch()');const params = new Proxy(new URLSearchParams(window.location.search), {get: (searchParams, prop) => searchParams.get(prop),});- for (let tableId in this.tableIds) {- // console.log(tableId, this.tableIds[tableId]);+ for (let i in this.tableIds) {+ const tableId = this.tableIds[i];document.querySelectorAll('table[data-sort-identifier="' + tableId + '"] thead th[data-filter-column]').forEach((th) => {let column = th.getAttribute("data-filter-column");- // console.log('[class] Will watch "'+tableId+'" filter for column "' + column + '"');+ console.log('[class] Will watch "'+tableId+'" filter for column "' + column + '"');// also grab current filter value from store AND from url and push back to the parent whichever is set.const key = "filter[" + tableId + "][" + column + "]";@@ -85,7 +97,7 @@ export class sortableTable {// we do this in the parent because Alpine has the watch function that is needed.this.parent.$watch("filter." + tableId + "." + column, (newValue, oldValue) => {- //console.log('filter for "'+tableId+'" column "' + column + '" changed from "' + oldValue + '" to "' + newValue + '"',);+ console.log('filter for "'+tableId+'" column "' + column + '" changed from "' + oldValue + '" to "' + newValue + '"',);this.fireSortOrDataChangeEvent(tableId);if ("" !== newValue) {showSearchBox(th);@@ -103,6 +115,7 @@ export class sortableTable {}});}+ console.log('Done with addWatch()');}capturePageNavigation() {@@ -164,7 +177,8 @@ export class sortableTable {// some sort of trigger to parent?this.parent.updateHistory(this.pages, this.sortColumns, this.sortDirections); // TODO give all pages, sort columns and sort directions to parent- this.parent.downloadObjects();+ this.loadingNewSorts[tableId] = true;+ this.parent.downloadObjects(tableId);e.preventDefault();queueMicrotask(() => {this.capturePageNavigation();@@ -212,7 +226,8 @@ export class sortableTable {addClickEvents() {// add sortable click events.- for (let tableId in this.tableIds) {+ for (let i in this.tableIds) {+ const tableId = this.tableIds[i];document.querySelectorAll('table[data-sort-identifier="' + tableId + '"] th[data-sort-column] span.title').forEach((el) => {el.addEventListener("click", this.clickColumnTitle.bind(this));@@ -286,19 +301,24 @@ export class sortableTable {}updateHeaderClasses() {- for (let tableId in this.tableIds) {- console.log('Update headers for table "' + tableId + '"');- console.log('Sort directions', JSON.parse(JSON.stringify(this.sortDirections)));- console.log('Sort columns', JSON.parse(JSON.stringify(this.sortColumns)));+ console.log('Now in updateHeaderClasses()', this.tableIds);+ for (let i in this.tableIds) {+ const tableId = this.tableIds[i];+ console.log('Update headers for table "' + tableId + '"', tableId);+ // console.log('Sort direction for this table: ', this.sortDirections[tableId]);+ // console.log('Sort column for this table', this.sortColumns[tableId]);+ // console.log('Found columns to fix: ', document.querySelectorAll('table[data-sort-identifier="' + tableId + '"] thead th[data-sort-column]').length);document.querySelectorAll('table[data-sort-identifier="' + tableId + '"] thead th[data-sort-column]').forEach((th) => {if (this.sortColumns[tableId] === th.dataset.sortColumn) {th.classList.add("sortable_sorted");if ("asc" === this.sortDirections[tableId]) {+ console.log('Table "'+tableId+'" is sorted on column "'+th.dataset.sortColumn+'" in the ASC direction');th.classList.add("sortable_sorted_asc");th.classList.remove("sortable_sorted_desc");}if ("desc" === this.sortDirections[tableId]) {+ console.log('Table "'+tableId+'" is sorted on column "'+th.dataset.sortColumn+'" in the DESC direction');th.classList.add("sortable_sorted_desc");th.classList.remove("sortable_sorted_asc");}@@ -358,6 +378,7 @@ export function initFromLocalStorage() {// grab state from localStorage.let fromStore = window.store.get(this.storageKey);if (fromStore) {+ console.log('From store', JSON.parse(JSON.stringify(fromStore)));this.defaultSortColumns = fromStore.column;this.defaultSortDirections = fromStore.direction;}@@ -389,6 +410,9 @@ function parseQueryParams(search = window.location.search) {export function initFromQueryParams() {const params = parseQueryParams();this.defaultPages = params.page || this.defaultPages;++ console.log('From query params', JSON.parse(JSON.stringify(params)));+// make sure all defaultPages are integers:for (let tableId in this.defaultPages) {this.defaultPages[tableId] = parseInt(this.defaultPages[tableId]);@@ -403,22 +427,23 @@ export function respondToSortChange(event) {const tableId = event.detail.tableId;this.sortableTable.sortColumns[tableId] = event.detail.sortColumn;this.sortableTable.sortDirections[tableId] = event.detail.sortDirection;- this.updateHistory(this.sortableTable.pages, this.sortableTable.sortColumns, this.sortableTable.sortDirections); // TODO Need fix.+ this.sortableTable.loadingNewSorts[tableId] = true;+ this.updateHistory(this.sortableTable.pages, this.sortableTable.sortColumns, this.sortableTable.sortDirections);this.storeFilterAndSort(this.storageKey, this.sortableTable.sortColumns, this.sortableTable.sortDirections, this.filter); // TODO store for ALL.- this.downloadObjects();+ this.downloadObjects(tableId);}export function updateHistory(page, column, direction) {if (history.pushState) {let obj = {- page: page,- column: column,- direction: direction,+ page: this.sortableTable.pages,+ column: this.sortableTable.sortColumns,+ direction: this.sortableTable.sortDirections,filter: JSON.parse(JSON.stringify(this.filter)),};if (this.filter.length > 0) {this.isFiltering = true;- this.loadingPage = true;+ // this.loadingPage = true;}let string = objectToQueryString(obj);console.log("Update history", string);diff --git a/resources/views/accounts/index.blade.php b/resources/views/accounts/index.blade.phpindex 8f9748238f..e572aa355b 100644--- a/resources/views/accounts/index.blade.php+++ b/resources/views/accounts/index.blade.php@@ -10,122 +10,126 @@</div></div></template>-- <div class="col-lg-12 col-md-12 col-sm-12 data-holder">- <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">- <template x-if="sortableTable.totalPages.main > 1">- <x-elements.alpine.page-navigation sort-identifier="main"/>- </template>-- <table data-sort-identifier="main" class="table table-valign-middle table-sm table-hover sortable">- <thead>- <tr>- <th data-sort-column="order" class="w-5">- <span class="title"> </span>- </th>- <th data-sort-column="name" data-filter-column="name" class="w-20"><span class="title">{{ trans('list.name') }}</span></th>- <template x-if="'asset' === objectType">- {{-- hide on LG and smaller. --}}- <th data-sort-column="role" class="d-lg-table-cell d-none"><span class="title">{{ trans('list.role') }}</span></th>- </template>- <template x-if="'liabilities' === objectType">- <th data-sort-column="account_type_id"><span class="title">{{ trans('list.liability_type') }}</span></th>- </template>- <template x-if="'liabilities' === objectType">- <th data-sort-column="liability_direction"><span class="title">{{ trans('form.liability_direction') }}</span></th>- </template>- <template x-if="'liabilities' === objectType">- <th data-sort-column="liability_interest"><span class="title">{{ trans('list.interest') }}</span>- ({{ trans('list.interest_period') }})- </th>- </template>- <th data-sort-column="account_number_and_iban" data-filter-column="account_number_and_iban"><span class="title">{{ trans('form.account_number') }}</span></th>- <template x-if="'liabilities' !== objectType">- <th data-sort-column="current_balance"><span class="title">{{ trans('list.currentBalance') }}</span></th>- </template>- <template x-if="'liabilities' === objectType">- <th data-sort-column="debt_amount">- <span class="title">{{ trans('firefly.left_in_debt') }}</span>- </th>- </template>- <th {{-- hide on SM --}} class="d-md-table-cell d-none">{{ trans('list.active') }}</th>- {{-- hide last activity to make room for other stuff --}}- <template x-if="'liabilities' !== objectType">- {{-- hide on LG and smaller. --}}- <th data-sort-column="last_activity" class="d-lg-table-cell d-none"><span class="title">{{ trans('list.lastActivity') }}</span></th>- </template>- {{-- hide on SM --}}- <th data-sort-column="balance_difference" class="w-15 text-end d-lg-table-cell d-none"><span class="title">{{ trans('list.balanceDiff') }}</span></th>- <th> </th>- </tr>- <tr x-show="true === sortableTable.loadingNewSort">- <th colspan="12">- <div class="p-3 text-center">- <div class="spinner-border spinner-border-sm" role="status">- <span class="visually-hidden">{{ __('firefly.thinking') }}</span>- </div>- </div>- </th>- </tr>- </thead>- <tbody>- <template x-for="account in accounts" :key="account.id">- <tr :data-id="account.id">- <td>- <template- x-if="('asset' === objectType || 'liabilities' === objectType) && 'asc' === sortableTable.sortDirection && 'order' === sortableTable.sortColumn && accounts.length > 1">- <span class="btn btn-outline-secondary btn-sm bi bi-list object-handle"></span>- </template>- </td>- <td>- <a :href="'./accounts/show/' + account.id" :title="account.name"- x-text="account.name"></a>- <template x-if="account.location">- <span class="bi bi-map"></span>- </template>- <template x-if="true === account.has_attachments">- <span class="bi bi-paperclip"></span>- </template>- </td>- <template x-if="'asset' === objectType">- <td class="d-lg-table-cell d-none">- <template x-if="null !== account.role">- <span x-text="i18next.t('firefly.account_role_' + account.role)"></span>+ <template x-for="(data, tableId) in groupedObjects" :key="tableId">+ <div class="col-lg-12 col-md-12 col-sm-12 data-holder mb-2">+ <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">+ <span x-text="data.title"></span>+ <table :data-sort-identifier="tableId" class="table table-valign-middle table-sm table-hover sortable">+ <thead>+ <template x-if="sortableTable.totalPages[tableId] > 1">+ <tr>+ <th colspan="10">+ <x-elements.alpine.page-navigation />+ </th>+ </tr></template>- <template x-if="null === account.role || '' === account.role">- <span>~</span>- </template>- </td>- </template>- <template x-if="'liabilities' === objectType">- <td>- <span x-text="account.liability_type"></span>- </td>- </template>- <template x-if="'liabilities' === objectType">- <td>- <span x-text="account.liability_direction"></span>- </td>- </template>- <template x-if="'liabilities' === objectType">- <td>- <span x-text="account.liability_interest"></span>%- (<span x-text="account.liability_interest_period"></span>)- </td>- </template>- <td>- <span x-text="account.iban"></span>- <template x-if="'' === account.iban">- <span x-text="account.account_number"></span>- </template>- </td>- <template x-if="'liabilities' !== objectType">- <td class="text-end">- <template x-if="!convertToPrimary || account.primary_currency_id === account.currency_id">+ <tr>+ <th data-sort-column="order" class="w-5">+ <span class="title"> </span>+ </th>+ <th data-sort-column="name" data-filter-column="name" class="w-20"><span class="title">{{ trans('list.name') }}</span></th>+ <template x-if="'asset' === objectType">+ {{-- hide on LG and smaller. --}}+ <th data-sort-column="role" class="w-10 d-lg-table-cell d-none"><span class="title">{{ trans('list.role') }}</span></th>+ </template>+ <template x-if="'liabilities' === objectType">+ <th class="w-10" data-sort-column="account_type_id"><span class="title">{{ trans('list.liability_type') }}</span></th>+ </template>+ <template x-if="'liabilities' === objectType">+ <th class="w-10" data-sort-column="liability_direction"><span class="title">{{ trans('form.liability_direction') }}</span></th>+ </template>+ <template x-if="'liabilities' === objectType">+ <th data-sort-column="liability_interest"><span class="title">{{ trans('list.interest') }}</span>+ ({{ trans('list.interest_period') }})+ </th>+ </template>+ <th class="w-15" data-sort-column="account_number_and_iban" data-filter-column="account_number_and_iban"><span class="title">{{ trans('form.account_number') }}</span></th>+ <template x-if="'liabilities' !== objectType">+ <th class="w-10" data-sort-column="current_balance"><span class="title">{{ trans('list.currentBalance') }}</span></th>+ </template>+ <template x-if="'liabilities' === objectType">+ <th data-sort-column="debt_amount">+ <span class="title">{{ trans('firefly.left_in_debt') }}</span>+ </th>+ </template>+ <th class="w-5" {{-- hide on SM --}} class="d-md-table-cell d-none">{{ trans('list.active') }}</th>+ {{-- hide last activity to make room for other stuff --}}+ <template x-if="'liabilities' !== objectType">+ {{-- hide on LG and smaller. --}}+ <th data-sort-column="last_activity" class="w-10 d-lg-table-cell d-none"><span class="title">{{ trans('list.lastActivity') }}</span></th>+ </template>+ {{-- hide on SM --}}+ <th data-sort-column="balance_difference" class="w-10 text-end d-lg-table-cell d-none"><span class="title">{{ trans('list.balanceDiff') }}</span></th>+ <th class="w-5"> </th>+ </tr>+ <tr x-show="true === sortableTable.loadingNewSorts[tableId]">+ <th colspan="12">+ <div class="p-3 text-center">+ <div class="spinner-border spinner-border-sm" role="status">+ <span class="visually-hidden">{{ __('firefly.thinking') }}</span>+ </div>+ </div>+ </th>+ </tr>+ </thead>+ <tbody>+ <template x-for="account in data.accounts" :key="account.id">+ <tr :data-id="account.id">+ <td>+ <template+ x-if="('asset' === objectType || 'liabilities' === objectType) && 'asc' === sortableTable.sortDirections[tableId] && 'order' === sortableTable.sortColumns[tableId] && groupedObjects[tableId].accounts.length > 1">+ <span class="btn btn-outline-secondary btn-sm bi bi-list object-handle"></span>+ </template>+ </td>+ <td>+ <a :href="'./accounts/show/' + account.id" :title="account.name"+ x-text="account.name"></a>+ <template x-if="account.location">+ <span class="bi bi-map"></span>+ </template>+ <template x-if="true === account.has_attachments">+ <span class="bi bi-paperclip"></span>+ </template>+ </td>+ <template x-if="'asset' === objectType">+ <td class="d-lg-table-cell d-none">+ <template x-if="null !== account.role">+ <span x-text="i18next.t('firefly.account_role_' + account.role)"></span>+ </template>+ <template x-if="null === account.role || '' === account.role">+ <span>~</span>+ </template>+ </td>+ </template>+ <template x-if="'liabilities' === objectType">+ <td>+ <span x-text="account.liability_type"></span>+ </td>+ </template>+ <template x-if="'liabilities' === objectType">+ <td>+ <span x-text="account.liability_direction"></span>+ </td>+ </template>+ <template x-if="'liabilities' === objectType">+ <td>+ <span x-text="account.liability_interest"></span>%+ (<span x-text="account.liability_interest_period"></span>)+ </td>+ </template>+ <td>+ <span x-text="account.iban"></span>+ <template x-if="'' === account.iban">+ <span x-text="account.account_number"></span>+ </template>+ </td>+ <template x-if="'liabilities' !== objectType">+ <td class="text-end">+ <template x-if="!convertToPrimary || account.primary_currency_id === account.currency_id"><span><template x-if="0.0 === account.current_balance_float"><span class="money-neutral" x-text="account.current_balance"></span>@@ -137,8 +141,8 @@<span class="money-negative" x-text="account.current_balance"></span></template></span>- </template>- <template x-if="convertToPrimary && account.primary_currency_id !== account.currency_id">+ </template>+ <template x-if="convertToPrimary && account.primary_currency_id !== account.currency_id"><span><template x-if="0.0 === account.current_balance_float"><span>~ <span class="money-neutral" x-text="account.pc_current_balance"></span></span>@@ -159,12 +163,12 @@<span>(<span class="money-negative" x-text="account.current_balance"></span>)</span></template></span>- </template>- </td>- </template>- <template x-if="'liabilities' === objectType">- <td class="text-end">- <template x-if="!convertToPrimary || account.primary_currency_id === account.currency_id">+ </template>+ </td>+ </template>+ <template x-if="'liabilities' === objectType">+ <td class="text-end">+ <template x-if="!convertToPrimary || account.primary_currency_id === account.currency_id"><span><template x-if="0.0 === account.current_debt_float"><span class="money-neutral" x-text="account.current_debt"></span>@@ -176,8 +180,8 @@<span class="money-negative" x-text="account.current_debt"></span></template></span>- </template>- <template x-if="convertToPrimary && account.primary_currency_id !== account.currency_id">+ </template>+ <template x-if="convertToPrimary && account.primary_currency_id !== account.currency_id"><span><template x-if="0.0 === account.current_debt_float"><span>~ <span class="money-neutral" x-text="account.pc_current_debt"></span></span>@@ -198,29 +202,29 @@<span>(<span class="money-negative" x-text="account.current_debt"></span>)</span></template></span>- </template>- </td>- </template>- <td class="d-md-table-cell d-none">- <template x-if="true === account.active">- <span class="bi bi-check text-success"></span>- </template>- <template x-if="false === account.active">- <span class="bi bi-x text-danger"></span>- </template>- </td>- <template x-if="'liabilities' !== objectType">- <td>- <template x-if="true === account.no_last_activity">- <em class="text-muted" x-text="account.last_activity"></em>- </template>- <template x-if="false === account.no_last_activity">- <span x-text="account.last_activity"></span>- </template>- </td>- </template>- <td class="text-end">- <template x-if="!convertToPrimary || account.primary_currency_id === account.currency_id">+ </template>+ </td>+ </template>+ <td class="d-md-table-cell d-none">+ <template x-if="true === account.active">+ <span class="bi bi-check text-success"></span>+ </template>+ <template x-if="false === account.active">+ <span class="bi bi-x text-danger"></span>+ </template>+ </td>+ <template x-if="'liabilities' !== objectType">+ <td>+ <template x-if="true === account.no_last_activity">+ <em class="text-muted" x-text="account.last_activity"></em>+ </template>+ <template x-if="false === account.no_last_activity">+ <span x-text="account.last_activity"></span>+ </template>+ </td>+ </template>+ <td class="text-end">+ <template x-if="!convertToPrimary || account.primary_currency_id === account.currency_id"><span><template x-if="0.0 === account.balance_difference_float"><span class="money-neutral" x-text="account.balance_difference"></span>@@ -232,8 +236,8 @@<span class="money-negative" x-text="account.balance_difference"></span></template></span>- </template>- <template x-if="convertToPrimary && account.primary_currency_id !== account.currency_id">+ </template>+ <template x-if="convertToPrimary && account.primary_currency_id !== account.currency_id"><span><template x-if="0.0 === account.balance_difference_float"><span>~ <span class="money-neutral" x-text="account.pc_balance_difference"></span></span>@@ -254,48 +258,48 @@<span>(<span class="money-negative" x-text="account.balance_difference"></span>)</span></template></span>- </template>- </td>- <td class="justify-content-end">- <div class="dropdown">- <button class="btn btn-outline-secondary btn-sm dropdown-toggle" type="button"- :id="'action_menu_' + account.id" data-bs-toggle="dropdown"- aria-expanded="false">- {{ __('firefly.actions') }}- </button>- <ul class="dropdown-menu" :aria-labelledby="'action_menu_' + account.id">- <li><a class="dropdown-item"- :href="'./accounts/edit/' + account.id + '?_from={{ urlencode($FF3_FROM) }}'"><span- class="bi bi-pencil"></span> {{ __('firefly.edit') }}</a></li>- <li><a class="dropdown-item"- :href="'./accounts/delete/' + account.id + '?_from={{ urlencode($FF3_FROM) }}'"><span- class="bi bi-trash"></span> {{ __('firefly.delete') }}</a></li>- <template x-if="'asset' === objectType">- <li><a class="dropdown-item"- :href="'./accounts/reconcile/' + account.id + '/index'"><span- class="bi bi-check"></span> {{ __('firefly.reconcile_this_account') }}- </a></li>- </template>- </ul>- </div>- </td>- </tr>- </template>- </tbody>- <template- x-if="accounts.length > 0 && ('asset' === objectType || 'liabilities' === objectType)">- <tfoot>- <tr>- <td colspan="3"> </td>- <template x-if="'asset' === objectType">- <td> </td>- </template>- <template x-if="'liabilities' === objectType">- <td colspan="3"> </td>- </template>- <template x-if="'liabilities' !== objectType">- <td class="text-end">- <template x-for="(sum, code) in sums">+ </template>+ </td>+ <td class="justify-content-end">+ <div class="dropdown">+ <button class="btn btn-outline-secondary btn-sm dropdown-toggle" type="button"+ :id="'action_menu_' + account.id" data-bs-toggle="dropdown"+ aria-expanded="false">+ {{ __('firefly.actions') }}+ </button>+ <ul class="dropdown-menu" :aria-labelledby="'action_menu_' + account.id">+ <li><a class="dropdown-item"+ :href="'./accounts/edit/' + account.id + '?_from={{ urlencode($FF3_FROM) }}'"><span+ class="bi bi-pencil"></span> {{ __('firefly.edit') }}</a></li>+ <li><a class="dropdown-item"+ :href="'./accounts/delete/' + account.id + '?_from={{ urlencode($FF3_FROM) }}'"><span+ class="bi bi-trash"></span> {{ __('firefly.delete') }}</a></li>+ <template x-if="'asset' === objectType">+ <li><a class="dropdown-item"+ :href="'./accounts/reconcile/' + account.id + '/index'"><span+ class="bi bi-check"></span> {{ __('firefly.reconcile_this_account') }}+ </a></li>+ </template>+ </ul>+ </div>+ </td>+ </tr>+ </template>+ </tbody>+ <tfoot>+ <template+ x-if="accounts.length > 0 && ('asset' === objectType || 'liabilities' === objectType)">+ <tr>+ <td colspan="3"> </td>+ <template x-if="'asset' === objectType">+ <td> </td>+ </template>+ <template x-if="'liabilities' === objectType">+ <td colspan="3"> </td>+ </template>+ <template x-if="'liabilities' !== objectType">+ <td class="text-end">+ <template x-for="(sum, code) in sums"><span><template x-if="sum > 0"><span>@@ -310,12 +314,12 @@</span></template></span>- </template>- </td>- </template>- <template x-if="'liabilities' === objectType">- <td class="text-end">- <template x-for="(sum, code) in debts">+ </template>+ </td>+ </template>+ <template x-if="'liabilities' === objectType">+ <td class="text-end">+ <template x-for="(sum, code) in debts"><span><template x-if="sum > 0"><span>@@ -330,15 +334,15 @@</span></template></span>- </template>- </td>- </template>- <td> </td> <!-- is active column -->- <template x-if="'liabilities' !== objectType">- <td> </td> {{-- last activity column --}}- </template>- <td class="text-end">- <template x-for="(sum, code) in differences">+ </template>+ </td>+ </template>+ <td> </td> <!-- is active column -->+ <template x-if="'liabilities' !== objectType">+ <td> </td> {{-- last activity column --}}+ </template>+ <td class="text-end">+ <template x-for="(sum, code) in differences"><span><template x-if="sum > 0"><span>@@ -353,34 +357,39 @@</span></template></span>- </template>- </td>- <template x-if="'liabilities' === objectType">- <td> </td>- </template>-- <template x-if="'liabilities' !== objectType">- <td> </td>- </template>- </tr>- </tfoot>- </template>- </table>+ </template>+ </td>+ <template x-if="'liabilities' === objectType">+ <td> </td>+ </template>- <template x-if="sortableTable.totalPages.main > 1">- <x-elements.alpine.page-navigation sort-identifier="main"/>- </template>+ <template x-if="'liabilities' !== objectType">+ <td> </td>+ </template>+ </tr>+ </template>+ <template x-if="sortableTable.totalPages[tableId] > 1">+ <tr>+ <th colspan="10">+ <x-elements.alpine.page-navigation />+ </th>+ </tr>+ </template>+ </tfoot>+ </table>+ </div>+ <x-elements.card-footer-with-menu+ :route="route('accounts.create', $objectType) . '?_from=' . urlencode($FF3_FROM)"+ :linkTitle="__('firefly.make_new_'. $objectType . '_account')"/></div>- <x-elements.card-footer-with-menu- :route="route('accounts.create', $objectType) . '?_from=' . urlencode($FF3_FROM)"- :linkTitle="__('firefly.make_new_'. $objectType . '_account')"/></div>- </div>- <template x-if="0 === accounts.length && true === active && false === loadingPage && false === sortableTable.isFiltering">+ </template>++ <template x-if="0 === groupedObjects.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>- <template x-if="0 === accounts.length && true === active">+ <template x-if="0 === groupedObjects.length && true === active"><p class="text-center"><small><em><a href="{{ route('accounts.inactive.index', $objectType) }}">@@ -391,7 +400,7 @@</small></p></template>- <template x-if="0 !== accounts.length && true === active">+ <template x-if="0 !== groupedObjects.length && true === active"><p class="text-center"><small><em><a href="{{ route('accounts.inactive.index', $objectType) }}">@@ -401,7 +410,7 @@</small></p></template>- <template x-if="0 !== accounts.length && false === active">+ <template x-if="0 !== groupedObjects.length && false === active"><p class="text-center"><small><em><a href="{{ route('accounts.index', $objectType) }}"><span@@ -410,7 +419,7 @@</small></p></template>- <template x-if="0 === accounts.length && false === active">+ <template x-if="0 === groupedObjects.length && false === active"><p class="text-center"><small><em><a href="{{ route('accounts.index', $objectType) }}"><spandiff --git a/resources/views/components/elements/alpine/page-navigation.blade.php b/resources/views/components/elements/alpine/page-navigation.blade.phpindex 26d6b06fde..6da5a3b464 100644--- a/resources/views/components/elements/alpine/page-navigation.blade.php+++ b/resources/views/components/elements/alpine/page-navigation.blade.php@@ -1,31 +1,31 @@-<template x-if="sortableTable.totalPages.{{ $sortIdentifier }} > 1" x-effect="sortableTable ? sortableTable.capturePageNavigation() : null">+<template x-if="sortableTable.totalPages[tableId] > 1" x-effect="sortableTable ? sortableTable.capturePageNavigation() : null"><div class="m-2">- <nav data-sort-identifier="{{ $sortIdentifier }}">+ <nav :data-sort-identifier="tableId"><ul class="pagination">- <li :class="{'page-item': true, 'disabled': 1 === sortableTable.pages.{{ $sortIdentifier }} }" :aria-disabled="1 === sortableTable.pages.{{ $sortIdentifier }} ? 'true' : 'false'" aria-label="{!! __('pagination.previous') !!}">- <template x-if="1 === sortableTable.pages.{{ $sortIdentifier }}">+ <li :class="{'page-item': true, 'disabled': 1 === sortableTable.pages[tableId] }" :aria-disabled="1 === sortableTable.pages[tableId] ? 'true' : 'false'" aria-label="{!! __('pagination.previous') !!}">+ <template x-if="1 === sortableTable.pages[tableId]"><span class="page-link" aria-hidden="true">‹</span></template>- <template x-if="sortableTable.pages.{{ $sortIdentifier }} > 1">- <a class="page-link" :data-page="(sortableTable.pages.{{ $sortIdentifier }}-1)" :href="pageNavUrl + '?page[{{ $sortIdentifier }}]=' + (sortableTable.pages.{{ $sortIdentifier }} - 1)" rel="prev" aria-label="{!! __('pagination.previous') !!}" title="{!! __('pagination.previous') !!}">‹</a>+ <template x-if="sortableTable.pages[tableId] > 1">+ <a class="page-link" :data-page="(sortableTable.pages[tableId]-1)" :href="pageNavUrl + '?page[' + tableId +']=' + (sortableTable.pages[tableId] - 1)" rel="prev" aria-label="{!! __('pagination.previous') !!}" title="{!! __('pagination.previous') !!}">‹</a></template></li>- <template x-for="current in sortableTable.totalPages.{{ $sortIdentifier }}" :key="current">- <li class="page-item" :class="{'page-item': true, 'active': current === sortableTable.pages.{{ $sortIdentifier }}}">- <template x-if="current !== sortableTable.pages.{{ $sortIdentifier }}">- <a class="page-link" :data-page="current" :href="pageNavUrl+'?page[{{ $sortIdentifier }}]=' + current" x-text="current" :aria-label="current"></a>+ <template x-for="current in sortableTable.totalPages[tableId]" :key="current">+ <li class="page-item" :class="{'page-item': true, 'active': current === sortableTable.pages[tableId]}">+ <template x-if="current !== sortableTable.pages[tableId]">+ <a class="page-link" :data-page="current" :href="pageNavUrl+'?page[' + tableId +']=' + current" x-text="current" :aria-label="current"></a></template>- <template x-if="current === sortableTable.pages.{{ $sortIdentifier }}">+ <template x-if="current === sortableTable.pages[tableId]"><span class="page-link" x-text="current"></span></template></li></template>- <li class="{'page-item': true, 'disabled': sortableTable.totalPages.{{ $sortIdentifier }} === sortableTable.pages.{{ $sortIdentifier }}" :aria-disabled="sortableTable.totalPages.{{ $sortIdentifier }} === sortableTable.pages.{{ $sortIdentifier }} ? 'true' : 'false'" aria-label="{!! __('pagination.next') !!}">- <template x-if="sortableTable.totalPages.{{ $sortIdentifier }} > sortableTable.pages.{{ $sortIdentifier }}">- <a class="page-link" :data-page="(sortableTable.pages.{{ $sortIdentifier }}+1)" :href="pageNavUrl+'?page[{{ $sortIdentifier }}]=' + (sortableTable.pages.{{ $sortIdentifier }} +1)" rel="next" aria-label="{!! __('pagination.next') !!}" title="{!! __('pagination.next') !!}">+ <li class="{'page-item': true, 'disabled': sortableTable.totalPages[tableId] === sortableTable.pages[tableId]" :aria-disabled="sortableTable.totalPages[tableId] === sortableTable.pages[tableId] ? 'true' : 'false'" aria-label="{!! __('pagination.next') !!}">+ <template x-if="sortableTable.totalPages[tableId] > sortableTable.pages[tableId]">+ <a class="page-link" :data-page="(sortableTable.pages[tableId]+1)" :href="pageNavUrl+'?page[' + tableId +']=' + (sortableTable.pages[tableId] +1)" rel="next" aria-label="{!! __('pagination.next') !!}" title="{!! __('pagination.next') !!}">›</a></template>- <template x-if="sortableTable.totalPages.{{ $sortIdentifier }} === sortableTable.pages.{{ $sortIdentifier }}">+ <template x-if="sortableTable.totalPages[tableId] === sortableTable.pages[tableId]"><span class="page-link" aria-hidden="true">›</span></template></li>