diff --git a/app/Http/Controllers/Transaction/CreateController.php b/app/Http/Controllers/Transaction/CreateController.php
index 25fa35e902..3f270ed40f 100644
--- a/app/Http/Controllers/Transaction/CreateController.php
+++ b/app/Http/Controllers/Transaction/CreateController.php
@@ -101,28 +101,28 @@ class CreateController extends Controller
{
app('preferences')->mark();
- $sourceId = (int) request()->get('source');
- $destinationId = (int) request()->get('destination');
+ $sourceId = (int) request()->get('source');
+ $destinationId = (int) request()->get('destination');
/** @var AccountRepositoryInterface $accountRepository */
- $accountRepository = app(AccountRepositoryInterface::class);
- $cash = $accountRepository->getCashAccount();
- $preFilled = session()->has('preFilled') ? session('preFilled') : [];
- $subTitle = (string) trans(sprintf('breadcrumbs.create_%s', strtolower((string) $objectType)));
- $subTitleIcon = 'fa-plus';
- $optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
- $allowedOpposingTypes = config('firefly.allowed_opposing_types');
- $accountToTypes = config('firefly.account_to_transaction');
- $defaultCurrency = app('amount')->getDefaultCurrency();
- $previousUrl = $this->rememberPreviousUrl('transactions.create.url');
- $parts = parse_url($previousUrl);
- $search = sprintf('?%s', $parts['query'] ?? '');
- $previousUrl = str_replace($search, '', $previousUrl);
- if(!is_array($optionalFields)) {
+ $accountRepository = app(AccountRepositoryInterface::class);
+ $cash = $accountRepository->getCashAccount();
+ $preFilled = session()->has('preFilled') ? session('preFilled') : [];
+ $subTitle = (string) trans(sprintf('breadcrumbs.create_%s', strtolower((string) $objectType)));
+ $subTitleIcon = 'fa-plus';
+ $optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
+ $allowedOpposingTypes = config('firefly.allowed_opposing_types');
+ $accountToTypes = config('firefly.account_to_transaction');
+ $defaultCurrency = app('amount')->getDefaultCurrency();
+ $previousUrl = $this->rememberPreviousUrl('transactions.create.url');
+ $parts = parse_url($previousUrl);
+ $search = sprintf('?%s', $parts['query'] ?? '');
+ $previousUrl = str_replace($search, '', $previousUrl);
+ if (!is_array($optionalFields)) {
$optionalFields = [];
}
// not really a fan of this, but meh.
- $optionalDateFields = [
+ $optionalDateFields = [
'interest_date' => $optionalFields['interest_date'] ?? false,
'book_date' => $optionalFields['book_date'] ?? false,
'process_date' => $optionalFields['process_date'] ?? false,
@@ -132,6 +132,13 @@ class CreateController extends Controller
];
$optionalFields['external_url'] ??= false;
$optionalFields['location'] ??= false;
+ $optionalFields['location'] = $optionalFields['location'] && true === config('firefly.enable_external_map');
+
+ // map info:
+ $longitude = config('firefly.default_location.longitude');
+ $latitude = config('firefly.default_location.latitude');
+ $zoomLevel = config('firefly.default_location.zoom_level');
+
session()->put('preFilled', $preFilled);
return view(
@@ -139,6 +146,9 @@ class CreateController extends Controller
compact(
'subTitleIcon',
'cash',
+ 'longitude',
+ 'latitude',
+ 'zoomLevel',
'objectType',
'optionalDateFields',
'subTitle',
diff --git a/config/search.php b/config/search.php
index c8dcb7cc6f..dbbfce291e 100644
--- a/config/search.php
+++ b/config/search.php
@@ -210,8 +210,10 @@ return [
'amount_exactly' => ['alias' => true, 'alias_for' => 'amount_is', 'needs_context' => true],
'amount_less' => ['alias' => false, 'needs_context' => true],
'amount_max' => ['alias' => true, 'alias_for' => 'amount_less', 'needs_context' => true],
+ 'less' => ['alias' => true, 'alias_for' => 'amount_less', 'needs_context' => true],
'amount_more' => ['alias' => false, 'needs_context' => true],
'amount_min' => ['alias' => true, 'alias_for' => 'amount_more', 'needs_context' => true],
+ 'more' => ['alias' => true, 'alias_for' => 'amount_more', 'needs_context' => true],
'foreign_amount_is' => ['alias' => false, 'needs_context' => true],
'foreign_amount' => ['alias' => true, 'alias_for' => 'foreign_amount_is', 'needs_context' => true],
'foreign_amount_less' => ['alias' => false, 'needs_context' => true],
diff --git a/resources/assets/v2/pages/transactions/create.js b/resources/assets/v2/pages/transactions/create.js
index 34dae26f95..3110aba89d 100644
--- a/resources/assets/v2/pages/transactions/create.js
+++ b/resources/assets/v2/pages/transactions/create.js
@@ -46,6 +46,8 @@ import {
} from "./shared/autocomplete-functions.js";
import {processAttachments} from "./shared/process-attachments.js";
import {spliceErrorsIntoTransactions} from "./shared/splice-errors-into-transactions.js";
+import Tags from "bootstrap5-tags";
+import {addLocation} from "./shared/manage-locations.js";
// TODO upload attachments to other file
// TODO fix two maps, perhaps disconnect from entries entirely.
@@ -487,22 +489,31 @@ let transactions = function () {
},
addSplit() {
this.entries.push(createEmptySplit());
- // setTimeout(() => {
- // // render tags:
- // Tags.init('select.ac-tags', {
- // allowClear: true,
- // server: urls.tag,
- // liveServer: true,
- // clearEnd: true,
- // allowNew: true,
- // notFoundMessage: '(nothing found)',
- // noCache: true,
- // fetchOptions: {
- // headers: {
- // 'X-CSRF-TOKEN': document.head.querySelector('meta[name="csrf-token"]').content
- // }
- // }
- // });
+
+ setTimeout(() => {
+ // render tags:
+ Tags.init('select.ac-tags', {
+ allowClear: true,
+ server: urls.tag,
+ liveServer: true,
+ clearEnd: true,
+ allowNew: true,
+ notFoundMessage: i18n.t('firefly.nothing_found'),
+ noCache: true,
+ fetchOptions: {
+ headers: {
+ 'X-CSRF-TOKEN': document.head.querySelector('meta[name="csrf-token"]').content
+ }
+ }
+ });
+ console.log('in set timeout.');
+ const count = this.entries.length - 1;
+ if(document.querySelector('#location_map_' + count)) {
+ addLocation(count);
+ }
+ });
+
+
// const count = this.entries.length - 1;
// let map = L.map('location_map_' + count).setView([this.latitude, this.longitude], this.zoomLevel);
//
diff --git a/resources/assets/v2/pages/transactions/shared/manage-locations.js b/resources/assets/v2/pages/transactions/shared/manage-locations.js
new file mode 100644
index 0000000000..5aebfd9576
--- /dev/null
+++ b/resources/assets/v2/pages/transactions/shared/manage-locations.js
@@ -0,0 +1,57 @@
+/*
+ * manage-locations.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