mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-05 12:12:18 +00:00
Clean up files and add alias
This commit is contained in:
@@ -101,28 +101,28 @@ class CreateController extends Controller
|
|||||||
{
|
{
|
||||||
app('preferences')->mark();
|
app('preferences')->mark();
|
||||||
|
|
||||||
$sourceId = (int) request()->get('source');
|
$sourceId = (int) request()->get('source');
|
||||||
$destinationId = (int) request()->get('destination');
|
$destinationId = (int) request()->get('destination');
|
||||||
|
|
||||||
/** @var AccountRepositoryInterface $accountRepository */
|
/** @var AccountRepositoryInterface $accountRepository */
|
||||||
$accountRepository = app(AccountRepositoryInterface::class);
|
$accountRepository = app(AccountRepositoryInterface::class);
|
||||||
$cash = $accountRepository->getCashAccount();
|
$cash = $accountRepository->getCashAccount();
|
||||||
$preFilled = session()->has('preFilled') ? session('preFilled') : [];
|
$preFilled = session()->has('preFilled') ? session('preFilled') : [];
|
||||||
$subTitle = (string) trans(sprintf('breadcrumbs.create_%s', strtolower((string) $objectType)));
|
$subTitle = (string) trans(sprintf('breadcrumbs.create_%s', strtolower((string) $objectType)));
|
||||||
$subTitleIcon = 'fa-plus';
|
$subTitleIcon = 'fa-plus';
|
||||||
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
$optionalFields = app('preferences')->get('transaction_journal_optional_fields', [])->data;
|
||||||
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
|
$allowedOpposingTypes = config('firefly.allowed_opposing_types');
|
||||||
$accountToTypes = config('firefly.account_to_transaction');
|
$accountToTypes = config('firefly.account_to_transaction');
|
||||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||||
$previousUrl = $this->rememberPreviousUrl('transactions.create.url');
|
$previousUrl = $this->rememberPreviousUrl('transactions.create.url');
|
||||||
$parts = parse_url($previousUrl);
|
$parts = parse_url($previousUrl);
|
||||||
$search = sprintf('?%s', $parts['query'] ?? '');
|
$search = sprintf('?%s', $parts['query'] ?? '');
|
||||||
$previousUrl = str_replace($search, '', $previousUrl);
|
$previousUrl = str_replace($search, '', $previousUrl);
|
||||||
if(!is_array($optionalFields)) {
|
if (!is_array($optionalFields)) {
|
||||||
$optionalFields = [];
|
$optionalFields = [];
|
||||||
}
|
}
|
||||||
// not really a fan of this, but meh.
|
// not really a fan of this, but meh.
|
||||||
$optionalDateFields = [
|
$optionalDateFields = [
|
||||||
'interest_date' => $optionalFields['interest_date'] ?? false,
|
'interest_date' => $optionalFields['interest_date'] ?? false,
|
||||||
'book_date' => $optionalFields['book_date'] ?? false,
|
'book_date' => $optionalFields['book_date'] ?? false,
|
||||||
'process_date' => $optionalFields['process_date'] ?? false,
|
'process_date' => $optionalFields['process_date'] ?? false,
|
||||||
@@ -132,6 +132,13 @@ class CreateController extends Controller
|
|||||||
];
|
];
|
||||||
$optionalFields['external_url'] ??= false;
|
$optionalFields['external_url'] ??= false;
|
||||||
$optionalFields['location'] ??= 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);
|
session()->put('preFilled', $preFilled);
|
||||||
|
|
||||||
return view(
|
return view(
|
||||||
@@ -139,6 +146,9 @@ class CreateController extends Controller
|
|||||||
compact(
|
compact(
|
||||||
'subTitleIcon',
|
'subTitleIcon',
|
||||||
'cash',
|
'cash',
|
||||||
|
'longitude',
|
||||||
|
'latitude',
|
||||||
|
'zoomLevel',
|
||||||
'objectType',
|
'objectType',
|
||||||
'optionalDateFields',
|
'optionalDateFields',
|
||||||
'subTitle',
|
'subTitle',
|
||||||
|
@@ -210,8 +210,10 @@ return [
|
|||||||
'amount_exactly' => ['alias' => true, 'alias_for' => 'amount_is', 'needs_context' => true],
|
'amount_exactly' => ['alias' => true, 'alias_for' => 'amount_is', 'needs_context' => true],
|
||||||
'amount_less' => ['alias' => false, 'needs_context' => true],
|
'amount_less' => ['alias' => false, 'needs_context' => true],
|
||||||
'amount_max' => ['alias' => true, 'alias_for' => 'amount_less', '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_more' => ['alias' => false, 'needs_context' => true],
|
||||||
'amount_min' => ['alias' => true, 'alias_for' => 'amount_more', '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_is' => ['alias' => false, 'needs_context' => true],
|
||||||
'foreign_amount' => ['alias' => true, 'alias_for' => 'foreign_amount_is', 'needs_context' => true],
|
'foreign_amount' => ['alias' => true, 'alias_for' => 'foreign_amount_is', 'needs_context' => true],
|
||||||
'foreign_amount_less' => ['alias' => false, 'needs_context' => true],
|
'foreign_amount_less' => ['alias' => false, 'needs_context' => true],
|
||||||
|
@@ -46,6 +46,8 @@ import {
|
|||||||
} from "./shared/autocomplete-functions.js";
|
} from "./shared/autocomplete-functions.js";
|
||||||
import {processAttachments} from "./shared/process-attachments.js";
|
import {processAttachments} from "./shared/process-attachments.js";
|
||||||
import {spliceErrorsIntoTransactions} from "./shared/splice-errors-into-transactions.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 upload attachments to other file
|
||||||
// TODO fix two maps, perhaps disconnect from entries entirely.
|
// TODO fix two maps, perhaps disconnect from entries entirely.
|
||||||
@@ -487,22 +489,31 @@ let transactions = function () {
|
|||||||
},
|
},
|
||||||
addSplit() {
|
addSplit() {
|
||||||
this.entries.push(createEmptySplit());
|
this.entries.push(createEmptySplit());
|
||||||
// setTimeout(() => {
|
|
||||||
// // render tags:
|
setTimeout(() => {
|
||||||
// Tags.init('select.ac-tags', {
|
// render tags:
|
||||||
// allowClear: true,
|
Tags.init('select.ac-tags', {
|
||||||
// server: urls.tag,
|
allowClear: true,
|
||||||
// liveServer: true,
|
server: urls.tag,
|
||||||
// clearEnd: true,
|
liveServer: true,
|
||||||
// allowNew: true,
|
clearEnd: true,
|
||||||
// notFoundMessage: '(nothing found)',
|
allowNew: true,
|
||||||
// noCache: true,
|
notFoundMessage: i18n.t('firefly.nothing_found'),
|
||||||
// fetchOptions: {
|
noCache: true,
|
||||||
// headers: {
|
fetchOptions: {
|
||||||
// 'X-CSRF-TOKEN': document.head.querySelector('meta[name="csrf-token"]').content
|
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;
|
// 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);
|
||||||
//
|
//
|
||||||
|
@@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
let maps = [];
|
||||||
|
|
||||||
|
export function addLocation(index) {
|
||||||
|
console.log('add location to index ' + index);
|
||||||
|
if(typeof maps[index] === 'undefined') {
|
||||||
|
console.log('no map yet at index ' + index + ' (location_map_' + index + ')');
|
||||||
|
let holder = document.getElementById('location_map_' + index);
|
||||||
|
//console.log(holder.dataset.longitude);
|
||||||
|
// holder.dataset('latitude');
|
||||||
|
// console.log(holder.dataset('latitude'));
|
||||||
|
maps[index] = L.map(holder).setView([holder.dataset.latitude, holder.dataset.longitude], holder.dataset.zoomLevel);
|
||||||
|
|
||||||
|
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
|
maxZoom: 19,
|
||||||
|
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||||
|
}).addTo(maps[index]);
|
||||||
|
// 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: '© <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);
|
||||||
|
}
|
||||||
|
}
|
@@ -2267,6 +2267,7 @@ return [
|
|||||||
'average' => 'Average',
|
'average' => 'Average',
|
||||||
'balanceFor' => 'Balance for :name',
|
'balanceFor' => 'Balance for :name',
|
||||||
'no_tags' => '(no tags)',
|
'no_tags' => '(no tags)',
|
||||||
|
'nothing_found' => '(nothing found)',
|
||||||
|
|
||||||
// piggy banks:
|
// piggy banks:
|
||||||
'event_history' => 'Event history',
|
'event_history' => 'Event history',
|
||||||
|
@@ -4,7 +4,11 @@
|
|||||||
<em title="{{ __('firefly.location') }}" class="fa-solid fa-earth-europe"></em>
|
<em title="{{ __('firefly.location') }}" class="fa-solid fa-earth-europe"></em>
|
||||||
</label>
|
</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<div :id="'location_map_' + index" style="height:300px;" :data-index="index"></div>
|
<div
|
||||||
|
data-latitude="{{ $latitude }}"
|
||||||
|
data-longitude="{{ $longitude }}"
|
||||||
|
data-zoom-level="{{ $zoomLevel }}"
|
||||||
|
:id="'location_map_' + index" style="height:300px;" :data-index="index"></div>
|
||||||
<span class="muted small">
|
<span class="muted small">
|
||||||
<template x-if="!transaction.hasLocation">
|
<template x-if="!transaction.hasLocation">
|
||||||
<span>{{ __('firefly.click_tap_location') }}</span>
|
<span>{{ __('firefly.click_tap_location') }}</span>
|
||||||
|
@@ -10,7 +10,12 @@
|
|||||||
<x-transaction-tab-list></x-transaction-tab-list>
|
<x-transaction-tab-list></x-transaction-tab-list>
|
||||||
<div class="tab-content" id="splitTabsContent">
|
<div class="tab-content" id="splitTabsContent">
|
||||||
<template x-for="transaction,index in entries">
|
<template x-for="transaction,index in entries">
|
||||||
<x-transaction-split :optionalFields="$optionalFields" :optionalDateFields="$optionalDateFields"></x-transaction-split>
|
<x-transaction-split
|
||||||
|
:zoomLevel="$zoomLevel"
|
||||||
|
:latitude="$latitude"
|
||||||
|
:longitude="$longitude"
|
||||||
|
:optionalFields="$optionalFields"
|
||||||
|
:optionalDateFields="$optionalDateFields"></x-transaction-split>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
Reference in New Issue
Block a user