Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix location and start with transaction links
Sander Dorigo515227cc1f93
diff --git a/resources/assets/v2/src/pages/transactions/create.js b/resources/assets/v2/src/pages/transactions/create.jsindex b7c3ea5079..e0327b4e43 100644--- a/resources/assets/v2/src/pages/transactions/create.js+++ b/resources/assets/v2/src/pages/transactions/create.js@@ -206,36 +206,6 @@ let transactions = function () {return formatMoney(this.groupProperties.totalAmount, this.entries[0].currency_code ?? 'EUR');},- filterForeignCurrencies(code) {- let list = [];- let currency;- for (let i in this.formData.enabledCurrencies) {- if (this.formData.enabledCurrencies.hasOwnProperty(i)) {- let current = this.formData.enabledCurrencies[i];- if (current.code === code) {- currency = current;- }- }- }- list.push(currency);- this.formData.foreignCurrencies = list;- // is he source account currency anyway:- if (1 === list.length && list[0].code === this.entries[0].source_account.currency_code) {- console.log('Foreign currency is same as source currency. Disable foreign amount.');- this.formBehaviour.foreignCurrencyEnabled = false;- }- if (1 === list.length && list[0].code !== this.entries[0].source_account.currency_code) {- console.log('Foreign currency is NOT same as source currency. Enable foreign amount.');- this.formBehaviour.foreignCurrencyEnabled = true;- }-- // this also forces the currency_code on ALL entries.- for (let i in this.entries) {- if (this.entries.hasOwnProperty(i)) {- this.entries[i].foreign_currency_code = code;- }- }- },filterPrimaryCurrencies(code) {let list = [];diff --git a/resources/assets/v3/js/pages/transactions/create.js b/resources/assets/v3/js/pages/transactions/create.jsindex 9fc0f3c6f6..3430985c68 100644--- a/resources/assets/v3/js/pages/transactions/create.js+++ b/resources/assets/v3/js/pages/transactions/create.js@@ -21,27 +21,21 @@import '../../boot/bootstrap.js';import sidebar from '../../pages/shared/sidebar.js';import dates from '../shared/dates.js';-import {createEmptySplit, getAccount, defaultErrorSet} from "./shared/create-empty-split.js";+import {defaultErrorSet} from "./shared/create-empty-split.js";import {parseFromEntries} from "./shared/parse-from-entries.js";-import formatMoney from "../../util/format-money.js";import Post from "../../api/model/transaction/post.js";-import Delete from "../../api/model/transaction/delete.js";import {loadCurrencies} from "./shared/load-currencies.js";import {loadBudgets} from "./shared/load-budgets.js";import {loadPiggyBanks} from "./shared/load-piggy-banks.js";import {loadSubscriptions} from "./shared/load-subscriptions.js";-//-// import 'leaflet/dist/leaflet.css';-import {addAllAutocompleteToForm, getUrls} from "./shared/add-autocomplete.js";+import {addAllAutocompleteToForm} from "./shared/add-autocomplete.js";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";@@ -51,23 +45,14 @@ 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 {loadDefaultCoordinates} from './shared/load-default-coordinates.js';-import L from 'leaflet';import 'leaflet/dist/leaflet.css';-import markerIcon from "leaflet/dist/images/marker-icon.png";-import markerRetinaIcon from "leaflet/dist/images/marker-icon-2x.png";-import shadow from 'leaflet/dist/images/marker-shadow.png';import {displayMap} from './shared/display-map.js';import {renderMap} from './shared/render-map.js';import {onMapClick} from './shared/on-map-click.js';import {onMapZoom} from "./shared/on-map-zoom.js";+import {clearLocation} from './shared/clear-location.js';-// TODO fix two maps, perhaps disconnect from entries entirely.-// TODO map location from preferences-// TODO field preferences--const urls = getUrls();-let create = function () {return {// needed for translations.@@ -143,9 +128,6 @@ let create = function () {}},---// events in the formchangedDateTime(event) {console.warn('changedDateTime, event is not used');@@ -183,7 +165,7 @@ let create = function () {renderMap: renderMap,onMapClick: onMapClick,onMapZoom: onMapZoom,-+ clearLocation: clearLocation,filterForeignCurrencies(code) {let list = [];@@ -216,9 +198,6 @@ let create = function () {}},---addedSplit() {this.addAllAutocompleteToForm();},@@ -234,7 +213,6 @@ let create = function () {this.entries[index].category_name = '';},-respondToTabSwitch(event) {// event.target // newly activated tab// event.relatedTarget // previous active tab@@ -250,17 +228,11 @@ let create = function () {// this.maps[index].invalidateSize();setTimeout(() => {const tabEl = document.querySelectorAll('button[data-bs-toggle="tab"]')- console.log('Found tab elements', tabEl.length);for(let i = 0; i < tabEl.length; i++) {- console.log('Add to tab element', i);tabEl[i].removeEventListener('shown.bs.tab', this.respondToTabSwitch);tabEl[i].addEventListener('shown.bs.tab', this.respondToTabSwitch.bind(this), true);}- // tabEl.addEventListener('shown.bs.tab', event => {- // // event.target // newly activated tab- // // event.relatedTarget // previous active tab- // console.log('Switched to new tab!');- // });+ // TODO don't do this on a timeout!}, 500);},@@ -292,7 +264,6 @@ let create = function () {// load custom field preference and enable/disable those fields.this.loadCustomFields().then(data => {- console.log('Loaded custom fields', data);this.formBehaviour.customFields = data;});@@ -313,26 +284,6 @@ let create = function () {});--- // document.addEventListener('location-move', (event) => {- // this.entries[event.detail.index].latitude = event.detail.latitude;- // this.entries[event.detail.index].longitude = event.detail.longitude;- // });- //- // document.addEventListener('location-set', (event) => {- // this.entries[event.detail.index].hasLocation = true;- // this.entries[event.detail.index].latitude = event.detail.latitude;- // this.entries[event.detail.index].longitude = event.detail.longitude;- // this.entries[event.detail.index].zoomLevel = event.detail.zoomLevel;- // });- //- // document.addEventListener('location-zoom', (event) => {- // this.entries[event.detail.index].hasLocation = true;- // this.entries[event.detail.index].zoomLevel = event.detail.zoomLevel;- // });- //- //},save() {this.notifications.error.show = false;@@ -396,27 +347,7 @@ let create = function () {const triggerFirstTabEl = document.querySelector('#split-0-tab')triggerFirstTabEl.click();},- //- // clearLocation(e) {- // e.preventDefault();- // // remove location from entry, fire event, do nothing else (the map is somebody else's problem).- //- // const target = e.currentTarget;- // const index = parseInt(target.attributes['data-index'].value);- // this.entries[index].hasLocation = false;- // this.entries[index].latitude = null;- // this.entries[index].longitude = null;- // this.entries[index].zoomLevel = null;- //- // const removeEvent = new CustomEvent('location-remove', {- // detail: {- // index: index- // }- // });- // document.dispatchEvent(removeEvent);- //- // return false;- // },+}}diff --git a/resources/assets/v3/js/pages/transactions/edit.js b/resources/assets/v3/js/pages/transactions/edit.jsindex 4b130b545f..4108d85e0e 100644--- a/resources/assets/v3/js/pages/transactions/edit.js+++ b/resources/assets/v3/js/pages/transactions/edit.js@@ -20,7 +20,6 @@import '../../boot/bootstrap.js';import dates from '../../pages/shared/dates.js';-import formatMoney from "../../util/format-money.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";@@ -54,13 +53,7 @@ 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';-// 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-// TODO filters-// TODO parse amount+import {clearLocation} from './shared/clear-location.js';const urls = getUrls();@@ -158,6 +151,7 @@ let transactions = function () {renderMap: renderMap,onMapClick: onMapClick,onMapZoom: onMapZoom,+ clearLocation: clearLocation,// part of the account selection auto-complete@@ -181,18 +175,7 @@ let transactions = function () {getTags(index) {return this.entries[index].tags ?? [];},- clearLocation(e) {- let index = parseInt(e.currentTarget.dataset.index);- this.entries[index].hasLocation = false;- this.entries[index].latitude = null;- this.entries[index].longitude = null;- this.entries[index].zoom_level = null;-- if(this.markers.hasOwnProperty(index)) {- this.maps[index].removeLayer(this.markers[index]);- }- },getTransactionGroup() {this.entries = [];const page = window.location.href.split('/');diff --git a/resources/assets/v3/js/pages/transactions/shared/clear-location.js b/resources/assets/v3/js/pages/transactions/shared/clear-location.jsnew file mode 100644index 0000000000..caa5d11edb--- /dev/null+++ b/resources/assets/v3/js/pages/transactions/shared/clear-location.js@@ -0,0 +1,12 @@+export function clearLocation(e) {++ let index = parseInt(e.currentTarget.dataset.index);+ this.entries[index].hasLocation = false;+ this.entries[index].latitude = null;+ this.entries[index].longitude = null;+ this.entries[index].zoom_level = null;++ if(this.markers.hasOwnProperty(index)) {+ this.maps[index].removeLayer(this.markers[index]);+ }+}diff --git a/resources/views/components/transaction/split.blade.php b/resources/views/components/transaction/split.blade.phpindex 33213fd477..8c8037aee5 100644--- a/resources/views/components/transaction/split.blade.php+++ b/resources/views/components/transaction/split.blade.php@@ -97,6 +97,9 @@<!-- DATE FIELDS -->@include('partials.form.transaction.date-fields')++ <!-- TRANSACTION LINKS -->+ @include('partials.form.transaction.links')</div></div></div>diff --git a/resources/views/partials/form/transaction/links.blade.php b/resources/views/partials/form/transaction/links.blade.phpnew file mode 100644index 0000000000..8beb229773--- /dev/null+++ b/resources/views/partials/form/transaction/links.blade.php@@ -0,0 +1,15 @@+<template x-if="true === formBehaviour.customFields.links">+<div class="row mb-3">+ <label :for="'category_name_' + index" class="col-sm-1 col-form-label d-none d-sm-block">+ <em title="{{ __('firefly.journal_links') }}" class="bi bi-link"></em>+ </label>+ <div class="col-sm-10">+ <div class="form-group">++ <div class="form-control-plaintext">+ <a class="btn btn-sm btn-outline-primary" href="#">Manage related transactions</a>+ </div>+ </div>+ </div>+</div>+</template>diff --git a/resources/views/transactions/create.blade.php b/resources/views/transactions/create.blade.phpindex de55f0d2c8..b7f5eb77da 100644--- a/resources/views/transactions/create.blade.php+++ b/resources/views/transactions/create.blade.php@@ -5,8 +5,7 @@<x-transaction.tab-list /><div class="tab-content" id="splitTabsContent"><template x-for="transaction, index in entries">- <x-transaction.split- />+ <x-transaction.split /></template></div></div>