From 5c1a424f564a0f0e8727b6bb6616dc8d3db9ecfc Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 21 Aug 2026 06:00:50 +0200 Subject: [PATCH] Slowly replace show form, so it can contain location as well. --- config/translations.php | 1 + .../assets/v3/js/pages/transactions/show.js | 82 +++++++++++++++++++ resources/assets/v3/vite.config.js | 1 + resources/lang/en_US/firefly.php | 1 + resources/views/transactions/show.blade.php | 29 +++++-- 5 files changed, 106 insertions(+), 8 deletions(-) create mode 100644 resources/assets/v3/js/pages/transactions/show.js diff --git a/config/translations.php b/config/translations.php index bfa99e34c7..55e4799223 100644 --- a/config/translations.php +++ b/config/translations.php @@ -64,6 +64,7 @@ return [ 'you_create_transfer', 'you_create_withdrawal', 'you_create_deposit', + 'wait_loading_page', 'inactive', 'liability_direction_debit_short', 'liability_direction_credit_short', diff --git a/resources/assets/v3/js/pages/transactions/show.js b/resources/assets/v3/js/pages/transactions/show.js new file mode 100644 index 0000000000..244b4de0b6 --- /dev/null +++ b/resources/assets/v3/js/pages/transactions/show.js @@ -0,0 +1,82 @@ +/* + * dashboard.js + * Copyright (c) 2026 james@firefly-iii.org + * + * 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 . + */ + +import '../../boot/bootstrap.js'; +import sidebar from '../../pages/shared/sidebar.js'; +import dates from '../shared/dates.js'; +import i18next from "i18next"; +import Get from '../../api/model/transaction/get.js'; + +let show = function () { + return { + i18next: null, + group: { + id: 0, + group_title: '', + transactions: [], + + }, + loading: true, + id: 0, + init() { + this.i18next = i18next; + const page = window.location.href.split('/'); + this.group.id = parseInt(page[page.length - 1]); + this.downloadTransactionGroup(); + // console.log('Generic JS for page with few features.'); + }, + downloadTransactionGroup() { + (new Get()).show(this.group.id).then((response) => { + const info = response.data.data; + this.group.transactions = info.attributes.transactions; + this.loading = false; + }); + } + } + +}; + + +const comps = { + show, + sidebar, + dates +}; + +function loadPage(comps) { + // console.log('loadPage'); + Object.keys(comps).forEach(comp => { + let data = comps[comp](); + Alpine.data(comp, () => data); + // console.log(comp); + }); + Alpine.start(); +} + +// wait for load until bootstrapped event is received. +document.addEventListener('firefly-iii-bootstrapped', () => { + // console.log('Loaded through event listener.'); + loadPage(comps); +}); +// or is bootstrapped before event is triggered. +if (window.bootstrapped) { + // console.log('Loaded through window variable.'); + loadPage(comps); +} diff --git a/resources/assets/v3/vite.config.js b/resources/assets/v3/vite.config.js index 4692e982aa..c5a9100cd6 100644 --- a/resources/assets/v3/vite.config.js +++ b/resources/assets/v3/vite.config.js @@ -82,6 +82,7 @@ export default defineConfig(({command, mode, isSsrBuild, isPreview}) => { // transactions 'js/pages/transactions/create.js', 'js/pages/transactions/edit.js', + 'js/pages/transactions/show.js', // tags diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index fa47cf1f95..a56af2693c 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -2122,6 +2122,7 @@ return [ // transactions: 'wait_loading_transaction' => 'Please wait for the form to load', + 'wait_loading_page' => 'Please wait a moment for the page to load', 'wait_loading_data' => 'Please wait for your information to load...', 'wait_attachments' => 'Please wait for the attachments to upload.', 'errors_upload' => 'The upload has failed. Please check your browser console for the error.', diff --git a/resources/views/transactions/show.blade.php b/resources/views/transactions/show.blade.php index 733a4c7aeb..2006b17f9e 100644 --- a/resources/views/transactions/show.blade.php +++ b/resources/views/transactions/show.blade.php @@ -1,5 +1,15 @@ @extends('layout.v3.session') @section('content') +
+
@@ -60,20 +70,21 @@ {{ trans('list.id') }} - #{{ $transactionGroup->id }} + # {{ trans('list.type') }} - {{ __($first['transaction_type_type']) }} + d> {{ trans('list.description') }} - @if(1 === $splits) - {{ $first['description'] }} - @else - {{ $transactionGroup->title }} - @endif + + @@ -539,9 +550,11 @@ {{-- modal for linking journals. Will be filled by AJAX --}} +
+ @endsection @section('scripts') - @vite(['js/pages/generic.js']) + @vite(['js/pages/transactions/show.js'])