Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Reverse the mess I made by not working in a branch.
James Coleaa2d52ef73ce
diff --git a/app/Api/V1/Controllers/Models/Account/ShowController.php b/app/Api/V1/Controllers/Models/Account/ShowController.phpindex 376f121df7..f755833a30 100644--- a/app/Api/V1/Controllers/Models/Account/ShowController.php+++ b/app/Api/V1/Controllers/Models/Account/ShowController.php@@ -83,8 +83,9 @@ 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/Api/V1/Requests/Models/Account/StoreRequest.php b/app/Api/V1/Requests/Models/Account/StoreRequest.phpindex 1db598c186..1db2bfb5aa 100644--- a/app/Api/V1/Requests/Models/Account/StoreRequest.php+++ b/app/Api/V1/Requests/Models/Account/StoreRequest.php@@ -76,8 +76,6 @@ class StoreRequest extends FormRequest'notes' => $this->stringWithNewlines('notes'),'interest' => $this->convertString('interest'),'interest_period' => $this->convertString('interest_period'),- 'object_group_title' => $this->convertString('object_group_title'),- 'object_group_id' => $this->convertInteger('object_group_id'),];// append location information.$data = $this->appendLocationData($data, null);@@ -124,8 +122,6 @@ class StoreRequest extends FormRequest'interest' => ['min:0', 'max:100', 'numeric'],'interest_period' => sprintf('nullable|in:%s', implode(',', config('firefly.interest_periods'))),'notes' => ['min:0', 'max:32768'],- 'object_group_id' => ['numeric', 'belongsToUser:object_groups,id'],- 'object_group_title' => ['min:0', 'max:255'],];return Location::requestRules($rules);diff --git a/app/Api/V1/Requests/Models/Account/UpdateRequest.php b/app/Api/V1/Requests/Models/Account/UpdateRequest.phpindex 3b5aa322f3..5d184f2969 100644--- a/app/Api/V1/Requests/Models/Account/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/Account/UpdateRequest.php@@ -74,8 +74,6 @@ class UpdateRequest extends FormRequest'liability_direction' => ['liability_direction', 'convertString'],'liability_amount' => ['liability_amount', 'convertString'],'liability_start_date' => ['liability_start_date', 'date'],- 'object_group_id' => ['object_group_id', 'convertInteger'],- 'object_group_title' => ['object_group_title', 'convertString'],];$data = $this->getAllData($fields);@@ -115,8 +113,6 @@ class UpdateRequest extends FormRequest'interest' => ['required_if:type,liability', 'min:0', 'max:100', 'numeric'],'interest_period' => ['required_if:type,liability', 'in:daily,monthly,yearly'],'notes' => ['min:0', 'max:32768'],- 'object_group_id' => ['numeric', 'belongsToUser:object_groups,id'],- 'object_group_title' => ['min:0', 'max:255'],];return Location::requestRules($rules);diff --git a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.phpindex b845a49215..e93e708401 100644--- a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php+++ b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php@@ -77,7 +77,7 @@ class StoreRequest extends FormRequest'accounts.*.account_id' => ['required', 'numeric', 'belongsToUser:accounts,id'],'accounts.*.current_amount' => ['numeric', new IsValidZeroOrMoreAmount()],'object_group_id' => ['numeric', 'belongsToUser:object_groups,id'],- 'object_group_title' => ['min:0', 'max:255'],+ 'object_group_title' => ['min:1', 'max:255'],'target_amount' => ['required', new IsValidZeroOrMoreAmount()],'start_date' => ['required', 'date', 'after:1970-01-01', 'before:2038-01-17'],'transaction_currency_id' => ['exists:transaction_currencies,id', 'required_without:transaction_currency_code'],diff --git a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.phpindex 3f2e42539e..f7fe234148 100644--- a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php+++ b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php@@ -87,7 +87,7 @@ class UpdateRequest extends FormRequest'accounts.*.account_id' => ['required', 'numeric', 'belongsToUser:accounts,id'],'accounts.*.current_amount' => ['numeric', 'nullable', new IsValidZeroOrMoreAmount(true), new IsEnoughInAccounts($piggyBank, $this->getAll())],'object_group_id' => ['numeric', 'belongsToUser:object_groups,id'],- 'object_group_title' => ['min:0', 'max:255'],+ 'object_group_title' => ['min:1', 'max:255'],'transaction_currency_id' => ['exists:transaction_currencies,id', 'nullable'],'transaction_currency_code' => ['exists:transaction_currencies,code', 'nullable'],];diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.phpindex 4c1ab231ec..620fc0bea1 100644--- a/app/Factory/AccountFactory.php+++ b/app/Factory/AccountFactory.php@@ -29,10 +29,8 @@ use FireflyIII\Events\Model\Account\CreatedNewAccount;use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;-use FireflyIII\Models\ObjectGroup;use FireflyIII\Models\UserGroup;use FireflyIII\Repositories\Account\AccountRepositoryInterface;-use FireflyIII\Repositories\ObjectGroup\CreatesObjectGroups;use FireflyIII\Services\Internal\Support\AccountServiceTrait;use FireflyIII\Services\Internal\Support\LocationServiceTrait;use FireflyIII\Services\Internal\Update\AccountUpdateService;@@ -48,7 +46,6 @@ class AccountFactory{use AccountServiceTrait;use LocationServiceTrait;- use CreatesObjectGroups;protected AccountRepositoryInterface $accountRepository;protected array $validAssetFields;@@ -269,23 +266,6 @@ class AccountFactory// set order$this->storeOrder($account, $data);- $objectGroupTitle = $data['object_group_title'] ?? '';- if ('' !== $objectGroupTitle) {- $objectGroup = $this->findOrCreateObjectGroup($objectGroupTitle);- if ($objectGroup instanceof ObjectGroup) {- $account->objectGroups()->sync([$objectGroup->id]);- }- }- // try also with ID- $objectGroupId = (int) ($data['object_group_id'] ?? 0);- if (0 !== $objectGroupId) {- $objectGroup = $this->findObjectGroupById($objectGroupId);- if ($objectGroup instanceof ObjectGroup) {- $account->objectGroups()->sync([$objectGroup->id]);- }- }- $account->save();-// refresh and return$account->refresh();diff --git a/app/Http/Controllers/Account/EditController.php b/app/Http/Controllers/Account/EditController.phpindex 3618276b84..e4b95ed447 100644--- a/app/Http/Controllers/Account/EditController.php+++ b/app/Http/Controllers/Account/EditController.php@@ -157,7 +157,6 @@ final class EditController extends Controller'interest_period' => $repository->getMetaValue($account, 'interest_period'),'notes' => $this->repository->getNoteText($account),'active' => $hasOldInput ? (bool) $request->old('active') : $account->active,- 'object_group' => null !== $account->objectGroups->first() ? $account->objectGroups->first()->title : '',];if ('' === $openingBalanceAmount) {$preFilled['opening_balance'] = '';diff --git a/app/Http/Controllers/PiggyBank/AmountController.php b/app/Http/Controllers/PiggyBank/AmountController.phpindex 3ab1fe3e8a..560a12a317 100644--- a/app/Http/Controllers/PiggyBank/AmountController.php+++ b/app/Http/Controllers/PiggyBank/AmountController.php@@ -53,7 +53,7 @@ final class AmountController extends Controller$this->middleware(function ($request, $next) {app('view')->share('title', (string) trans('firefly.piggyBanks'));- app('view')->share('mainTitleIcon', 'bi-piggy-bank');+ app('view')->share('mainTitleIcon', 'bi-target');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);diff --git a/app/Http/Controllers/PiggyBank/CreateController.php b/app/Http/Controllers/PiggyBank/CreateController.phpindex 6657aa71a4..8c935f19bb 100644--- a/app/Http/Controllers/PiggyBank/CreateController.php+++ b/app/Http/Controllers/PiggyBank/CreateController.php@@ -53,7 +53,7 @@ final class CreateController extends Controller$this->middleware(function ($request, $next) {app('view')->share('title', (string) trans('firefly.piggyBanks'));- app('view')->share('mainTitleIcon', 'bi-piggy-bank');+ app('view')->share('mainTitleIcon', 'bi-target');$this->attachments = app(AttachmentHelperInterface::class);$this->piggyRepos = app(PiggyBankRepositoryInterface::class);diff --git a/app/Http/Controllers/PiggyBank/DeleteController.php b/app/Http/Controllers/PiggyBank/DeleteController.phpindex a347ce3ea9..b7237297f1 100644--- a/app/Http/Controllers/PiggyBank/DeleteController.php+++ b/app/Http/Controllers/PiggyBank/DeleteController.php@@ -48,7 +48,7 @@ final class DeleteController extends Controller$this->middleware(function ($request, $next) {app('view')->share('title', (string) trans('firefly.piggyBanks'));- app('view')->share('mainTitleIcon', 'bi-piggy-bank');+ app('view')->share('mainTitleIcon', 'bi-target');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);diff --git a/app/Http/Controllers/PiggyBank/EditController.php b/app/Http/Controllers/PiggyBank/EditController.phpindex caeba1380e..3be6f01a49 100644--- a/app/Http/Controllers/PiggyBank/EditController.php+++ b/app/Http/Controllers/PiggyBank/EditController.php@@ -53,7 +53,7 @@ final class EditController extends Controller$this->middleware(function ($request, $next) {app('view')->share('title', (string) trans('firefly.piggyBanks'));- app('view')->share('mainTitleIcon', 'bi-piggy-bank');+ app('view')->share('mainTitleIcon', 'bi-target');$this->attachments = app(AttachmentHelperInterface::class);$this->piggyRepos = app(PiggyBankRepositoryInterface::class);diff --git a/app/Http/Controllers/PiggyBank/IndexController.php b/app/Http/Controllers/PiggyBank/IndexController.phpindex 37b50dea9b..34e67be816 100644--- a/app/Http/Controllers/PiggyBank/IndexController.php+++ b/app/Http/Controllers/PiggyBank/IndexController.php@@ -60,7 +60,7 @@ final class IndexController extends Controller$this->middleware(function ($request, $next) {app('view')->share('title', (string) trans('firefly.piggyBanks'));- app('view')->share('mainTitleIcon', 'bi-piggy-bank');+ app('view')->share('mainTitleIcon', 'bi-target');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);diff --git a/app/Http/Controllers/PiggyBank/ShowController.php b/app/Http/Controllers/PiggyBank/ShowController.phpindex 957e7151cd..204b1d467e 100644--- a/app/Http/Controllers/PiggyBank/ShowController.php+++ b/app/Http/Controllers/PiggyBank/ShowController.php@@ -52,7 +52,7 @@ final class ShowController extends Controller$this->middleware(function ($request, $next) {app('view')->share('title', (string) trans('firefly.piggyBanks'));- app('view')->share('mainTitleIcon', 'bi-piggy-bank');+ app('view')->share('mainTitleIcon', 'bi-target');$this->piggyRepos = app(PiggyBankRepositoryInterface::class);diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.phpindex 6158212f7d..f33fdf0c1a 100644--- a/app/Http/Requests/AccountFormRequest.php+++ b/app/Http/Requests/AccountFormRequest.php@@ -72,7 +72,6 @@ class AccountFormRequest extends FormRequest'interest_period' => $this->convertString('interest_period'),'include_net_worth' => '1','liability_direction' => $this->convertString('liability_direction'),- 'object_group_title' => $this->convertString('object_group'),];$data = $this->appendLocationData($data, 'location');@@ -123,7 +122,6 @@ class AccountFormRequest extends FormRequest'interest_period' => 'in:daily,monthly,yearly','notes' => ['min:1', 'max:32768', 'nullable'],'_from' => ['nullable', 'max:255', new IsValidOriginUrl()],- 'object_group' => ['min:0', 'max:255'],];$rules = Location::requestRules($rules);diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.phpindex 74173e702c..6d56e1fcee 100644--- a/app/Repositories/Account/AccountRepository.php+++ b/app/Repositories/Account/AccountRepository.php@@ -261,25 +261,6 @@ 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');@@ -301,7 +282,6 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac}}-if (0 === $sorted) {if (0 !== count($res)) {$query->orderBy('accounts.order', 'ASC');diff --git a/app/Repositories/ObjectGroup/ObjectGroupRepository.php b/app/Repositories/ObjectGroup/ObjectGroupRepository.phpindex 72a9f07475..856810125f 100644--- a/app/Repositories/ObjectGroup/ObjectGroupRepository.php+++ b/app/Repositories/ObjectGroup/ObjectGroupRepository.php@@ -79,7 +79,7 @@ class ObjectGroupRepository implements ObjectGroupRepositoryInterface, UserGrouppublic function get(): Collection{return $this->user->objectGroups()- ->with(['piggyBanks', 'bills','accounts'])+ ->with(['piggyBanks', 'bills'])->orderBy('order', 'ASC')->orderBy('title', 'ASC')->get()diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.phpindex cf639e4efc..43852665f2 100644--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php@@ -326,7 +326,7 @@ trait ModifiesPiggyBanksreturn $piggyBank;}- $piggyBank->objectGroups()->detach();+ $piggyBank->objectGroups()->sync([]);$piggyBank->save();}@@ -342,7 +342,6 @@ trait ModifiesPiggyBanksreturn $piggyBank;}- $piggyBank->objectGroups()->detach();}return $piggyBank;diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.phpindex e67284ff01..06a76e13ea 100644--- a/app/Services/Internal/Update/AccountUpdateService.php+++ b/app/Services/Internal/Update/AccountUpdateService.php@@ -30,10 +30,8 @@ use FireflyIII\Exceptions\FireflyException;use FireflyIII\Models\Account;use FireflyIII\Models\AccountType;use FireflyIII\Models\Location;-use FireflyIII\Models\ObjectGroup;use FireflyIII\Models\UserGroup;use FireflyIII\Repositories\Account\AccountRepositoryInterface;-use FireflyIII\Repositories\ObjectGroup\CreatesObjectGroups;use FireflyIII\Services\Internal\Support\AccountServiceTrait;use FireflyIII\Support\Facades\Preferences;use FireflyIII\Support\Facades\Steam;@@ -47,7 +45,6 @@ use Illuminate\Support\Facades\Log;class AccountUpdateService{use AccountServiceTrait;- use CreatesObjectGroups;protected AccountRepositoryInterface $accountRepository;protected array $validAssetFields;@@ -125,26 +122,6 @@ class AccountUpdateService// update preferences if inactive:$this->updatePreferences($account);- $objectGroupTitle = $data['object_group_title'] ?? '';- if ('' !== $objectGroupTitle) {- $objectGroup = $this->findOrCreateObjectGroup($objectGroupTitle);- if ($objectGroup instanceof ObjectGroup) {- $account->objectGroups()->sync([$objectGroup->id]);- }- }- // try also with ID- $objectGroupId = (int) ($data['object_group_id'] ?? 0);- if (0 !== $objectGroupId) {- $objectGroup = $this->findObjectGroupById($objectGroupId);- if ($objectGroup instanceof ObjectGroup) {- $account->objectGroups()->sync([$objectGroup->id]);- }- }- if('' === $objectGroupTitle && 0 === $objectGroupId) {- $account->objectGroups()->detach();- }- $account->save();-event(new UpdatedExistingAccount($account, $oldData));return $account;diff --git a/config/firefly.php b/config/firefly.phpindex 7b3af32a8a..467cf90d38 100644--- a/config/firefly.php+++ b/config/firefly.php@@ -852,7 +852,6 @@ 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 ab94454a60..66cac38852 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, respondToSortChange, sortableTable, storeFilterAndSort, updateHistory} from "../shared/sortable-tables.js";+import {initFromLocalStorage, initFromQueryParams, sortableTable, storeFilterAndSort, updateHistory, respondToSortChange} from "../shared/sortable-tables.js";window.enableDates = true;@@ -38,31 +38,33 @@ let index = function () {// necessary for indexlistPageSize: 50,objectType: "invalid",+ accounts: [],+ page: 1,+ totalPages: 1,i18next: null,anonymous: false,- loadingPage: false,+ loadingPage: true,convertToPrimary: false,active: true,sums: {},debts: {},differences: {},- // grouped accounts per object group.- accounts: [],- groupedObjects: {},-+ // functions+ formatMoney: formatMoney,// default settings for sortable tables.storageKey: "",- defaultSortColumns: {"main": "order"},- defaultSortDirections: {"main": "asc"},- defaultPages: {"main": 1},- pageNavUrl: "./accounts/",- filter: {},+ defaultSortColumn: "order",+ defaultSortDirection: "asc",+ // variables necessary for sortable tables.+ pageNavUrl: "./accounts/",+ sortColumn: "order", // used in GET request. TODO needs change when doing multiple tables.+ sortDirection: "asc", // used in GET request. TODO needs change when doing multiple tables.+ filter: {}, // TODO needs change when doing multiple tables.// sort functions, imported- formatMoney: formatMoney,updateHistory: updateHistory,initFromLocalStorage: initFromLocalStorage,initFromQueryParams: initFromQueryParams,@@ -70,59 +72,40 @@ let index = function () {respondToSortChange: respondToSortChange,sortableTable: null,- launchSortableTable(groupedObjects) {- // create sortable table.- 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);- // }-- }-- console.log('final sort columns', JSON.parse(JSON.stringify(this.defaultSortColumns)));- console.log('final sort directions', JSON.parse(JSON.stringify(this.defaultSortDirections)));+ init() {+ // initialize sortable table.+ this.storageKey = "accounts-" + this.objectType + (this.active ? "-active" : "-inactive");+ this.defaultSortColumn = "expense" === this.objectType || "revenue" === this.objectType ? "name" : this.defaultSortColumn;+ this.initFromLocalStorage();+ this.initFromQueryParams();- // 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;- this.groupedObjects = groupedObjects;- this.sortableTable.init(this);- },+ // create sortable table.+ this.sortableTable = new sortableTable("main");- init() {- // prepare some variables.+ // 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.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];- this.initFromLocalStorage();- this.initFromQueryParams();+ // configure sortable table with final result (not filter).+ this.sortableTable.sortColumn = this.defaultSortColumn;+ this.sortableTable.sortDirection = this.defaultSortDirection;+ this.sortableTable.storageKey = this.storageKey;+ this.sortableTable.page = this.page;++ // initialize sortable table.+ this.sortableTable.init(this);// 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++) {@@ -143,15 +126,13 @@ let index = function () {});},- 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;+ 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;+ }+ }},filterAmounts(account) {// overrule some amounts, set them to zero when "this.anonymous" is true.@@ -178,246 +159,126 @@ let index = function () {}return account;},- 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;+ downloadObjects() {+ this.sortableTable.loadingNewSort = true;+ let sort = "asc" === this.sortableTable.sortDirection ? this.sortableTable.sortColumn : "-" + this.sortableTable.sortColumn;let start = window.store.get("start");let end = window.store.get("end");- 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 = {+ this.convertToPrimary = window.store.get("convert_to_primary");+ new Get()+ .list({active: this.active,sort: sort,- limit:1337,- page: page, // because we download ALL.+ page: this.page,type: this.objectType,start: start,- filter: JSON.parse(JSON.stringify(this.filter))["main"], // same.+ filter: JSON.parse(JSON.stringify(this.filter)),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: page, // because we download ALL.- type: this.objectType,- start: start,- filter: filter, // same.- end: end,- };- }- 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[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);- }- }- // 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,+ })+ .then((response) => {+ const locale = window.store.get("locale");+ this.accounts = [];+ this.sums = {};+ this.debts = {};+ this.differences = {};++ this.totalPages = parseInt(response.data.meta.pagination.total_pages);+ 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(),};+ 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 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;+ // 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");+ });+ }+ });},addSpaces(iban) {if (null === iban) {diff --git a/resources/assets/v3/js/pages/categories/index.js b/resources/assets/v3/js/pages/categories/index.jsindex 46b6f84b00..e5f47465c5 100644--- a/resources/assets/v3/js/pages/categories/index.js+++ b/resources/assets/v3/js/pages/categories/index.js@@ -25,7 +25,7 @@ import Alpine from "@alpinejs/csp";import formatMoney from "../../util/format-money.js";import formatDate from "../../util/format-date.js";import i18next from "i18next";-import {initFromLocalStorage, initFromQueryParams, respondToSortChange, sortableTable, storeFilterAndSort, updateHistory} from "../shared/sortable-tables.js";+import {initFromLocalStorage, initFromQueryParams, sortableTable, storeFilterAndSort, updateHistory, respondToSortChange} from "../shared/sortable-tables.js";import Get from "../../api/model/category/get.js";window.enableDates = false;@@ -33,22 +33,25 @@ window.enableDates = false;let index = function () {return {categories: [],+ totalPages: 0,+ page: 1,i18next: null,anonymous: false,loadingPage: true,convertToPrimary: false,- // default settings for sortable tables.- storageKey: "",- defaultSortColumns: {"main": "name"},- defaultSortDirections: {"main": "asc"},- defaultPages: {"main": 1},- filter: {},+ // functions+ formatMoney: formatMoney,+ formatDate: formatDate,++ // default settings for sortingpageNavUrl: "./categories/",+ storageKey: "categories-index",+ defaultSortColumn: "name",+ defaultSortDirection: "asc",+ filter: {},// sort functions, imported- formatMoney: formatMoney,- formatDate: formatDate,updateHistory: updateHistory,storeFilterAndSort: storeFilterAndSort,initFromLocalStorage: initFromLocalStorage,@@ -61,22 +64,17 @@ let index = function () {this.initFromQueryParams();// create sortable table.- let tables = ["main"];- for(let i = 0; i < tables.length; i++) {- let table = tables[i];- this.filter[table] = {};- }- this.sortableTable = new sortableTable(tables);+ this.sortableTable = new sortableTable("main");// prepare some varsthis.i18next = i18next;this.anonymous = window.store.get("anonymous");// configure sortable table with final result (not filter).- this.sortableTable.sortColumns = this.defaultSortColumns;- this.sortableTable.sortDirections = this.defaultSortDirections;+ this.sortableTable.sortColumn = this.defaultSortColumn;+ this.sortableTable.sortDirection = this.defaultSortDirection;this.sortableTable.storageKey = this.storageKey;- this.sortableTable.pages = this.defaultPages;+ this.sortableTable.page = this.page;// initialize sortable table.this.sortableTable.init(this);@@ -86,33 +84,20 @@ let index = function () {this.downloadObjects();},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"];- }-+ let sort = "asc" === this.sortableTable.sortDirection ? this.sortableTable.sortColumn : "-" + this.sortableTable.sortColumn;this.convertToPrimary = window.store.get("convert_to_primary");let locale = window.store.get("locale");new Get().list({active: this.active,sort: sort,- page: this.sortableTable.pages["main"],+ page: this.page,filter: JSON.parse(JSON.stringify(this.filter)),}).then((response) => {this.categories = [];-- this.sortableTable.totalPages["main"] = 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();- }+ this.totalPages = parseInt(response.data.meta.pagination.total_pages);for (let i = 0; i < response.data.data.length; i++) {if (Object.hasOwn(response.data.data, i)) {@@ -122,7 +107,7 @@ let index = function () {if (null !== current.attributes.last_activity) {lastActivity = formatDate(current.attributes.last_activity,- i18next.t("config.date_time_fns", {lng: locale}),+ i18next.t("config.date_time_fns", { lng: locale }),locale,);noLastActivity = false;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 09b2f39479..50f4b11623 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,12 +19,7 @@*/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/get-nearest-parent.js b/resources/assets/v3/js/pages/shared/get-nearest-parent.jsdeleted file mode 100644index 749284cd2f..0000000000--- a/resources/assets/v3/js/pages/shared/get-nearest-parent.js+++ /dev/null@@ -1,29 +0,0 @@-/*- * get-nearest-table.js- * Copyright (c) 2026 [email protected]- *- * This file is part of Firefly III (https://github.com/firefly-iii).- *- * This program is free software: you can redistribute it and/or modify- * it under the terms of the GNU Affero General Public License as- * published by the Free Software Foundation, either version 3 of the- * License, or (at your option) any later version.- *- * This program is distributed in the hope that it will be useful,- * but WITHOUT ANY WARRANTY; without even the implied warranty of- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- * GNU Affero General Public License for more details.- *- * You should have received a copy of the GNU Affero General Public License- * along with this program. If not, see <https://www.gnu.org/licenses/>.- */--export default function (htmlElementNode, tagName) {- while (htmlElementNode) {- htmlElementNode = htmlElementNode.parentNode;- if (tagName === htmlElementNode.tagName.toLowerCase()) {- return htmlElementNode;- }- }- return undefined;-}diff --git a/resources/assets/v3/js/pages/shared/sortable-tables.js b/resources/assets/v3/js/pages/shared/sortable-tables.jsindex 0e27f62d56..5cb68aa99c 100644--- a/resources/assets/v3/js/pages/shared/sortable-tables.js+++ b/resources/assets/v3/js/pages/shared/sortable-tables.js@@ -19,105 +19,71 @@*/import i18next from "i18next";-import getNearestParent from '../shared/get-nearest-parent.js'export class sortableTable {- tableIds = {};- sortColumns = {};- sortDirections = {};- pages = {};- totalPages= {};- sortColumn = "order"; // todo forbidden to use!- sortDirection = "asc"; // todo forbidden to use!+ tableId = "";+ sortColumn = "order";+ sortDirection = "asc";storageKey = "";disableRefresh = false;parent = null;- isFiltering = true; // TODO do not use- loadingNewSort = true; // TODO do not use.+ isFiltering = true;+ loadingNewSort = true;filter = {};- loadingNewSorts = {};--- constructor(tableIds) {- this.tableIds = tableIds;+ constructor(tableId) {+ this.tableId = tableId;+ console.log('Now in constructor("' + tableId + '")');}init(parent) {- console.log('Now in sortable tables init()');-- //this.tableId = tableId;- 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] = 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])- }--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 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 + '"');-- // also grab current filter value from store AND from url and push back to the parent whichever is set.- const key = "filter[" + tableId + "][" + column + "]";- let urlValue = params[key] ?? null;- let fromStore = window.store.get(this.storageKey);- let storeValue = fromStore ? (fromStore.filter[column] ?? null) : null;- let valueToUse = null !== urlValue ? urlValue : storeValue;-- // 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 + '"',);- this.fireSortOrDataChangeEvent(tableId);- if ("" !== newValue) {- showSearchBox(th);- }- });- if (null !== valueToUse && "" !== valueToUse) {- this.disableRefresh = true;- this.parent.isFiltering = true;- this.parent.filter[tableId][column] = valueToUse;- // make sure the button is visible.- queueMicrotask(() => {- showSearchBox(th);- });+ document+ .querySelectorAll('table[data-sort-identifier="' + this.tableId + '"] thead th[data-filter-column]')+ .forEach((th) => {+ let column = th.getAttribute("data-filter-column");+ console.log('[class] Will watch 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[" + column + "]";+ let urlValue = params[key] ?? null;+ let fromStore = window.store.get(this.storageKey);+ let storeValue = fromStore ? (fromStore.filter[column] ?? null) : null;+ let valueToUse = null !== urlValue ? urlValue : storeValue;++ // we do this in the parent because Alpine has the watch function that is needed.+ this.parent.$watch("filter." + column, (newValue, oldValue) => {+ console.log('filter for column "' + column + '" changed from "' + oldValue + '" to "' + newValue + '"',);+ this.fireSortChangeEvent();+ if ("" !== newValue) {+ showSearchBox(th);}});- }- console.log('Done with addWatch()');- }+ if (null !== valueToUse && "" !== valueToUse) {+ this.disableRefresh = true;+ this.parent.isFiltering = true;+ this.parent.filter[column] = valueToUse;+ // make sure the button is visible.+ queueMicrotask(() => {+ showSearchBox(th);+ });+ }+ });+ }capturePageNavigation() {// console.log("capturePageNavigation()");document.querySelectorAll("a.page-link").forEach((el) => {@@ -128,57 +94,30 @@ export class sortableTable {clickColumnTitle(event) {let parent = event.currentTarget.parentNode;- const parentTable = getNearestParent(parent, "table");- const tableId = parentTable.dataset.sortIdentifier;let newColumn = parent.dataset.sortColumn;-- // oldthis.sortDirection = typeof this.sortDirection !== "undefined" ? this.sortDirection : "asc";- // new: sort direction and sort column to be put in tableIds[tableId].- this.sortDirections[tableId] = typeof this.sortDirections[tableId] !== "undefined" ? this.sortDirections[tableId] : "asc";-- // old:if (newColumn === this.sortColumn) {this.sortDirection = "asc" === this.sortDirection ? "desc" : "asc";}- // new:- if (newColumn === this.sortColumns[tableId]) {- this.sortDirections[tableId] = "asc" === this.sortDirections[tableId] ? "desc" : "asc";- }-- // old:if (newColumn !== this.sortColumn) {this.sortColumn = newColumn;}- // new:- if (newColumn !== this.sortColumns[tableId]) {- this.sortColumns[tableId] = newColumn;- }- this.fireSortOrDataChangeEvent(tableId);+ this.fireSortChangeEvent();}handlePageClick(e) {let link = e.currentTarget;- let nav = getNearestParent(link, "nav");- const tableId = nav.dataset.sortIdentifier;let page = parseInt(link.dataset.page);if (isNaN(page)) {e.preventDefault();return false;}- // old:- // this.page = page;- // new:- this.pages[tableId] = page;-- // should be removed:- // this.parent.page = page;-+ this.page = page;+ this.parent.page = page;// 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.loadingNewSorts[tableId] = true;- this.parent.downloadObjects(tableId);+ this.parent.updateHistory(page, this.sortColumn, this.sortDirection);+ this.parent.downloadObjects();e.preventDefault();queueMicrotask(() => {this.capturePageNavigation();@@ -186,32 +125,29 @@ export class sortableTable {return false;}- fireSortOrDataChangeEvent(tableId) {- console.log('Now calling update header classes from fireSortOrDataChangeEvent');+ fireSortChangeEvent() {this.updateHeaderClasses();let obj = {- tableId: tableId,- sortColumn: this.sortColumns[tableId],- sortDirection: this.sortDirections[tableId],+ tableId: this.tableId,+ sortColumn: this.sortColumn,+ sortDirection: this.sortDirection,};console.log("Change sort instructions", obj);let event = new CustomEvent("sortable-table-sort-change", {detail: obj,});if (!this.disableRefresh) {- // console.log("Fire event!");+ console.log("Fire event!");document.dispatchEvent(event);}- // if (this.disableRefresh) {- // console.log("Do NOT fire event!");- // this.disableRefresh = false;- // }+ if (this.disableRefresh) {+ console.log("Do NOT fire event!");+ this.disableRefresh = false;+ }}clickCloseButton(event) {let th = event.currentTarget.parentNode.parentNode.parentNode;- const table = getNearestParent(th, "table");- const tableId = table.dataset.sortIdentifier;let column = th.dataset.filterColumn;console.log("close search box for ", column);th.querySelector(".search-filter").classList.add("d-none");@@ -220,42 +156,39 @@ export class sortableTable {th.querySelector(".search-button").classList.remove("d-none");// console.log(th.querySelector('.form-control').value);th.querySelector(".form-control").value = "";- this.parent.filter[tableId][column] = "";- this.fireSortOrDataChangeEvent(tableId);+ this.parent.filter[column] = "";+ this.fireSortChangeEvent();}addClickEvents() {// add sortable click events.- 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));- });-- // create search buttons and inputs.- document.querySelectorAll('table[data-sort-identifier="' + tableId + '"] th[data-filter-column]').forEach(- function (el) {- this.createSearchBox(el);- }.bind(this),- );-- // add event to search-button.- document.querySelectorAll('table[data-sort-identifier="' + tableId + '"] th[data-filter-column] .search-button',)- .forEach((el) => {- el.addEventListener("click", () => {- const th = el.parentNode.parentNode;- showSearchBox(th);- });+ document+ .querySelectorAll('table[data-sort-identifier="' + this.tableId + '"] th[data-sort-column] span.title')+ .forEach((el) => {+ el.addEventListener("click", this.clickColumnTitle.bind(this));+ });++ // create search buttons and inputs.+ document.querySelectorAll('table[data-sort-identifier="' + this.tableId + '"] th[data-filter-column]').forEach(+ function (el) {+ this.createSearchBox(el);+ }.bind(this),+ );++ document+ .querySelectorAll(+ 'table[data-sort-identifier="' + this.tableId + '"] th[data-filter-column] .search-button',+ )+ .forEach((el) => {+ el.addEventListener("click", () => {+ const th = el.parentNode.parentNode;+ showSearchBox(th);});- }+ });}-createSearchBox(th) {//console.log('createSearchBox', th);let column = th.dataset.filterColumn;- let table = getNearestParent(th, "table");- let tableId = table.dataset.sortIdentifier;// create filter inset.let inset = document.createElement("span");inset.classList.add("search-inset");@@ -280,7 +213,7 @@ export class sortableTable {input.classList.add("form-control", "form-control-sm");input.setAttribute("type", "search");input.setAttribute("placeholder", i18next.t("firefly.filter_placeholder_" + column));- input.setAttribute("x-model", "filter." + tableId + "." + column);+ input.setAttribute("x-model", "filter." + column);div.appendChild(input);// create button@@ -301,38 +234,27 @@ export class sortableTable {}updateHeaderClasses() {- 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");- }+ document.querySelectorAll('table[data-sort-identifier="' + this.tableId + '"] thead th[data-sort-column]')+ .forEach((th) => {+ if (this.sortColumn === th.dataset.sortColumn) {+ th.classList.add("sortable_sorted");+ if ("asc" === this.sortDirection) {+ th.classList.add("sortable_sorted_asc");+ th.classList.remove("sortable_sorted_desc");}- if (this.sortColumns[tableId] !== th.dataset.sortColumn) {+ if ("desc" === this.sortDirection) {+ th.classList.add("sortable_sorted_desc");th.classList.remove("sortable_sorted_asc");- th.classList.remove("sortable_sorted_desc");- th.classList.remove("sortable_sorted");}- });- }+ }+ if (this.sortColumn !== th.dataset.sortColumn) {+ th.classList.remove("sortable_sorted_asc");+ th.classList.remove("sortable_sorted_desc");+ th.classList.remove("sortable_sorted");+ }+ });}}-function showSearchBox(th) {// let column = th.dataset.filterColumn;@@ -378,77 +300,48 @@ 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;- }-}--function parseQueryParams(search = window.location.search) {- const params = new URLSearchParams(search);- const result = {};-- for (const [key, value] of params) {- const parts = key.split(/[\[\]]/).filter(Boolean);- let current = result;-- for (let i = 0; i < parts.length; i++) {- const part = parts[i];-- if (i === parts.length - 1) {- current[part] = value;- } else {- current[part] ??= {};- current = current[part];- }- }+ this.defaultSortColumn = fromStore.column;+ this.defaultSortDirection = fromStore.direction;+ this.defaultFilter = fromStore.filter;}-- return result;}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]);- }-- this.defaultSortColumns = params.column ?? this.defaultSortColumns;- this.defaultSortDirections = params.direction ?? this.defaultSortDirections;+ // grab state from URL params.+ // Filter is not part of this because the code does not know which columns are filterable.+ const params = new Proxy(new URLSearchParams(window.location.search), {+ get: (searchParams, prop) => searchParams.get(prop),+ });+ this.page = parseInt(params.page || "1");+ this.defaultSortColumn = params.column ?? this.defaultSortColumn;+ this.defaultSortDirection = params.direction ?? this.defaultSortDirection;}export function respondToSortChange(event) {console.log("sortable-table-sort-change", event.detail);- const tableId = event.detail.tableId;- this.sortableTable.sortColumns[tableId] = event.detail.sortColumn;- this.sortableTable.sortDirections[tableId] = event.detail.sortDirection;- 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(tableId);+ this.sortableTable.sortColumn = event.detail.sortColumn;+ this.sortableTable.sortDirection = event.detail.sortDirection;+ this.updateHistory(this.page, event.detail.sortColumn, event.detail.sortDirection);+ this.storeFilterAndSort(this.storageKey, event.detail.sortColumn, event.detail.sortDirection, this.filter);+ this.downloadObjects();}export function updateHistory(page, column, direction) {if (history.pushState) {let obj = {- page: this.sortableTable.pages,- column: this.sortableTable.sortColumns,- direction: this.sortableTable.sortDirections,+ page: page,+ column: column,+ direction: direction,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);let newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + "?" + string;- window.history.pushState({path: newUrl}, "", newUrl);+ window.history.pushState({ path: newUrl }, "", newUrl);}}diff --git a/resources/views/accounts/create.blade.php b/resources/views/accounts/create.blade.phpindex e8310418e2..d46dd41e4d 100644--- a/resources/views/accounts/create.blade.php+++ b/resources/views/accounts/create.blade.php@@ -59,7 +59,6 @@@endif{!! ExpandedForm::textarea('notes',null,['helpText' => trans('firefly.field_supports_markdown')]) !!}{!! ExpandedForm::file('attachments[]', ['multiple' => 'multiple','helpText' => trans('firefly.upload_max_file_size', ['size' => $uploadSize ?? $filesize])]) !!}- {!! ExpandedForm::objectGroup() !!}</div></div></div>diff --git a/resources/views/accounts/edit.blade.php b/resources/views/accounts/edit.blade.phpindex 723d88df18..0bf1019ba4 100644--- a/resources/views/accounts/edit.blade.php+++ b/resources/views/accounts/edit.blade.php@@ -68,7 +68,6 @@{!! ExpandedForm::textarea('notes', $preFilled['notes'],['helpText' => trans('firefly.field_supports_markdown')]) !!}{!! ExpandedForm::checkbox('active', 1) !!}{!! ExpandedForm::file('attachments[]', ['multiple' => 'multiple','helpText' => trans('firefly.upload_max_file_size', ['size' => $uploadSize ?? $filesize])]) !!}- {!! ExpandedForm::objectGroup() !!}</div></div>diff --git a/resources/views/accounts/index.blade.php b/resources/views/accounts/index.blade.phpindex e572aa355b..c4f09ae691 100644--- a/resources/views/accounts/index.blade.php+++ b/resources/views/accounts/index.blade.php@@ -10,126 +10,122 @@</div></div></template>- <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>++ <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="totalPages > 1">+ <x-elements.alpine.page-navigation/>+ </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>- <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">+ <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>@@ -141,8 +137,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>@@ -163,12 +159,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>@@ -180,8 +176,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>@@ -202,29 +198,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>@@ -236,8 +232,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>@@ -258,48 +254,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>- <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">+ </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"><span><template x-if="sum > 0"><span>@@ -314,12 +310,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>@@ -334,15 +330,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>@@ -357,39 +353,34 @@</span></template></span>- </template>- </td>- <template x-if="'liabilities' === objectType">- <td> </td>- </template>+ </template>+ </td>+ <template x-if="'liabilities' === objectType">+ <td> </td>+ </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')"/>+ <template x-if="'liabilities' !== objectType">+ <td> </td>+ </template>+ </tr>+ </tfoot>+ </template>+ </table>++ <template x-if="totalPages > 1">+ <x-elements.alpine.page-navigation/>+ </template></div>+ <x-elements.card-footer-with-menu+ :route="route('accounts.create', $objectType) . '?_from=' . urlencode($FF3_FROM)"+ :linkTitle="__('firefly.make_new_'. $objectType . '_account')"/></div>- </template>-- <template x-if="0 === groupedObjects.length && true === active && false === loadingPage && false === sortableTable.isFiltering">+ </div>+ <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>- <template x-if="0 === groupedObjects.length && true === active">+ <template x-if="0 === accounts.length && true === active"><p class="text-center"><small><em><a href="{{ route('accounts.inactive.index', $objectType) }}">@@ -400,7 +391,7 @@</small></p></template>- <template x-if="0 !== groupedObjects.length && true === active">+ <template x-if="0 !== accounts.length && true === active"><p class="text-center"><small><em><a href="{{ route('accounts.inactive.index', $objectType) }}">@@ -410,7 +401,7 @@</small></p></template>- <template x-if="0 !== groupedObjects.length && false === active">+ <template x-if="0 !== accounts.length && false === active"><p class="text-center"><small><em><a href="{{ route('accounts.index', $objectType) }}"><span@@ -419,7 +410,7 @@</small></p></template>- <template x-if="0 === groupedObjects.length && false === active">+ <template x-if="0 === accounts.length && false === active"><p class="text-center"><small><em><a href="{{ route('accounts.index', $objectType) }}"><spandiff --git a/resources/views/categories/index.blade.php b/resources/views/categories/index.blade.phpindex 302ac7bbf4..57d75c8b26 100644--- a/resources/views/categories/index.blade.php+++ b/resources/views/categories/index.blade.php@@ -16,8 +16,8 @@:route="route('categories.create') . '?_from=' . urlencode($FF3_FROM)":linkTitle="__('firefly.create_new_category')"/><div class="card-body p-0">- <template x-if="sortableTable.totalPages.main > 1">- <x-elements.alpine.page-navigation sort-identifier="main"/>+ <template x-if="totalPages > 1">+ <x-elements.alpine.page-navigation/></template><table data-sort-identifier="main" class="table table-valign-middle table-sm table-hover sortable"><thead>@@ -53,8 +53,8 @@</tbody></table>- <template x-if="sortableTable.totalPages.main > 1">- <x-elements.alpine.page-navigation sort-identifier="main"/>+ <template x-if="totalPages > 1">+ <x-elements.alpine.page-navigation/></template><x-elements.card-footer-with-menudiff --git a/resources/views/components/elements/alpine/page-navigation.blade.php b/resources/views/components/elements/alpine/page-navigation.blade.phpindex 6da5a3b464..dca716aba9 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[tableId] > 1" x-effect="sortableTable ? sortableTable.capturePageNavigation() : null">+<template x-if="totalPages > 1" x-effect="sortableTable ? sortableTable.capturePageNavigation() : null"><div class="m-2">- <nav :data-sort-identifier="tableId">+ <nav><ul class="pagination">- <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]">+ <li :class="{'page-item': true, 'disabled': 1 === page}" :aria-disabled="1 === page ? 'true' : 'false'" aria-label="{!! __('pagination.previous') !!}">+ <template x-if="1 === page"><span class="page-link" aria-hidden="true">‹</span></template>- <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 x-if="page > 1">+ <a class="page-link" :data-page="(page-1)" :href="pageNavUrl + '?page=' + (page - 1)" rel="prev" aria-label="{!! __('pagination.previous') !!}" title="{!! __('pagination.previous') !!}">‹</a></template></li>- <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 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" :data-page="current" :href="pageNavUrl+'?page=' + current" x-text="current" :aria-label="current"></a></template>- <template x-if="current === sortableTable.pages[tableId]">+ <template x-if="current === page"><span class="page-link" x-text="current"></span></template></li></template>- <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') !!}">+ <li class="{'page-item': true, 'disabled': totalPages === page" :aria-disabled="totalPages === page ? 'true' : 'false'" aria-label="{!! __('pagination.next') !!}">+ <template x-if="totalPages > page">+ <a class="page-link" :data-page="(page+1)" :href="pageNavUrl+'?page=' + (page +1)" rel="next" aria-label="{!! __('pagination.next') !!}" title="{!! __('pagination.next') !!}">›</a></template>- <template x-if="sortableTable.totalPages[tableId] === sortableTable.pages[tableId]">+ <template x-if="totalPages === page"><span class="page-link" aria-hidden="true">›</span></template></li>diff --git a/resources/views/components/layout/create-menu.blade.php b/resources/views/components/layout/create-menu.blade.phpindex b183c4019f..e0fc20356d 100644--- a/resources/views/components/layout/create-menu.blade.php+++ b/resources/views/components/layout/create-menu.blade.php@@ -98,7 +98,7 @@<div class="grow"><h3 class="dropdown-item-title"><!-- withdrawal, deposit, transfer -->- <em class="bi bi-piggy-bank me-2"></em>+ <em class="bi bi-bullseye me-2"></em>{{ __('firefly.create_new_piggy_bank') }}</h3></div>diff --git a/resources/views/components/layout/sidebar.blade.php b/resources/views/components/layout/sidebar.blade.phpindex 50fa07a347..29029df201 100644--- a/resources/views/components/layout/sidebar.blade.php+++ b/resources/views/components/layout/sidebar.blade.php@@ -53,7 +53,7 @@</li><li class="nav-item"><a href="{{ route('piggy-banks.index') }}" class="nav-link {{ menu_item_active_partial('piggy-banks.') }}">- <em class="nav-icon bi bi-piggy-bank"></em>+ <em class="nav-icon bi bi-bullseye"></em><p>{{ __('firefly.piggyBanks') }}</p>diff --git a/resources/views/form/options.blade.php b/resources/views/form/options.blade.phpindex 1f263bb819..7f7e79fc9f 100644--- a/resources/views/form/options.blade.php+++ b/resources/views/form/options.blade.php@@ -14,7 +14,7 @@<div class="row mb-2" id="{{ $name }}_holder"><div class="col-sm-9 offset-sm-3"><div class="form-check has-validation">- {{ Html::checkbox('return_to_edit')->class('form-check-input')->id($name . '_return_to_edit') }}+ {{ Html::checkbox('create_another')->class('form-check-input')->id($name . '_return_to_edit') }}<label class="form-check-label" for="{{ $name }}">{{ trans('form.returnHereUpdateExplanation') }}</label>diff --git a/resources/views/index.blade.php b/resources/views/index.blade.phpindex dc7a1a4ed0..7bdc1ef312 100644--- a/resources/views/index.blade.php+++ b/resources/views/index.blade.php@@ -204,7 +204,7 @@<div class="card-footer text-end d-print-none"><a href="{{ route('piggy-banks.index') }}" title="{{ __('firefly.go_to_piggies') }}"class="btn btn-primary btn-sm"><span- class="bi bi-piggy-bank"></span> {{ __('firefly.go_to_piggies') }}</a>+ class="bi bi-bullseye"></span> {{ __('firefly.go_to_piggies') }}</a></div></div></div>diff --git a/resources/views/object-groups/index.blade.php b/resources/views/object-groups/index.blade.phpindex 6efd4f01a4..a0048cf4da 100644--- a/resources/views/object-groups/index.blade.php+++ b/resources/views/object-groups/index.blade.php@@ -13,11 +13,11 @@<table class="table table-valign-middle table-sm" id="sortable"><thead><tr>- <th class="w-10"> </th>- <th class="w-80">+ <th> </th>+ <th>{{ __('firefly.object_group_title') }}</th>- <th class="w-10">+ <th> </th></tr>@@ -27,31 +27,13 @@<tr class="group-sortable" data-id="{{ $objectGroup['id'] }}" data-name="{{ e($objectGroup['title']) }}" data-order="{{ $objectGroup['order'] }}"><td><span class="btn btn-sm btn-outline-secondary bi bi-list group-handle"></span></td><td>-<strong>{{ $objectGroup['title'] }}</strong><br/>- <div class="row">@foreach($objectGroup['piggyBanks'] as $piggyBank)- <div class="col-3 big-line">- <a style="font-size:0.9em;" class="badge text-bg-success text-truncate d-inline-block" title="{{ $piggyBank->title }}" href="{{ route('piggy-banks.show',[$piggyBank->id]) }}">- <span class="bi bi-piggy-bank"></span> {{ $piggyBank->name }}</a></div>- {{-- {{ __('firefly.piggy_bank') }}: <a href="{{ route('piggy-banks.show', [$piggyBank['id']]) }}">{{ $piggyBank['name'] }}</a><br> --}}+ - {{ __('firefly.piggy_bank') }}: <a href="{{ route('piggy-banks.show', [$piggyBank['id']]) }}">{{ $piggyBank['name'] }}</a><br>@endforeach-@foreach($objectGroup['bills'] as $subscription)- <div class="col-3 big-line">- <a style="font-size:0.9em;" class="badge text-bg-primary text-truncate d-inline-block" title="{{ $subscription->title }}" href="{{ route('subscriptions.show',[$subscription->id]) }}">- <span class="bi bi-calendar"></span> {{ $subscription->name }}</a></div>-- {{-- - {{ __('firefly.bill') }}: <a href="{{ route('subscriptions.show', [$subscription['id']]) }}">{{ $subscription['name'] }}</a><br> --}}+ - {{ __('firefly.bill') }}: <a href="{{ route('subscriptions.show', [$subscription['id']]) }}">{{ $subscription['name'] }}</a><br>@endforeach- @foreach($objectGroup['accounts'] as $account)- <div class="col-3 big-line">- <a style="font-size:0.9em;" class="badge text-bg-teal text-truncate d-inline-block" title="{{ $account->title }}" href="{{ route('accounts.show',[$account->id]) }}">- <span class="bi bi-cash"></span> {{ $account->name }}</a></div>-- {{-- - {{ __('firefly.account') }}: <a href="{{ route('accounts.show', [$account['id']]) }}">{{ $account['name'] }}</a><br> --}}- @endforeach- </div></td><td class="text-end"><div class="dropdown">diff --git a/resources/views/profile/index.blade.php b/resources/views/profile/index.blade.phpindex 52259c9b99..9cb414c96d 100644--- a/resources/views/profile/index.blade.php+++ b/resources/views/profile/index.blade.php@@ -136,7 +136,7 @@<button type="button"data-success="{{ trans('firefly.deleted_all_piggy_banks') }}"data-type="piggy_banks" class="confirm btn btn-danger btn-sm"><span- class="bi bi-piggy-bank"></span> {{ __('firefly.delete_all_piggy_banks') }}</button>+ class="bi bi-bullseye"></span> {{ __('firefly.delete_all_piggy_banks') }}</button></div><h4>{{ __('firefly.automation') }}</h4><div class="btn-group">