Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Clean up shared elements of create transaction form.
James Colef38577380c13
diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.phpindex 7ba3b2db5d..3ef4bebc5c 100644--- a/app/Http/Controllers/Controller.php+++ b/app/Http/Controllers/Controller.php@@ -193,7 +193,11 @@ abstract class Controller extends BaseController$from = $current['path'];}if (array_key_exists('query', $current) && '' !== $current['query']) {- $from .= '?'.$current['query'];+ // parse query and remove existing _from.+ $parts = [];+ parse_str($current['query'], $parts);+ unset($parts['_from']);+ $from .= http_build_query($parts);}if (array_key_exists('fragment', $current) && '' !== $current['fragment']) {$from .= '#'.$current['fragment'];diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.phpindex 46595819d8..4319b1e868 100644--- a/app/Http/Controllers/Transaction/CreateController.php+++ b/app/Http/Controllers/Transaction/CreateController.php@@ -24,10 +24,12 @@ declare(strict_types=1);namespace FireflyIII\Http\Controllers\Transaction;+use FireflyIII\Exceptions\FireflyException;use FireflyIII\Http\Controllers\Controller;use FireflyIII\Models\TransactionGroup;use FireflyIII\Repositories\Account\AccountRepositoryInterface;use FireflyIII\Repositories\TransactionGroup\TransactionGroupRepositoryInterface;+use FireflyIII\Rules\System\IsValidOriginUrl;use FireflyIII\Services\Internal\Update\GroupCloneService;use FireflyIII\Support\Facades\AppConfiguration;use FireflyIII\Support\Facades\Preferences;@@ -101,6 +103,15 @@ final class CreateController extends Controller*/public function create(?string $objectType): Factory|View{+ // validate "from" parameter.+ // TODO better place to do this perhaps?+ $from = request()->get('_from');+ $validator = validator(['_from' => $from], ['nullable', 'max:255', new IsValidOriginUrl()]);+ if ($validator->fails()) {+ throw new FireflyException(trans('validation.bad_url_parts'));+ }++Preferences::mark();$sourceId = (int) request()->get('source');diff --git a/resources/assets/v1/src/components/form/Title.vue b/resources/assets/v1/src/components/form/Title.vuedeleted file mode 100644index 661e65e98e..0000000000--- a/resources/assets/v1/src/components/form/Title.vue+++ /dev/null@@ -1,67 +0,0 @@-<!--- - TransactionDescription.vue- - Copyright (c) 2019 [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/>.- -->--<template>--</template>--<script>-export default {- props: {- error: {- type: Array,- required: true,- default() {- return []- }- },- value: {- type: String,- required: true,- }- },- name: "Title",- mounted() {- this.title = this.value;- },- watch: {- value() {- this.title = this.value;- }- },- components: {},- data() {- return {- title: ''- }- },- methods: {- hasError: function () {- return this.error.length > 0;- },- clearTitle: function () {- this.title = '';- },- handleInput() {- this.$emit('input', this.title);- },- }-}-</script>diff --git a/resources/assets/v1/src/components/form/URL.vue b/resources/assets/v1/src/components/form/URL.vuedeleted file mode 100644index 686905c82c..0000000000--- a/resources/assets/v1/src/components/form/URL.vue+++ /dev/null@@ -1,97 +0,0 @@-<!--- - TransactionDescription.vue- - Copyright (c) 2019 [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/>.- -->--<template>- <div class="form-group" v-bind:class="{ 'has-error': hasError()}">- <label class="col-sm-4 control-label">- {{ $t('form.url') }}- </label>- <div class="col-sm-8">- <div class="input-group">- <input- ref="title"- :title="$t('form.url')"- v-model="url"- autocomplete="off"- class="form-control"- @input="handleInput"- name="url"- type="text"- placeholder="https://"- v-on:submit.prevent- >- <span class="input-group-btn">- <button- class="btn btn-default"- tabIndex="-1"- type="button"- v-on:click="clearUrl"><i class="fa fa-trash-o"></i></button>- </span>- </div>- <ul v-for="error in this.error" class="list-unstyled">- <li class="text-danger">{{ error }}</li>- </ul>- </div>- </div>-</template>--<script>-export default {- props: {- error: {- type: Array,- required: true,- default() {- return []- }- },- value: {- type: String,- required: true,- }- },- name: "URL",- watch: {- value() {- this.url = this.value;- }- },- mounted() {- this.url = this.value;- },- components: {},- data() {- return {- url: null,- }- },- methods: {- hasError: function () {- return this.error?.length > 0;- },- clearUrl: function () {- this.url = '';- },- handleInput() {- this.$emit('input', this.url);- },- }-}-</script>diff --git a/resources/assets/v1/src/components/form/UserGroupCurrency.vue b/resources/assets/v1/src/components/form/UserGroupCurrency.vuedeleted file mode 100644index fbd483b69d..0000000000--- a/resources/assets/v1/src/components/form/UserGroupCurrency.vue+++ /dev/null@@ -1,107 +0,0 @@-<!--- - WebhookDelivery.vue- - Copyright (c) 2022 [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/>.- -->--<template>- <div class="form-group" v-bind:class="{ 'has-error': hasError()}">- <label class="col-sm-4 control-label">- {{ $t('form.administration_currency') }}- </label>- <div class="col-sm-8">- <select- v-model="currency"- :title="$t('form.administration_currency')"- class="form-control"- name="user_group_currency"- >- <option v-for="currency in this.currencies"- :label="currency.name"- :value="currency.id">{{ currency.name }}- </option>- </select>- <p class="help-block" v-text="$t('firefly.administration_currency_form_help')"></p>- <ul v-for="error in this.error" class="list-unstyled">- <li class="text-danger">{{ error }}</li>- </ul>- </div>- </div>-</template>--<script>-export default {- name: "UserGroupCurrency",- data() {- return {- currency : 0,- currencies: [-- ],- };- },- props: {- error: {- type: Array,- required: true,- default() {- return []- }- },- value: {- type: Number,- required: true,- }- },- mounted() {- this.currency = this.value;- this.downloadCurrencies(1);- },- watch: {- value() {- this.currency = this.value;- },- currency(newValue) {- this.$emit('input', newValue);- }- },- methods: {- downloadCurrencies: function (page) {- axios.get("./api/v1/currencies?enabled=1&page=" + page).then((response) => {- for (let i in response.data.data) {- if (response.data.data.hasOwnProperty(i)) {- let current = response.data.data[i];- let currency = {- id: current.id,- name: current.attributes.name,- code: current.attributes.code,- };- this.currencies.push(currency);- }- }-- if (response.data.meta.pagination.current_page < response.data.meta.pagination.total_pages) {- this.downloadCurrencies(parseInt(response.data.meta.pagination.current_page) + 1);- }- });- },- hasError() {- return this.error?.length > 0;- }- },-}-</script>diff --git a/resources/assets/v1/src/components/form/WebhookDelivery.vue b/resources/assets/v1/src/components/form/WebhookDelivery.vuedeleted file mode 100644index ff184466ac..0000000000--- a/resources/assets/v1/src/components/form/WebhookDelivery.vue+++ /dev/null@@ -1,111 +0,0 @@-<!--- - WebhookDelivery.vue- - Copyright (c) 2022 [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/>.- -->--<template>- <div class="form-group" v-bind:class="{ 'has-error': hasError()}">- <label class="col-sm-4 control-label">- {{ $t('form.webhook_delivery') }}- </label>- <div class="col-sm-8">- <div v-if="loading" class="form-control-static">- <em class="fa fa-spinner fa-spin"></em> {{ $t('firefly.loading') }}- </div>- <select v-if="!loading"- ref="bill"- v-model="delivery"- :title="$t('form.webhook_delivery')"- class="form-control"- name="webhook_delivery"- >- <option v-for="delivery in this.deliveries"- :label="delivery.name"- :value="delivery.id">{{ delivery.name }}- </option>- </select>- <p class="help-block" v-text="$t('firefly.webhook_delivery_form_help')"></p>- <ul v-for="error in this.error" class="list-unstyled">- <li class="text-danger">{{ error }}</li>- </ul>- </div>- </div>-</template>--<script>-export default {- name: "WebhookDelivery",- data() {- return {- loading: true,- delivery : 0,- deliveries: [-- ],- };- },- props: {- error: {- type: Array,- required: true,- default() {- return []- }- },- value: {- type: String,- required: true,- }- },- mounted() {- this.delivery = this.value;- this.deliveries = [- //{id: 300, name: this.$t('firefly.webhook_delivery_JSON')},- ];- axios.get('./api/v1/configuration/webhook.deliveries').then((response) => {- for (let key in response.data.data.value) {- if (!response.data.data.value.hasOwnProperty(key)) {- continue;- }- this.deliveries.push(- {- id: key,- name: this.$t('firefly.webhook_delivery_' + key),- }- );- }- this.loading = false;- }).catch((error) => {- this.loading = false;- });- },- watch: {- value() {- this.delivery = this.value;- },- delivery(newValue) {- this.$emit('input', newValue);- }- },- methods: {- hasError() {- return this.error?.length > 0;- }- },-}-</script>diff --git a/resources/assets/v1/src/components/form/WebhookResponse.vue b/resources/assets/v1/src/components/form/WebhookResponse.vuedeleted file mode 100644index 1ce8eb32b9..0000000000--- a/resources/assets/v1/src/components/form/WebhookResponse.vue+++ /dev/null@@ -1,107 +0,0 @@-<!--- - WebhookResponse.vue- - Copyright (c) 2022 [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/>.- -->--<template>- <div class="form-group" v-bind:class="{ 'has-error': hasError()}">- <label class="col-sm-4 control-label">- {{ $t('form.webhook_response') }}- </label>- <div class="col-sm-8">- <div v-if="loading" class="form-control-static">- <em class="fa fa-spinner fa-spin"></em> {{ $t('firefly.loading') }}- </div>- <select v-if="!loading"- ref="response"- v-model="response"- :title="$t('form.webhook_response')"- class="form-control"- name="webhook_response"- >- <option v-for="response in this.responses"- :label="response.name"- :value="response.id">{{ response.name }}- </option>- </select>- <p class="help-block" v-text="$t('firefly.webhook_response_form_help')"></p>- <ul v-for="error in this.error" class="list-unstyled">- <li class="text-danger">{{ error }}</li>- </ul>- </div>- </div>-</template>--<script>-export default {- name: "WebhookResponse",- data() {- return {- loading: true,- response: 0,- responses: [],- };- },- props: {- error: {- type: Array,- required: true,- default() {- return []- }- },- value: {- type: String,- required: true,- }- },- watch: {- value() {- this.response = this.value;- },- response(newValue) {- this.$emit('input', newValue);- }- },- mounted() {- this.response = this.value;- this.responses = [];- axios.get('./api/v1/configuration/webhook.responses').then((response) => {- for (let key in response.data.data.value) {- if (!response.data.data.value.hasOwnProperty(key)) {- continue;- }- this.responses.push(- {- id: key,- name: this.$t('firefly.webhook_response_' + key),- }- );- }- this.loading = false;- }).catch((error) => {- this.loading = false;- });- },- methods: {- hasError() {- return this.error?.length > 0;- }- },-}-</script>diff --git a/resources/assets/v1/src/components/form/WebhookTrigger.vue b/resources/assets/v1/src/components/form/WebhookTrigger.vuedeleted file mode 100644index 0a13381b03..0000000000--- a/resources/assets/v1/src/components/form/WebhookTrigger.vue+++ /dev/null@@ -1,110 +0,0 @@-<!--- - WebhookTrigger.vue- - Copyright (c) 2022 [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/>.- -->--<template>- <div class="form-group" v-bind:class="{ 'has-error': hasError()}">- <label class="col-sm-4 control-label">- {{ $t('form.webhook_trigger') }}- </label>- <div class="col-sm-8">- <div v-if="loading" class="form-control-static">- <em class="fa fa-spinner fa-spin"></em> {{ $t('firefly.loading') }}- </div>- <select v-if="!loading"- ref="trigger"- multiple- v-model="trigger"- :title="$t('form.webhook_trigger')"- class="form-control"- name="webhook_trigger"- >- <option v-for="trigger in this.triggers"- :label="trigger.name"- :value="trigger.id">{{ trigger.name }}- </option>- </select>- <p class="help-block" v-text="$t('firefly.webhook_trigger_form_help')"></p>- <ul v-for="error in this.error" class="list-unstyled">- <li class="text-danger">{{ error }}</li>- </ul>- </div>- </div>-</template>--<script>-export default {- name: "WebhookTrigger",- data() {- return {- trigger: [],- loading: true,- triggers: [],- };- },- props: {- error: {- type: Array,- required: true,- default() {- return []- }- },- value: {- type: Array,- required: true,- }- },- mounted() {- this.trigger = this.value;- this.triggers = [];- axios.get('./api/v1/configuration/webhook.triggers').then((response) => {- for (let key in response.data.data.value) {- if (!response.data.data.value.hasOwnProperty(key)) {- continue;- }- this.triggers.push(- {- id: key,- name: this.$t('firefly.webhook_trigger_' + key),- }- );- // console.log('webhook trigger: id=' + response.data.data.value[key] + ', name=' + key);- }- this.loading = false;- }).catch((error) => {- this.loading = false;- });- },- watch: {- value() {- console.log('Value changed to ' + this.value);- this.trigger = this.value;- },- trigger(newValue) {- this.$emit('input', newValue);- }- },- methods: {- hasError() {- return this.error?.length > 0;- }- },-}-</script>diff --git a/resources/assets/v1/src/components/transactions/Amount.vue b/resources/assets/v1/src/components/transactions/Amount.vuedeleted file mode 100644index 14b9ad4c96..0000000000--- a/resources/assets/v1/src/components/transactions/Amount.vue+++ /dev/null@@ -1,19 +0,0 @@-<!--- - Amount.vue- - Copyright (c) 2019 [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/>.- -->diff --git a/resources/assets/v3/js/pages/transactions/create.js b/resources/assets/v3/js/pages/transactions/create.jsindex 52d356d9a3..5167ad7f00 100644--- a/resources/assets/v3/js/pages/transactions/create.js+++ b/resources/assets/v3/js/pages/transactions/create.js@@ -37,9 +37,15 @@ import {processAttachments} from "./shared/process-attachments.js";import {spliceErrorsIntoTransactions} from "./shared/splice-errors-into-transactions.js";import {disableSplitAccounts} from './shared/disable-split-accounts.js';import {parseTotalAmount} from "./shared/parse-total-amount.js";+import {keyUpFromCategory} from "./shared/keyup-from-category.js";+import {changedAmount} from "./shared/changed-amount.js";+import {changedForeignAmount} from "./shared/changed-foreign-amount.js";+import {parseErrors} from "./shared/parse-errors.js";// import {addLocation} from "./shared/manage-locations.js";import i18next from "i18next";import {processUploadError} from "./shared/process-upload-error.js";+import {showMessageOrRedirectUser} from "./shared/show-message-or-redirect.js";+import {addSplit} from "./shared/add-split.js";// TODO fix tags// TODO upload attachments to other file// TODO fix two maps, perhaps disconnect from entries entirely.@@ -140,6 +146,12 @@ let create = function () {disableSplitAccounts: disableSplitAccounts,parseTotalAmount: parseTotalAmount,processUploadError: processUploadError,+ keyUpFromCategory: keyUpFromCategory,+ changedAmount: changedAmount,+ changedForeignAmount: changedForeignAmount,+ showMessageOrRedirectUser: showMessageOrRedirectUser,+ parseErrors: parseErrors,+ addSplit:addSplit,detectTransactionType() {const sourceType = this.entries[0].source_account.type ?? 'unknown';@@ -276,26 +288,6 @@ let create = function () {}},- changedAmount(e) {- const index = parseInt(e.target.dataset.index);- this.entries[index].amount = parseFloat(e.target.value);- this.groupProperties.totalAmount = 0;- for (let i in this.entries) {- if (this.entries.hasOwnProperty(i)) {- this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);- }- }- },- changedForeignAmount(e) {- const index = parseInt(e.target.dataset.index);- this.entries[index].foreign_amount = parseFloat(e.target.value);- //this.groupProperties.totalAmount = 0;- // for (let i in this.entries) {- // if (this.entries.hasOwnProperty(i)) {- // this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);- // }- // }- },addedSplit() {addAllAutocompleteToForm(this.filters);@@ -384,13 +376,6 @@ let create = function () {// destination can never be revenue accountthis.filters.destination = ['Expense account', 'Loan', 'Debt', 'Mortgage', 'Asset account'];},- keyUpFromCategory(e) {- if (e.key === 'Enter' && false === this.formStates.categorySelectVisible) {- this.save();- return;- }- this.formStates.categorySelectVisible = document.querySelector('input.ac-category').nextSibling.classList.contains('show');- },save() {this.notifications.error.show = false;this.notifications.success.show = false;@@ -448,53 +433,6 @@ let create = function () {});},- showMessageOrRedirectUser() {- // disable all messages:- this.notifications.error.show = false;- this.notifications.success.show = false;- this.notifications.wait.show = false;-- if (this.formStates.returnHereButton) {- this.notifications.success.show = true;- this.notifications.success.url = 'transactions/show/' + parseInt(this.groupProperties.id);- this.notifications.success.text = i18next.t('firefly.stored_journal_js', {- description: this.groupProperties.title,- interpolation: {escapeValue: false}- });- this.formStates.isSubmitting = false;- // reset group title again- this.groupProperties.title = null;-- if (this.formStates.resetButton) {- this.entries = [];- this.addSplit();- this.groupProperties.totalAmount = 0;- }- return;- }- window.location = 'transactions/show/' + this.groupProperties.id + '?transaction_group_id=' + this.groupProperties.id + '&message=created';- },-- parseErrors(data) {- // disable all messages:- this.notifications.error.show = true;- this.notifications.success.show = false;- this.notifications.wait.show = false;- this.formStates.isSubmitting = false;- this.notifications.error.text = i18next.t('firefly.errors_submission_v2', {errorMessage: data.message});-- if (data.hasOwnProperty('errors')) {- this.entries = spliceErrorsIntoTransactions(data.errors, this.entries);- }- },-- addSplit() {- console.log('addSplit()');- this.entries.push(createEmptySplit());- this.disableSplitAccounts();- addAllAutocompleteToForm(this.filters);- },-removeSplit(index) {this.entries.splice(index, 1);// fall back to index 0diff --git a/resources/assets/v3/js/pages/transactions/edit.js b/resources/assets/v3/js/pages/transactions/edit.jsindex 036c7eedb0..7df87168bd 100644--- a/resources/assets/v3/js/pages/transactions/edit.js+++ b/resources/assets/v3/js/pages/transactions/edit.js@@ -34,11 +34,16 @@ import i18next from "i18next";import {createEmptySplit, defaultErrorSet} from "./shared/create-empty-split.js";import {parseFromEntries} from "./shared/parse-from-entries.js";import Put from "../../api/model/transaction/put.js";+import {showMessageOrRedirectUser} from "./shared/show-message-or-redirect.js";import {processAttachments} from "./shared/process-attachments.js";-import {spliceErrorsIntoTransactions} from "./shared/splice-errors-into-transactions.js";import sidebar from "../shared/sidebar.js";import {disableSplitAccounts} from "./shared/disable-split-accounts.js";import {parseTotalAmount} from "./shared/parse-total-amount.js";+import {keyUpFromCategory} from "./shared/keyup-from-category.js";+import {changedAmount} from "./shared/changed-amount.js";+import {changedForeignAmount} from "./shared/changed-foreign-amount.js";+import {parseErrors} from "./shared/parse-errors.js";+import {addSplit} from "./shared/add-split.js";// TODO upload attachments to other file// TODO fix two maps, perhaps disconnect from entries entirely.@@ -116,20 +121,18 @@ let transactions = function () {parseTotalAmount: parseTotalAmount,disableSplitAccounts: disableSplitAccounts,processUploadError: processUploadError,+ keyUpFromCategory: keyUpFromCategory,+ changedAmount: changedAmount,+ changedForeignAmount: changedForeignAmount,+ showMessageOrRedirectUser: showMessageOrRedirectUser,+ parseErrors: parseErrors,+ addSplit:addSplit,// part of the account selection auto-completefilters: {source: [], destination: [],},- // events in the form- keyUpFromCategory(e) {- if (e.key === 'Enter' && false === this.formBehaviour.categorySelectVisible) {- this.save();- return;- }- this.formBehaviour.categorySelectVisible = document.querySelector('input.ac-category').nextSibling.classList.contains('show');- },changedDateTime(event) {console.warn('changedDateTime, event is not used');},@@ -274,63 +277,12 @@ let transactions = function () {});},- changedAmount(e) {- const index = parseInt(e.target.dataset.index);- this.entries[index].amount = parseFloat(e.target.value);- this.groupProperties.totalAmount = 0;- for (let i in this.entries) {- if (this.entries.hasOwnProperty(i)) {- this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);- }- }- },- // TODO is a duplicate- showMessageOrRedirectUser() {- // disable all messages:- this.notifications.error.show = false;- this.notifications.success.show = false;- this.notifications.wait.show = false;- if (this.formStates.returnHereButton) {- let title = this.groupProperties.title;- if('' === title) {- title = this.entries[0].description;- }- this.notifications.success.show = true;- this.notifications.success.url = 'transactions/show/' + this.groupProperties.id;- this.notifications.success.text = i18next.t('firefly.updated_journal_js', {description: title});- this.formStates.isSubmitting = false;- return;- }- window.location = 'transactions/show/' + this.groupProperties.id + '?transaction_group_id=' + this.groupProperties.id + '&message=updated';- },- // TODO is a duplicate- parseErrors(data) {- // disable all messages:- this.notifications.error.show = true;- this.notifications.success.show = false;- this.notifications.wait.show = false;- this.formStates.isSubmitting = false;- this.notifications.error.text = i18next.t('firefly.errors_submission_v2', {errorMessage: data.message});-- if (data.hasOwnProperty('errors')) {- this.entries = spliceErrorsIntoTransactions(data.errors, this.entries);- }- },// TODO is a duplicateprocessUpload(event) {this.showMessageOrRedirectUser();},- changedForeignAmount(e) {- const index = parseInt(e.target.dataset.index);- if('' === e.target.value) {- this.entries[index].foreign_amount = '';- return;- }- this.entries[index].foreign_amount = parseFloat(e.target.value);- },-// submit the transaction form.// basically the same as store.js.save() {@@ -391,12 +343,7 @@ let transactions = function () {});},- addSplit() {- console.log('addSplit()');- this.entries.push(createEmptySplit());- this.disableSplitAccounts();- addAllAutocompleteToForm(this.filters);- },+ // exclusive to edit form, used to initialize splits.addedSplit() {console.log('addedSplit()');this.disableSplitAccounts();diff --git a/resources/assets/v3/js/pages/transactions/shared/add-split.js b/resources/assets/v3/js/pages/transactions/shared/add-split.jsnew file mode 100644index 0000000000..0b6a780694--- /dev/null+++ b/resources/assets/v3/js/pages/transactions/shared/add-split.js@@ -0,0 +1,29 @@+/*+ * add-split.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/>.+ */++import {createEmptySplit} from "./create-empty-split.js";+import {addAllAutocompleteToForm} from "./add-autocomplete.js";++export function addSplit() {+ console.log('addSplit()');+ this.entries.push(createEmptySplit());+ this.disableSplitAccounts();+ addAllAutocompleteToForm(this.filters);+}diff --git a/resources/assets/v3/js/pages/transactions/shared/changed-amount.js b/resources/assets/v3/js/pages/transactions/shared/changed-amount.jsnew file mode 100644index 0000000000..5bd2102ef1--- /dev/null+++ b/resources/assets/v3/js/pages/transactions/shared/changed-amount.js@@ -0,0 +1,30 @@+/*+ * changed-amount.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 function changedAmount(e) {+ const index = parseInt(e.target.dataset.index);+ this.entries[index].amount = parseFloat(e.target.value);+ this.groupProperties.totalAmount = 0;+ for (let i in this.entries) {+ if (this.entries.hasOwnProperty(i)) {+ this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);+ }+ }+}diff --git a/resources/assets/v3/js/pages/transactions/shared/changed-foreign-amount.js b/resources/assets/v3/js/pages/transactions/shared/changed-foreign-amount.jsnew file mode 100644index 0000000000..9ed7cd2a4e--- /dev/null+++ b/resources/assets/v3/js/pages/transactions/shared/changed-foreign-amount.js@@ -0,0 +1,30 @@+/*+ * changed-foreign-amount.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 function changedForeignAmount(e) {+ const index = parseInt(e.target.dataset.index);+ this.entries[index].foreign_amount = parseFloat(e.target.value);+ //this.groupProperties.totalAmount = 0;+ // for (let i in this.entries) {+ // if (this.entries.hasOwnProperty(i)) {+ // this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);+ // }+ // }+}diff --git a/resources/assets/v3/js/pages/transactions/shared/keyup-from-category.js b/resources/assets/v3/js/pages/transactions/shared/keyup-from-category.jsnew file mode 100644index 0000000000..c71d93972a--- /dev/null+++ b/resources/assets/v3/js/pages/transactions/shared/keyup-from-category.js@@ -0,0 +1,27 @@+/*+ * keyup-from-category.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 function keyUpFromCategory(e) {+ if (e.key === 'Enter' && false === this.formStates.categorySelectVisible) {+ this.save();+ return;+ }+ this.formStates.categorySelectVisible = document.querySelector('input.ac-category').nextSibling.classList.contains('show');+}diff --git a/resources/assets/v3/js/pages/transactions/shared/parse-errors.js b/resources/assets/v3/js/pages/transactions/shared/parse-errors.jsnew file mode 100644index 0000000000..cb173af742--- /dev/null+++ b/resources/assets/v3/js/pages/transactions/shared/parse-errors.js@@ -0,0 +1,35 @@+/*+ * parse-errors.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/>.+ */++import {spliceErrorsIntoTransactions} from "./splice-errors-into-transactions.js";+++export function parseErrors(data) {+ // disable all messages:+ this.notifications.error.show = true;+ this.notifications.success.show = false;+ this.notifications.wait.show = false;+ this.formStates.isSubmitting = false;+ this.notifications.error.text = i18next.t('firefly.errors_submission_v2', {errorMessage: data.message});++ if (data.hasOwnProperty('errors')) {+ this.entries = spliceErrorsIntoTransactions(data.errors, this.entries);+ }+}diff --git a/resources/assets/v3/js/pages/transactions/shared/show-message-or-redirect.js b/resources/assets/v3/js/pages/transactions/shared/show-message-or-redirect.jsnew file mode 100644index 0000000000..e1c4c0d54f--- /dev/null+++ b/resources/assets/v3/js/pages/transactions/shared/show-message-or-redirect.js@@ -0,0 +1,76 @@+/*+ * show-message-or-redirect.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/>.+ */++import i18next from "i18next";++export function showMessageOrRedirectUser() {+ // disable all messages:+ this.notifications.error.show = false;+ this.notifications.success.show = false;+ this.notifications.wait.show = false;++ if (this.formStates.returnHereButton) {+ this.formStates.isSubmitting = false;+ this.notifications.success.show = true;+ this.notifications.success.url = 'transactions/show/' + parseInt(this.groupProperties.id);++ // title depends on form role.+ if('create' === this.formBehaviour.formType) {+ this.notifications.success.text = i18next.t('firefly.stored_journal_js', {description: this.groupProperties.title, interpolation: {escapeValue: false}});+ this.groupProperties.title = null;++ // reset the form.+ if (this.formStates.resetButton) {+ this.entries = [];+ this.addSplit();+ this.groupProperties.totalAmount = 0;+ }+ }+ if('edit' === this.formBehaviour.formType) {+ let title = this.groupProperties.title;+ if('' === title) {+ title = this.entries[0].description;+ }+ this.notifications.success.text = i18next.t('firefly.updated_journal_js', {description: title});+ }+++ return;+ }+ // the redirect also depends on the "from" in the query param, which is validated by Firefly III on the server side.+ // get from parameter from query+ const urlParams = new URLSearchParams(window.location.search);+ const from = urlParams.get('_from').toString();++ // grab base href+ let baseHref = document.querySelector('base').getAttribute('href');+ baseHref = baseHref.substring(0, baseHref.length - 1);++ if ('' !== from) {+ console.log('Redirect to valid _from parameter: ' + baseHref + ' ' + from);+ window.location = baseHref + from;+ return;+ }+ if('edit' === this.formBehaviour.formType) {+ window.location = 'transactions/show/' + this.groupProperties.id + '?transaction_group_id=' + this.groupProperties.id + '&message=updated';+ return;+ }+ window.location = 'transactions/show/' + this.groupProperties.id + '?transaction_group_id=' + this.groupProperties.id + '&message=created';+}