Split form in parts, add "edit" page.

This commit is contained in:
James Cole 2024-01-03 19:34:50 +01:00
parent 211526c032
commit 7426c6aac3
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
29 changed files with 2293 additions and 2144 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
/node_modules
/storage/*.key
/vendor
public/hot
npm-debug.log
yarn-error.log
.env

View File

@ -51,7 +51,7 @@ class EditController extends Controller
// translations:
$this->middleware(
function ($request, $next) {
app('view')->share('title', (string)trans('firefly.transactions'));
app('view')->share('title', (string) trans('firefly.transactions'));
app('view')->share('mainTitleIcon', 'fa-exchange');
$this->repository = app(JournalRepositoryInterface::class);
@ -78,7 +78,9 @@ class EditController extends Controller
$accountToTypes = config('firefly.account_to_transaction');
$expectedSourceTypes = config('firefly.expected_source_types');
$allowedSourceDests = config('firefly.source_dests');
$title = $transactionGroup->transactionJournals()->count() > 1 ? $transactionGroup->title : $transactionGroup->transactionJournals()->first()->description;
$subTitle = (string) trans('firefly.edit_transaction_title', ['description' => $title]);
$subTitleIcon = 'fa-plus';
$defaultCurrency = app('amount')->getDefaultCurrency();
$cash = $repository->getCashAccount();
$previousUrl = $this->rememberPreviousUrl('transactions.edit.url');
@ -92,6 +94,8 @@ class EditController extends Controller
'cash',
'allowedSourceDests',
'expectedSourceTypes',
'subTitle',
'subTitleIcon',
'transactionGroup',
'allowedOpposingTypes',
'accountToTypes',

View File

@ -44,6 +44,7 @@ import 'leaflet/dist/leaflet.css';
// TODO fix two maps, perhaps disconnect from entries entirely.
// TODO group title
// TODO map location from preferences
// TODO field preferences
let i18n;
@ -204,7 +205,7 @@ let transactions = function () {
showWaitMessage: false,
// four buttons
returnHereButton: true,
returnHereButton: false,
resetButton: false,
resetButtonEnabled: false,
rulesButton: true,
@ -850,28 +851,29 @@ let transactions = function () {
}
});
const count = this.entries.length - 1;
//let map = L.map('location_map_' + count).setView([this.latitude, this.longitude], this.zoomLevel);
let map = L.map('location_map_' + count).setView([this.latitude, this.longitude], this.zoomLevel);
// L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
// maxZoom: 19,
// attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap '+count+'</a>'
// }).addTo(map);
// map.on('click', this.addPointToMap);
// map.on('zoomend', this.saveZoomOfMap);
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap '+count+'</a>'
}).addTo(map);
map.on('click', this.addPointToMap);
map.on('zoomend', this.saveZoomOfMap);
this.entries[count].map
const id = 'location_map_' + count;
const map = () => {
const el = document.getElementById(id),
map = L.map(id).setView([this.latitude, this.longitude], this.zoomLevel)
L.tileLayer(
'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
{attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap '+count+'</a>'}
).addTo(map)
map.on('click', this.addPointToMap);
map.on('zoomend', this.saveZoomOfMap);
return map
}
this.entries[count].map = map();
// const id = 'location_map_' + count;
// const map = () => {
// const el = document.getElementById(id),
// map = L.map(id).setView([this.latitude, this.longitude], this.zoomLevel)
// L.tileLayer(
// 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
// {attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap '+count+'</a>'}
// ).addTo(map)
// map.on('click', this.addPointToMap);
// map.on('zoomend', this.saveZoomOfMap);
// return map
// }
// this.entries[count].map = map();
}, 250);

View File

@ -0,0 +1,75 @@
/*
* edit.js
* Copyright (c) 2024 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 <https://www.gnu.org/licenses/>.
*/
import '../../boot/bootstrap.js';
import dates from '../../pages/shared/dates.js';
import {getVariable} from "../../store/get-variable.js";
import {I18n} from "i18n-js";
import {loadTranslations} from "../../support/load-translations.js";
// TODO upload attachments to other file
// TODO fix two maps, perhaps disconnect from entries entirely.
// TODO group title
// TODO map location from preferences
// TODO field preferences
let i18n;
let transactions = function () {
return {
entries: [],
init() {
Promise.all([getVariable('language', 'en_US')]).then((values) => {
i18n = new I18n();
const locale = values[0].replace('-', '_');
i18n.locale = locale;
loadTranslations(i18n, locale).then(() => {
//this.addSplit();
});
});
},
}
}
let comps = {transactions, dates};
function loadPage() {
Object.keys(comps).forEach(comp => {
console.log(`Loading page component "${comp}"`);
let data = comps[comp]();
Alpine.data(comp, () => data);
});
Alpine.start();
}
// wait for load until bootstrapped event is received.
document.addEventListener('firefly-iii-bootstrapped', () => {
console.log('Loaded through event listener.');
loadPage();
});
// or is bootstrapped before event is triggered.
if (window.bootstrapped) {
console.log('Loaded through window variable.');
loadPage();
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
<div class="row mb-2">
<div class="col">
<template x-if="showSuccessMessage">
<div class="alert alert-success alert-dismissible fade show" role="alert">
<a :href="successMessageLink" class="alert-link" x-text="successMessageText"></a>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
</template>
<template x-if="showErrorMessage">
<div class="alert alert-danger alert-dismissible fade show" role="alert"
x-text="errorMessageText">
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
</template>
<template x-if="showWaitMessage">
<div class="alert alert-info alert-dismissible fade show" role="alert">
<em class="fa-solid fa-spinner fa-spin"></em> Please wait for the attachments to upload.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
</template>
</div>
</div>

View File

@ -0,0 +1,127 @@
<div :class="{'tab-pane fade pt-2':true, 'show active': index ===0}" :id="'split-'+index+'-pane'" role="tabpanel" :aria-labelledby="'split-'+index+'-tab'" tabindex="0" x-init="addedSplit()">
<div class="row mb-2">
<div class="col-xl-6 col-lg-6 col-md-12 col-xs-12 mb-2">
<!-- BASIC TRANSACTION INFORMATION -->
<div class="card">
<div class="card-header">
<h3 class="card-title"
>{{ __('firefly.basic_journal_information') }}</h3>
</div>
<div class="card-body">
<!-- DESCRIPTION -->
@include('partials.form.transaction.description')
<!-- SOURCE ACCOUNT -->
@include('partials.form.transaction.source-account')
<!-- DESTINATION ACCOUNT -->
@include('partials.form.transaction.destination-account')
<!-- DATE AND TIME -->
@include('partials.form.transaction.date-time')
</div>
</div>
</div>
<div class="col-xl-6 col-lg-6 col-md-12 col-xs-12 mb-2">
<!-- AMOUNTS -->
<div class="card">
<div class="card-header">
<h3 class="card-title">
{{ __('firefly.transaction_journal_amount') }}
</h3>
</div>
<div class="card-body">
<!-- AMOUNT -->
@include('partials.form.transaction.amount')
<!-- FOREIGN AMOUNT -->
@include('partials.form.transaction.foreign-amount')
</div>
</div>
</div>
<!-- META DATA -->
<div class="col-xl-4 col-lg-6 col-md-12 col-xs-12 mb-2">
<div class="card">
<div class="card-header">
<h3 class="card-title">
{{ __('firefly.transaction_journal_meta') }}
</h3>
</div>
<div class="card-body">
<!-- BUDGET -->
@include('partials.form.transaction.budget')
<!-- CATEGORY -->
@include('partials.form.transaction.category')
<!-- PIGGY BANK -->
@include('partials.form.transaction.piggy-bank')
<!-- SUBSCRIPTION -->
@include('partials.form.transaction.subscription')
<!-- TAGS -->
@include('partials.form.transaction.tags')
<!-- NOTES -->
@include('partials.form.transaction.notes')
</div>
</div>
</div>
<!-- EXTRA THINGS -->
<div class="col-xl-4 col-lg-6 col-md-12 col-xs-12 mb-2">
<div class="card">
<div class="card-header">
<h3 class="card-title">
{{ __('firefly.transaction_journal_extra') }}
</h3>
</div>
<div class="card-body">
<!-- ATTACHMENTS -->
@include('partials.form.transaction.attachments')
<!-- INTERNAL REFERENCE -->
@include('partials.form.transaction.internal-reference')
<!-- EXTERNAL URL -->
@include('partials.form.transaction.external-url')
<!-- LOCATION -->
@include('partials.form.transaction.location')
<!-- DATE FIELDS -->
@include('partials.form.transaction.date-fields')
</div>
</div>
</div>
<div class="col-xl-4 col-lg-6 col-md-12 col-xs-12 mb-2">
<div class="card">
<div class="card-header">
<h3 class="card-title">
{{ __('firefly.submission_options') }}
</h3>
</div>
<div class="card-body">
@include('partials.form.transaction.submission-options')
</div>
<div class="card-footer">
<div class="row">
<div class="col text-end">
<button class="btn btn-success" :disabled="submitting" @click="submitTransaction()">Submit</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-12">
<template x-if="0 !== index">
<button :disabled="submitting" class="btn btn-danger" @click="removeSplit(index)">
Remove this split
</button>
</template>
<button class="btn btn-info" :disabled="submitting">Add another split</button>
</div>
</div>
</div>

View File

@ -0,0 +1,32 @@
<div class="row">
<div class="col">
<ul class="nav nav-tabs" id="splitTabs" role="tablist">
<template x-for="transaction,index in entries">
<li class="nav-item" role="presentation">
<button :id="'split-'+index+'-tab'"
:class="{'nav-link': true, 'active': index === 0 }"
data-bs-toggle="tab"
:data-bs-target="'#split-'+index+'-pane'"
type="button" role="tab"
:aria-controls="'split-'+index+'-pane'"
aria-selected="true">{{ __('firefly.single_split') }} #
<span x-text="index+1"></span>
</button>
</li>
</template>
<li class="nav-item" role="presentation">
<button class="nav-link" type="button" role="tab" @click="addSplit()"
><em class="fa-solid fa-plus-circle"></em>
</button>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">
{{ __('firefly.total') }}:
<span x-text="formattedTotalAmount()"></span>
</a>
</li>
</ul>
</div>
</div>

View File

@ -0,0 +1,32 @@
<div class="row mb-3">
<div class="col-sm-3">
<template x-if="loadingCurrencies">
<span class="form-control-plaintext"><em
class="fa-solid fa-spinner fa-spin"></em></span>
</template>
<template x-if="!loadingCurrencies">
<select class="form-control" :id="'currency_code_' + index"
x-model="transaction.currency_code"
>
<template x-for="currency in nativeCurrencies">
<option :selected="currency.id == defaultCurrency.id"
:label="currency.name" :value="currency.code"
x-text="currency.name"></option>
</template>
</select>
</template>
</div>
<div class="col-sm-9">
<input type="number" step="any" min="0"
:id="'amount_' + index"
:data-index="index"
:class="{'is-invalid': transaction.errors.amount.length > 0, 'input-mask' : true, 'form-control': true}"
x-model="transaction.amount" data-inputmask="currency"
@change="changedAmount"
placeholder="0.00">
<template x-if="transaction.errors.amount.length > 0">
<div class="invalid-feedback"
x-text="transaction.errors.amount[0]"></div>
</template>
</div>
</div>

View File

@ -0,0 +1,14 @@
<div class="row mb-3">
<label :for="'attachments_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-file-import"></i>
</label>
<div class="col-sm-10">
<input type="file" multiple
class="form-control attachments"
:id="'attachments_' + index"
:data-index="index"
name="attachments[]"
placeholder="{{ __('firefly.category') }}">
</div>
</div>

View File

@ -0,0 +1,25 @@
<template x-if="transactionType != 'deposit' && transactionType != 'transfer'">
<div class="row mb-3">
<label :for="'budget_id_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-chart-pie"></i>
</label>
<div class="col-sm-10">
<template x-if="loadingBudgets">
<span class="form-control-plaintext"><em
class="fa-solid fa-spinner fa-spin"></em></span>
</template>
<template x-if="!loadingBudgets">
<select class="form-control"
:id="'budget_id_' + index"
x-model="transaction.budget_id"
>
<template x-for="budget in budgets">
<option :label="budget.name" :value="budget.id"
x-text="budget.name"></option>
</template>
</select>
</template>
</div>
</div>
</template>

View File

@ -0,0 +1,14 @@
<div class="row mb-3">
<label :for="'category_name_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-bookmark"></i>
</label>
<div class="col-sm-10">
<input type="search"
class="form-control ac-category"
:id="'category_name_' + index"
x-model="transaction.category_name"
:data-index="index"
placeholder="{{ __('firefly.category') }}">
</div>
</div>

View File

@ -0,0 +1,16 @@
<template x-for="dateField in dateFields">
<div class="row mb-1">
<label :for="dateField + '_date_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-calendar-alt" :title="dateField"></i>
</label>
<div class="col-sm-10">
<input type="date"
class="form-control"
:id="dateField + '_date_' + index"
x-model="transaction[dateField]"
:data-index="index"
placeholder="">
</div>
</div>
</template>

View File

@ -0,0 +1,11 @@
<div class="row mb-3">
<label for="date_0" class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-calendar"></i>
</label>
<div class="col-sm-10">
<input type="datetime-local" class="form-control" :id="'date_' + index"
@change="detectTransactionType"
x-model="transaction.date"
>
</div>
</div>

View File

@ -0,0 +1,13 @@
<div class="row mb-3">
<label :for="'description_' + index" class="col-sm-1 col-form-label d-none d-sm-block">
<em title="TODO explain me" class="fa-solid fa-font"></em>
</label>
<div class="col-sm-10">
<input type="text" class="form-control ac-description"
:id="'description_' + index"
@change="detectTransactionType"
x-model="transaction.description"
:data-index="index"
placeholder="{{ __('firefly.description') }}">
</div>
</div>

View File

@ -0,0 +1,14 @@
<div class="row mb-3">
<label :for="'dest_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-arrow-left"></i>
</label>
<div class="col-sm-10">
<input type="text"
class="form-control ac-dest"
:id="'dest_' + index"
x-model="transaction.destination_account.alpine_name"
:data-index="index"
placeholder="{{ __('firefly.destination_account') }}">
</div>
</div>

View File

@ -0,0 +1,21 @@
<div class="row mb-3">
<label :for="'external_url_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-link"></i>
</label>
<div class="col-sm-10">
<input type="text"
class="form-control"
:id="'external_url_' + index"
x-model="transaction.external_url"
:data-index="index"
:class="{'is-invalid': transaction.errors.external_url.length > 0, 'form-control': true}"
placeholder="{{ __('firefly.external_url') }}" />
<template x-if="transaction.errors.external_url.length > 0">
<div class="invalid-feedback"
x-text="transaction.errors.external_url[0]">
</div>
</template>
</div>
</div>

View File

@ -0,0 +1,45 @@
<template x-if="foreignAmountEnabled">
<div class="row mb-3">
<div class="col-sm-3">
<label class="form-label">&nbsp;</label>
<template x-if="loadingCurrencies">
<span class="form-control-plaintext"><em
class="fa-solid fa-spinner fa-spin"></em></span>
</template>
<template x-if="!loadingCurrencies">
<select class="form-control"
:id="'foreign_currency_code_' + index"
x-model="transaction.foreign_currency_code"
>
<template x-for="currency in foreignCurrencies">
<option :label="currency.name" :value="currency.code"
x-text="currency.name"></option>
</template>
</select>
</template>
</div>
<div class="col-sm-9">
<template x-if="transactionType != 'transfer'">
<label class="small form-label">Amount in foreign amount, if
any</label>
</template>
<template x-if="transactionType == 'transfer'">
<label class="small form-label">Amount in currency of
destination
account</label>
</template>
<input type="number" step="any" min="0"
:id="'amount_' + index"
:data-index="index"
:class="{'is-invalid': transaction.errors.foreign_amount.length > 0, 'input-mask' : true, 'form-control': true}"
x-model="transaction.foreign_amount"
data-inputmask="currency"
@change="changedAmount"
placeholder="0.00">
<template x-if="transaction.errors.foreign_amount.length > 0">
<div class="invalid-feedback"
x-text="transaction.errors.foreign_amount[0]"></div>
</template>
</div>
</div>
</template>

View File

@ -0,0 +1,14 @@
<div class="row mb-3">
<label :for="'internal_reference_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-anchor"></i>
</label>
<div class="col-sm-10">
<input type="search"
class="form-control"
:id="'internal_reference_' + index"
x-model="transaction.internal_reference"
:data-index="index"
placeholder="{{ __('firefly.internal_reference') }}">
</div>
</div>

View File

@ -0,0 +1,18 @@
<div class="row mb-3">
<label :for="'map_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-earth-europe"></i>
</label>
<div class="col-sm-10">
<div :id="'location_map_' + index" style="height:300px;" :data-index="index"></div>
<span class="muted small">
<template x-if="!transaction.hasLocation">
<span>Tap the map to add a location</span>
</template>
<template x-if="transaction.hasLocation">
<a :data-index="index" href="#" @click="clearLocation">Clear point</a>
</template>
</span>
</div>
</div>

View File

@ -0,0 +1,11 @@
<div class="row mb-3">
<label :for="'notes_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-font"></i>
</label>
<div class="col-sm-10">
<textarea class="form-control" :id="'notes_' + index"
x-model="transaction.notes"
placeholder="{{ __('firefly.notes') }}"></textarea>
</div>
</div>

View File

@ -0,0 +1,30 @@
<template
x-if="transactionType != 'deposit' && transactionType != 'withdrawal'">
<div class="row mb-3">
<label :for="'piggy_bank_id_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-piggy-bank"></i>
</label>
<div class="col-sm-10">
<template x-if="loadingPiggyBanks">
<span class="form-control-plaintext"><em
class="fa-solid fa-spinner fa-spin"></em></span>
</template>
<template x-if="!loadingPiggyBanks">
<select class="form-control"
:id="'piggy_bank_id_' + index"
x-model="transaction.piggy_bank_id">
<template x-for="group in piggyBanks">
<optgroup :label="group.name">
<template x-for="piggyBank in group.piggyBanks">
<option :label="piggyBank.name"
:value="piggyBank.id"
x-text="piggyBank.name"></option>
</template>
</optgroup>
</template>
</select>
</template>
</div>
</div>
</template>

View File

@ -0,0 +1,14 @@
<div class="row mb-3">
<label :for="'source_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-arrow-right"></i>
</label>
<div class="col-sm-10">
<input type="text"
class="form-control ac-source"
:id="'source_' + index"
x-model="transaction.source_account.alpine_name"
:data-index="index"
placeholder="{{ __('firefly.source_account') }}">
</div>
</div>

View File

@ -0,0 +1,31 @@
<div class="form-check">
<input class="form-check-input" x-model="returnHereButton" type="checkbox"
id="returnButton">
<label class="form-check-label" for="returnButton">
Return here to create a new transaction
</label>
</div>
<div class="form-check">
<input class="form-check-input" x-model="resetButton" type="checkbox"
id="resetButton" :disabled="!returnHereButton">
<label class="form-check-label" for="resetButton">
Reset the form after returning
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="rulesButton"
:checked="rulesButton">
<label class="form-check-label" for="rulesButton">
Run rules on this transaction
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="webhookButton"
:checked="webhookButton">
<label class="form-check-label" for="webhookButton">
Run webhooks on this transaction
</label>
</div>

View File

@ -0,0 +1,30 @@
<template x-if="transactionType != 'transfer' && transactionType != 'deposit'">
<div class="row mb-3">
<label :for="'bill_id_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-calendar"></i>
</label>
<div class="col-sm-10">
<template x-if="loadingSubscriptions">
<span class="form-control-plaintext"><em
class="fa-solid fa-spinner fa-spin"></em></span>
</template>
<template x-if="!loadingSubscriptions">
<select class="form-control"
:id="'bill_id_' + index"
x-model="transaction.bill_id">
<template x-for="group in subscriptions">
<optgroup :label="group.name">
<template
x-for="subscription in group.subscriptions">
<option :label="subscription.name"
:value="subscription.id"
x-text="subscription.name"></option>
</template>
</optgroup>
</template>
</select>
</template>
</div>
</div>
</template>

View File

@ -0,0 +1,16 @@
<div class="row mb-3">
<label :for="'tags_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-tag"></i>
</label>
<div class="col-sm-10">
<select
class="form-select ac-tags"
:id="'tags_' + index"
x-model="transaction.tags"
:name="'tags['+index+'][]'"
multiple>
<option value="">Type a tag...</option>
</select>
</div>
</div>

View File

@ -6,518 +6,11 @@
<div class="app-content">
<!--begin::Container-->
<div class="container-fluid" x-data="transactions" id="form">
<div class="row mb-2">
<div class="col">
<template x-if="showSuccessMessage">
<div class="alert alert-success alert-dismissible fade show" role="alert">
<a :href="successMessageLink" class="alert-link" x-text="successMessageText"></a>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
</template>
<template x-if="showErrorMessage">
<div class="alert alert-danger alert-dismissible fade show" role="alert"
x-text="errorMessageText">
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
</template>
<template x-if="showWaitMessage">
<div class="alert alert-info alert-dismissible fade show" role="alert">
<em class="fa-solid fa-spinner fa-spin"></em> Please wait for the attachments to upload.
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
</template>
</div>
</div>
<div class="row">
<div class="col">
<ul class="nav nav-tabs" id="splitTabs" role="tablist">
<template x-for="transaction,index in entries">
<li class="nav-item" role="presentation">
<button :id="'split-'+index+'-tab'"
:class="{'nav-link': true, 'active': index === 0 }"
data-bs-toggle="tab"
:data-bs-target="'#split-'+index+'-pane'"
type="button" role="tab"
:aria-controls="'split-'+index+'-pane'"
aria-selected="true">{{ __('firefly.single_split') }} #
<span x-text="index+1"></span>
</button>
</li>
</template>
<li class="nav-item" role="presentation">
<button class="nav-link" type="button" role="tab" @click="addSplit()"
><em class="fa-solid fa-plus-circle"></em>
</button>
</li>
<li class="nav-item">
<a class="nav-link disabled" aria-disabled="true">
{{ __('firefly.total') }}:
<span x-text="formattedTotalAmount()"></span>
</a>
</li>
</ul>
</div>
</div>
<x-messages></x-messages>
<x-transaction-tab-list></x-transaction-tab-list>
<div class="tab-content" id="splitTabsContent">
<template x-for="transaction,index in entries">
<div
:class="{'tab-pane fade pt-2':true, 'show active': index ===0}"
:id="'split-'+index+'-pane'"
role="tabpanel"
:aria-labelledby="'split-'+index+'-tab'"
tabindex="0"
x-init="addedSplit()"
>
<div class="row mb-2">
<div class="col-xl-6 col-lg-6 col-md-12 col-xs-12 mb-2">
<div class="card">
<div class="card-header">
<h3 class="card-title"
>{{ __('firefly.basic_journal_information') }}</h3>
</div>
<div class="card-body">
<div class="row mb-3">
<label :for="'description_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<em
title="TODO explain me"
class="fa-solid fa-font"></em>
</label>
<div class="col-sm-10">
<input type="text" class="form-control ac-description"
:id="'description_' + index"
@change="detectTransactionType"
x-model="transaction.description"
:data-index="index"
placeholder="{{ __('firefly.description') }}">
</div>
</div>
<div class="row mb-3">
<label :for="'source_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-arrow-right"></i>
</label>
<div class="col-sm-10">
<input type="text"
class="form-control ac-source"
:id="'source_' + index"
x-model="transaction.source_account.alpine_name"
:data-index="index"
placeholder="{{ __('firefly.source_account') }}">
</div>
</div>
<div class="row mb-3">
<label :for="'dest_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-arrow-left"></i>
</label>
<div class="col-sm-10">
<input type="text"
class="form-control ac-dest"
:id="'dest_' + index"
x-model="transaction.destination_account.alpine_name"
:data-index="index"
placeholder="{{ __('firefly.destination_account') }}">
</div>
</div>
<div class="row mb-3">
<label for="date_0" class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-calendar"></i>
</label>
<div class="col-sm-10">
<input type="datetime-local" class="form-control" :id="'date_' + index"
@change="detectTransactionType"
x-model="transaction.date"
>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-6 col-lg-6 col-md-12 col-xs-12 mb-2">
<div class="card">
<div class="card-header">
<h3 class="card-title">
{{ __('firefly.transaction_journal_amount') }}
</h3>
</div>
<div class="card-body">
<div class="row mb-3">
<div class="col-sm-3">
<template x-if="loadingCurrencies">
<span class="form-control-plaintext"><em
class="fa-solid fa-spinner fa-spin"></em></span>
</template>
<template x-if="!loadingCurrencies">
<select class="form-control" :id="'currency_code_' + index"
x-model="transaction.currency_code"
>
<template x-for="currency in nativeCurrencies">
<option :selected="currency.id == defaultCurrency.id"
:label="currency.name" :value="currency.code"
x-text="currency.name"></option>
</template>
</select>
</template>
</div>
<div class="col-sm-9">
<input type="number" step="any" min="0"
:id="'amount_' + index"
:data-index="index"
:class="{'is-invalid': transaction.errors.amount.length > 0, 'input-mask' : true, 'form-control': true}"
x-model="transaction.amount" data-inputmask="currency"
@change="changedAmount"
placeholder="0.00">
<template x-if="transaction.errors.amount.length > 0">
<div class="invalid-feedback"
x-text="transaction.errors.amount[0]"></div>
</template>
</div>
</div>
<template x-if="foreignAmountEnabled">
<div class="row mb-3">
<div class="col-sm-3">
<label class="form-label">&nbsp;</label>
<template x-if="loadingCurrencies">
<span class="form-control-plaintext"><em
class="fa-solid fa-spinner fa-spin"></em></span>
</template>
<template x-if="!loadingCurrencies">
<select class="form-control"
:id="'foreign_currency_code_' + index"
x-model="transaction.foreign_currency_code"
>
<template x-for="currency in foreignCurrencies">
<option :label="currency.name" :value="currency.code"
x-text="currency.name"></option>
</template>
</select>
</template>
</div>
<div class="col-sm-9">
<template x-if="transactionType != 'transfer'">
<label class="small form-label">Amount in foreign amount, if
any</label>
</template>
<template x-if="transactionType == 'transfer'">
<label class="small form-label">Amount in currency of
destination
account</label>
</template>
<input type="number" step="any" min="0"
:id="'amount_' + index"
:data-index="index"
:class="{'is-invalid': transaction.errors.foreign_amount.length > 0, 'input-mask' : true, 'form-control': true}"
x-model="transaction.foreign_amount"
data-inputmask="currency"
@change="changedAmount"
placeholder="0.00">
<template x-if="transaction.errors.foreign_amount.length > 0">
<div class="invalid-feedback"
x-text="transaction.errors.foreign_amount[0]"></div>
</template>
</div>
</div>
</template>
</div>
</div>
</div>
<div class="col-xl-4 col-lg-6 col-md-12 col-xs-12 mb-2">
<div class="card">
<div class="card-header">
<h3 class="card-title">
{{ __('firefly.transaction_journal_meta') }}
</h3>
</div>
<div class="card-body">
<template x-if="transactionType != 'deposit' && transactionType != 'transfer'">
<div class="row mb-3">
<label :for="'budget_id_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-chart-pie"></i>
</label>
<div class="col-sm-10">
<template x-if="loadingBudgets">
<span class="form-control-plaintext"><em
class="fa-solid fa-spinner fa-spin"></em></span>
</template>
<template x-if="!loadingBudgets">
<select class="form-control"
:id="'budget_id_' + index"
x-model="transaction.budget_id"
>
<template x-for="budget in budgets">
<option :label="budget.name" :value="budget.id"
x-text="budget.name"></option>
</template>
</select>
</template>
</div>
</div>
</template>
<div class="row mb-3">
<label :for="'category_name_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-bookmark"></i>
</label>
<div class="col-sm-10">
<input type="search"
class="form-control ac-category"
:id="'category_name_' + index"
x-model="transaction.category_name"
:data-index="index"
placeholder="{{ __('firefly.category') }}">
</div>
</div>
<template
x-if="transactionType != 'deposit' && transactionType != 'withdrawal'">
<div class="row mb-3">
<label :for="'piggy_bank_id_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-piggy-bank"></i>
</label>
<div class="col-sm-10">
<template x-if="loadingPiggyBanks">
<span class="form-control-plaintext"><em
class="fa-solid fa-spinner fa-spin"></em></span>
</template>
<template x-if="!loadingPiggyBanks">
<select class="form-control"
:id="'piggy_bank_id_' + index"
x-model="transaction.piggy_bank_id">
<template x-for="group in piggyBanks">
<optgroup :label="group.name">
<template x-for="piggyBank in group.piggyBanks">
<option :label="piggyBank.name"
:value="piggyBank.id"
x-text="piggyBank.name"></option>
</template>
</optgroup>
</template>
</select>
</template>
</div>
</div>
</template>
<template x-if="transactionType != 'transfer' && transactionType != 'deposit'">
<div class="row mb-3">
<label :for="'bill_id_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-calendar"></i>
</label>
<div class="col-sm-10">
<template x-if="loadingSubscriptions">
<span class="form-control-plaintext"><em
class="fa-solid fa-spinner fa-spin"></em></span>
</template>
<template x-if="!loadingSubscriptions">
<select class="form-control"
:id="'bill_id_' + index"
x-model="transaction.bill_id">
<template x-for="group in subscriptions">
<optgroup :label="group.name">
<template
x-for="subscription in group.subscriptions">
<option :label="subscription.name"
:value="subscription.id"
x-text="subscription.name"></option>
</template>
</optgroup>
</template>
</select>
</template>
</div>
</div>
</template>
<div class="row mb-3">
<label :for="'tags_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-tag"></i>
</label>
<div class="col-sm-10">
<select
class="form-select ac-tags"
:id="'tags_' + index"
x-model="transaction.tags"
:name="'tags['+index+'][]'"
multiple>
<option value="">Type a tag...</option>
</select>
</div>
</div>
<div class="row mb-3">
<label :for="'notes_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-font"></i>
</label>
<div class="col-sm-10">
<textarea class="form-control" :id="'notes_' + index"
x-model="transaction.notes"
placeholder="{{ __('firefly.notes') }}"></textarea>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-4 col-lg-6 col-md-12 col-xs-12 mb-2">
<div class="card">
<div class="card-header">
<h3 class="card-title">
{{ __('firefly.transaction_journal_extra') }}
</h3>
</div>
<div class="card-body">
<div class="row mb-3">
<label :for="'attachments_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-file-import"></i>
</label>
<div class="col-sm-10">
<input type="file" multiple
class="form-control attachments"
:id="'attachments_' + index"
:data-index="index"
name="attachments[]"
placeholder="{{ __('firefly.category') }}">
</div>
</div>
<div class="row mb-3">
<label :for="'internal_reference_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-anchor"></i>
</label>
<div class="col-sm-10">
<input type="search"
class="form-control"
:id="'internal_reference_' + index"
x-model="transaction.internal_reference"
:data-index="index"
placeholder="{{ __('firefly.internal_reference') }}">
</div>
</div>
<div class="row mb-3">
<label :for="'external_url_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-link"></i>
</label>
<div class="col-sm-10">
<input type="text"
class="form-control"
:id="'external_url_' + index"
x-model="transaction.external_url"
:data-index="index"
:class="{'is-invalid': transaction.errors.external_url.length > 0, 'form-control': true}"
placeholder="{{ __('firefly.external_url') }}" />
<template x-if="transaction.errors.external_url.length > 0">
<div class="invalid-feedback"
x-text="transaction.errors.external_url[0]">
</div>
</template>
</div>
</div>
<div class="row mb-3">
<label :for="'map_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-earth-europe"></i>
</label>
<div class="col-sm-10">
<div :id="'location_map_' + index" style="height:300px;" :data-index="index"></div>
<span class="muted small">
<template x-if="!transaction.hasLocation">
<span>Tap the map to add a location</span>
</template>
<template x-if="transaction.hasLocation">
<a :data-index="index" href="#" @click="clearLocation">Clear point</a>
</template>
</span>
</div>
</div>
<!-- -->
<template x-for="dateField in dateFields">
<div class="row mb-1">
<label :for="dateField + '_date_' + index"
class="col-sm-1 col-form-label d-none d-sm-block">
<i class="fa-solid fa-calendar-alt" :title="dateField"></i>
</label>
<div class="col-sm-10">
<input type="date"
class="form-control"
:id="dateField + '_date_' + index"
x-model="transaction[dateField]"
:data-index="index"
placeholder="">
</div>
</div>
</template>
</div>
</div>
</div>
<div class="col-xl-4 col-lg-6 col-md-12 col-xs-12 mb-2">
<div class="card">
<div class="card-header">
<h3 class="card-title">
{{ __('firefly.submission_options') }}
</h3>
</div>
<div class="card-body">
<div class="form-check">
<input class="form-check-input" x-model="returnHereButton" type="checkbox"
id="returnButton">
<label class="form-check-label" for="returnButton">
Return here to create a new transaction
</label>
</div>
<div class="form-check">
<input class="form-check-input" x-model="resetButton" type="checkbox"
id="resetButton" :disabled="!returnHereButton">
<label class="form-check-label" for="resetButton">
Reset the form after returning
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="rulesButton"
:checked="rulesButton">
<label class="form-check-label" for="rulesButton">
Run rules on this transaction
</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="webhookButton"
:checked="webhookButton">
<label class="form-check-label" for="webhookButton">
Run webhooks on this transaction
</label>
</div>
</div>
<div class="card-footer">
submission options
</div>
</div>
</div>
<div class="col-12">
<template x-if="0 !== index">
<button :disabled="submitting" class="btn btn-danger" @click="removeSplit(index)">
Remove this split
</button>
</template>
<button class="btn btn-info" :disabled="submitting">Add another split</button>
</div>
</div>
</div>
<x-transaction-split></x-transaction-split>
</template>
</div>
<div class="row">

View File

@ -0,0 +1,22 @@
@extends('layout.v2')
@section('vite')
@vite(['resources/assets/v2/sass/app.scss', 'resources/assets/v2/pages/transactions/edit.js'])
@endsection
@section('content')
<div class="app-content">
<!--begin::Container-->
<div class="container-fluid" x-data="transactions" id="form">
<x-messages></x-messages>
<x-transaction-tab-list></x-transaction-tab-list>
<div class="tab-content" id="splitTabsContent">
</div>
<div class="row">
<div class="col text-end">
<button class="btn btn-success" :disabled="submitting" @click="submitTransaction()">Update</button>
</div>
</div>
</div>
</div>
@endsection

View File

@ -44,6 +44,7 @@ export default defineConfig({
'resources/assets/v2/sass/app.scss',
'resources/assets/v2/pages/dashboard/dashboard.js',
'resources/assets/v2/pages/transactions/create.js',
'resources/assets/v2/pages/transactions/edit.js',
],
refresh: true,
}),