Skip to content

Firefly III: a personal finances manager

Fix #12825

James Cole7e5f330a3b51
diff --git a/changelog.md b/changelog.md
index eb7dadbfd3..066e026b8c 100644
--- a/changelog.md
+++ b/changelog.md
@@ -31,6 +31,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- #12828
- #12827
- #12824
+- #12825
### Security
diff --git a/resources/assets/v3/js/pages/transactions/edit.js b/resources/assets/v3/js/pages/transactions/edit.js
index 7f8fd7f93f..013b81917b 100644
--- a/resources/assets/v3/js/pages/transactions/edit.js
+++ b/resources/assets/v3/js/pages/transactions/edit.js
@@ -21,55 +21,54 @@
import "../../boot/bootstrap.js";
import dates from "../../pages/shared/dates.js";
import Get from "../../api/model/transaction/get.js";
-import { parseDownloadedSplits } from "./shared/parse-downloaded-splits.js";
-import { addAllAutocompleteToForm, getUrls } from "./shared/add-autocomplete.js";
-import { loadCurrencies } from "./shared/load-currencies.js";
-import { loadBudgets } from "./shared/load-budgets.js";
-import { loadPiggyBanks } from "./shared/load-piggy-banks.js";
-import { processUploadError } from "./shared/process-upload-error.js";
-import { loadSubscriptions } from "./shared/load-subscriptions.js";
-import Tags from "bootstrap5-tags";
+import {parseDownloadedSplits} from "./shared/parse-downloaded-splits.js";
+import {addAllAutocompleteToForm, getUrls} from "./shared/add-autocomplete.js";
+import {loadCurrencies} from "./shared/load-currencies.js";
+import {loadBudgets} from "./shared/load-budgets.js";
+import {loadPiggyBanks} from "./shared/load-piggy-banks.js";
+import {processUploadError} from "./shared/process-upload-error.js";
+import {loadSubscriptions} from "./shared/load-subscriptions.js";
import i18next from "i18next";
-import { defaultErrorSet } from "./shared/create-empty-split.js";
-import { parseFromEntries } from "./shared/parse-from-entries.js";
+import {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 {showMessageOrRedirectUser} from "./shared/show-message-or-redirect.js";
+import {processAttachments} from "./shared/process-attachments.js";
import sidebar from "../shared/sidebar.js";
-import { disableSplitInputs } from "./shared/disable-split-inputs.js";
-import { parseTotalAmount } from "./shared/parse-total-amount.js";
-import { keyUpFromCategory } from "./shared/keyup-from-category.js";
-import { keyUpFromSource } from "./shared/keyup-from-source.js";
-import { keyUpFromDestination } from "./shared/keyup-from-destination.js";
-import { keyUpFromDescription } from "./shared/keyup-from-description.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";
-import { clearDestinationAccount, clearSourceAccount } from "./shared/clear-fields.js";
-import { detectTransactionType } from "./shared/detect-transaction-type.js";
-import { determineAmountCurrency } from "./shared/determine-amount-currency.js";
-import { loadCustomFields } from "./shared/load-custom-fields.js";
-import { displayMap } from "./shared/display-map.js";
-import { loadDefaultCoordinates } from "./shared/load-default-coordinates.js";
-import { renderMap } from "./shared/render-map.js";
+import {disableSplitInputs} from "./shared/disable-split-inputs.js";
+import {parseTotalAmount} from "./shared/parse-total-amount.js";
+import {keyUpFromCategory} from "./shared/keyup-from-category.js";
+import {keyUpFromSource} from "./shared/keyup-from-source.js";
+import {keyUpFromDestination} from "./shared/keyup-from-destination.js";
+import {keyUpFromDescription} from "./shared/keyup-from-description.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";
+import {clearDestinationAccount, clearSourceAccount} from "./shared/clear-fields.js";
+import {detectTransactionType} from "./shared/detect-transaction-type.js";
+import {determineAmountCurrency} from "./shared/determine-amount-currency.js";
+import {loadCustomFields} from "./shared/load-custom-fields.js";
+import {displayMap} from "./shared/display-map.js";
+import {loadDefaultCoordinates} from "./shared/load-default-coordinates.js";
+import {renderMap} from "./shared/render-map.js";
import "leaflet/dist/leaflet.css";
-import { onMapClick } from "./shared/on-map-click.js";
-import { onMapZoom } from "./shared/on-map-zoom.js";
-import { clearLocation } from "./shared/clear-location.js";
-import { removeSplit } from "./shared/remove-split.js";
-import { loadTransactionLinks } from "./shared/load-transaction-links.js";
-import { createLinkAutocomplete } from "./shared/create-link-autocomplete.js";
-import { editLink } from "./shared/edit-link.js";
-import { switchLink } from "./shared/switch-link.js";
-import { removeLink } from "./shared/remove-link.js";
-import { saveEditedLink } from "./shared/save-edited-link.js";
-import { saveNewLink } from "./shared/save-new-link.js";
-import { processTransactionLinks } from "./shared/process-transaction-links.js";
-import { redirectAfterTransactionLinks } from "./shared/redirect-after-transaction-links.js";
-import { addTabListener } from "./shared/add-tab-listener.js";
-import { autoStep } from "./shared/auto-step.js";
-import { respondToTabSwitch } from "./shared/respond-to-tab-switch.js";
+import {onMapClick} from "./shared/on-map-click.js";
+import {onMapZoom} from "./shared/on-map-zoom.js";
+import {clearLocation} from "./shared/clear-location.js";
+import {removeSplit} from "./shared/remove-split.js";
+import {loadTransactionLinks} from "./shared/load-transaction-links.js";
+import {createLinkAutocomplete} from "./shared/create-link-autocomplete.js";
+import {editLink} from "./shared/edit-link.js";
+import {switchLink} from "./shared/switch-link.js";
+import {removeLink} from "./shared/remove-link.js";
+import {saveEditedLink} from "./shared/save-edited-link.js";
+import {saveNewLink} from "./shared/save-new-link.js";
+import {processTransactionLinks} from "./shared/process-transaction-links.js";
+import {redirectAfterTransactionLinks} from "./shared/redirect-after-transaction-links.js";
+import {addTabListener} from "./shared/add-tab-listener.js";
+import {autoStep} from "./shared/auto-step.js";
+import {respondToTabSwitch} from "./shared/respond-to-tab-switch.js";
import Alpine from "alpinejs";
import focusFirstInput from "../../shared/focus-first-input.js";
@@ -279,37 +278,27 @@ let transactions = function () {
})
.then(() => {
focusFirstInput();
+ let tagSelect;
this.groupProperties.totalAmount = 0;
for (let i in this.entries) {
if (Object.hasOwn(this.entries, i)) {
- this.groupProperties.totalAmount =
- this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);
+ this.groupProperties.totalAmount = this.groupProperties.totalAmount + parseFloat(this.entries[i].amount);
+ // add the tags. This is not done in Alpine itself because the combination between
+ // the Autocomplete library and Alpine breaks for some reason.
+ tagSelect = document.getElementById('tags_' + i);
+ if (null !== tagSelect) {
+ console.log('Is not null.');
+ for (let j in this.entries[i].tags) {
+ if (Object.hasOwn(this.entries[i].tags, j)) {
+ tagSelect.options.add(new Option(this.entries[i].tags[j], this.entries[i].tags[j], true, true));
+ }
+ }
+ }
+
}
}
- setTimeout(() => {
- // send event that transaction group is loaded.
- // document.dispatchEvent(new CustomEvent('transaction-group-loaded'));
-
- // TODO should not be on a timeout.
- // render tags:
- Tags.init("select.ac-tags", {
- allowClear: true,
- server: urls.tag,
- liveServer: true,
- clearEnd: true,
- allowNew: true,
- labelField: "title",
- valueField: "id",
- queryParam: "filter[query]",
- notFoundMessage: i18next.t("firefly.nothing_found"),
- noCache: true,
- fetchOptions: {
- headers: {
- "X-CSRF-TOKEN": document.head.querySelector('meta[name="csrf-token"]').content,
- },
- },
- });
- }, 150);
+
+
this.autoStep();
});
},
@@ -404,7 +393,7 @@ let transactions = function () {
// submit the transaction. Multi-stage process thing going on here!
let putter = new Put();
putter
- .put(submission, { id: this.groupProperties.id })
+ .put(submission, {id: this.groupProperties.id})
.then((response) => {
this.formStates.storedGroup = true;
const group = response.data.data;
@@ -457,7 +446,7 @@ let transactions = function () {
};
};
-let comps = { transactions, sidebar, dates };
+let comps = {transactions, sidebar, dates};
function loadPage() {
Object.keys(comps).forEach((comp) => {
diff --git a/resources/assets/v3/js/pages/transactions/shared/add-autocomplete.js b/resources/assets/v3/js/pages/transactions/shared/add-autocomplete.js
index e9220b8f21..fa1b90da6e 100644
--- a/resources/assets/v3/js/pages/transactions/shared/add-autocomplete.js
+++ b/resources/assets/v3/js/pages/transactions/shared/add-autocomplete.js
@@ -76,8 +76,8 @@ export function addAllAutocompleteToForm() {
"</small>"
);
};
-
- // render tags:
+ //
+ // // render tags:
Tags.init("select.ac-tags", {
allowClear: true,
server: urls.tag,
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.js
index 0ccccb3cb2..95f1fde48b 100644
--- 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.js
@@ -75,10 +75,14 @@ export function showMessageOrRedirectUser() {
// find parts
let parts = URL.parse(params, "https://example.com/");
- let from;
+ let from = '';
let separator = "?";
if ("" === parts.search) {
- from = urlParams.get("_from").toString();
+ let fromParam = urlParams.get("_from");
+ if(null !== fromParam) {
+ from = fromParam.toString();
+ }
+
}
if ("" !== parts.search) {
let obj = new URLSearchParams(parts.search);
diff --git a/resources/views/partials/form/transaction/tags.blade.php b/resources/views/partials/form/transaction/tags.blade.php
index e0889b2ac1..eaf874f97c 100644
--- a/resources/views/partials/form/transaction/tags.blade.php
+++ b/resources/views/partials/form/transaction/tags.blade.php
@@ -11,15 +11,43 @@
x-model="transaction.tags"
multiple>
<option value="">{{ __('firefly.select_tag') }}</option>
- <template x-for="(tag, index) in transaction.tags" :key="index">
- <option :value="tag" x-text="tag" selected="selected"></option>
- </template>
+
</select>
</div>
</div>
<!--
+<div class="row mb-2">
+ <label :for="'tags_' + index"
+ class="col-sm-1 col-form-label d-none d-sm-block">
+ <em title="{{ __('firefly.tags') }}" class="bi bi-tag"></em>
+ </label>
+ <template x-for="(currentTag, index) in transaction.tags" :key="index">
+ <option :value="currentTag" x-text="currentTag" selected="selected"></option>
+ </template>
+ <div class="col-sm-10">
+ <select
+ class="form-select ac-tags"
+ :id="'tags_' + index"
+ :name="'tags['+index+'][]'"
+ x-model="transaction.tags"
+ multiple>
+ <option value="">{{ __('firefly.select_tag') }}</option>
+ <template x-for="(currentValue, index) in transaction.tags" :key="index">
+ <option :label="index" :value="index" x-text="index" selected="selected"></option>
+ </template>
+ </select>
+
+ </div>
+</div>
+
+<option value="currentValue" x-text="currentValue" selected="selected"></option>
+ :value="tag"
+<template x-for="(tag, index) in transaction.tags" :key="index">
+ <option value="bla">bla</option>
+ </template>
+
:value="tag"
<template x-for="(tag, index) in transaction.tags" :key="index">
<option value="bla">bla</option>
diff --git a/resources/views/transactions/show.blade.php b/resources/views/transactions/show.blade.php
index 527eee0a6f..cc84349a7e 100644
--- a/resources/views/transactions/show.blade.php
+++ b/resources/views/transactions/show.blade.php
@@ -449,7 +449,7 @@
<td>
@foreach($journal['tags'] as $tag)
@if(null !== $tag['id'] && '' !== $tag['id'])
- <h4 class="inline"><a class="badge text-bg-success" href="{{ route('tags.show', [$tag['id']]) }}"><span class="bi bi-tag"></span>{{ $tag['tag'] }}</a></h4>
+ <h5 class="d-inline"><a class="badge text-bg-success" href="{{ route('tags.show', [$tag['id']]) }}"><span class="bi bi-tag"></span>{{ $tag['tag'] }}</a></h5>
@endif
@endforeach
</td>