mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-25 21:16:47 +00:00
Code for new release.
This commit is contained in:
@@ -148,10 +148,10 @@
|
||||
"list": {
|
||||
"active": "\u00c4r aktiv?",
|
||||
"trigger": "Trigger",
|
||||
"response": "Response",
|
||||
"delivery": "Delivery",
|
||||
"response": "Svar",
|
||||
"delivery": "Leverans",
|
||||
"url": "URL",
|
||||
"secret": "Secret"
|
||||
"secret": "Hemlighet"
|
||||
},
|
||||
"config": {
|
||||
"html_language": "sv",
|
||||
|
||||
@@ -36,6 +36,11 @@ import {I18n} from "i18n-js";
|
||||
import {loadTranslations} from "../../support/load-translations.js";
|
||||
import Tags from "bootstrap5-tags";
|
||||
|
||||
import L from "leaflet";
|
||||
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
|
||||
|
||||
let i18n;
|
||||
|
||||
const urls = {
|
||||
@@ -181,6 +186,7 @@ let transactions = function () {
|
||||
budgets: [],
|
||||
piggyBanks: {},
|
||||
subscriptions: [],
|
||||
dateFields: ['interest_date','book_date','process_date','due_date','payment_date','invoice_date'],
|
||||
|
||||
foreignAmountEnabled: true,
|
||||
filters: {
|
||||
@@ -207,6 +213,12 @@ let transactions = function () {
|
||||
newGroupTitle: '',
|
||||
newGroupId: 0,
|
||||
|
||||
// map things:
|
||||
hasLocation: false,
|
||||
latitude: 51.959659235274,
|
||||
longitude: 5.756805887265858,
|
||||
zoomLevel: 13,
|
||||
|
||||
|
||||
detectTransactionType() {
|
||||
const sourceType = this.entries[0].source_account.type ?? 'unknown';
|
||||
@@ -792,6 +804,7 @@ let transactions = function () {
|
||||
addSplit() {
|
||||
this.entries.push(createEmptySplit());
|
||||
setTimeout(() => {
|
||||
// render tags:
|
||||
Tags.init('select.ac-tags', {
|
||||
allowClear: true,
|
||||
server: urls.tag,
|
||||
@@ -805,6 +818,16 @@ let transactions = function () {
|
||||
}
|
||||
}
|
||||
});
|
||||
const count = this.entries.length - 1;
|
||||
this.entries[count].map = L.map('mappie').setView([this.latitude, this.longitude], this.zoomLevel);
|
||||
|
||||
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
maxZoom: 19,
|
||||
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
}).addTo(this.entries[count].map);
|
||||
this.entries[count].map.on('click', this.addPointToMap);
|
||||
this.entries[count].map.on('zoomend', this.saveZoomOfMap);
|
||||
|
||||
}, 250);
|
||||
|
||||
},
|
||||
@@ -816,6 +839,52 @@ let transactions = function () {
|
||||
},
|
||||
formattedTotalAmount() {
|
||||
return formatMoney(this.totalAmount, 'EUR');
|
||||
},
|
||||
clearLocation(e) {
|
||||
e.preventDefault();
|
||||
const target = e.currentTarget;
|
||||
const index = parseInt(target.attributes['data-index'].value);
|
||||
this.entries[index].hasLocation = false;
|
||||
this.entries[index].marker.remove();
|
||||
return false;
|
||||
},
|
||||
saveZoomOfMap(e) {
|
||||
let index = parseInt(e.sourceTarget._container.attributes['data-index'].value);
|
||||
let map = document.querySelector('#form')._x_dataStack[0].$data.entries[index].map;
|
||||
document.querySelector('#form')._x_dataStack[0].$data.entries[index].zoomLevel = map.getZoom();
|
||||
console.log('New zoom level: ' + map.getZoom());
|
||||
},
|
||||
addPointToMap(e) {
|
||||
let index = parseInt(e.originalEvent.currentTarget.attributes['data-index'].value);
|
||||
let map = document.querySelector('#form')._x_dataStack[0].$data.entries[index].map;
|
||||
let hasLocation = document.querySelector('#form')._x_dataStack[0].$data.entries[index].hasLocation;
|
||||
console.log('Has location: ' + hasLocation);
|
||||
if (false === hasLocation) {
|
||||
console.log('False!');
|
||||
const marker = new L.marker(e.latlng, {draggable: true});
|
||||
marker.on('dragend', function (event) {
|
||||
var marker = event.target;
|
||||
|
||||
var position = marker.getLatLng();
|
||||
marker.setLatLng(new L.LatLng(position.lat, position.lng), {draggable: 'true'});
|
||||
document.querySelector('#form')._x_dataStack[0].$data.entries[index].latitude = position.lat;
|
||||
document.querySelector('#form')._x_dataStack[0].$data.entries[index].longitude = position.lng;
|
||||
});
|
||||
|
||||
marker.addTo(map);
|
||||
document.querySelector('#form')._x_dataStack[0].$data.entries[index].hasLocation = true;
|
||||
document.querySelector('#form')._x_dataStack[0].$data.entries[index].marker = marker;
|
||||
document.querySelector('#form')._x_dataStack[0].$data.entries[index].latitude = e.latlng.lat;
|
||||
document.querySelector('#form')._x_dataStack[0].$data.entries[index].longitude = e.latlng.lng;
|
||||
document.querySelector('#form')._x_dataStack[0].$data.entries[index].zoomLevel = map.getZoom();
|
||||
}
|
||||
//this.entries[index].hasLocation = true;
|
||||
// map.on('click', function (e) {
|
||||
// if (false === this.hasLocation) {
|
||||
// let marker = new L.marker(e.latlng).addTo(map);
|
||||
// this.hasLocation = true;
|
||||
// }
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +49,31 @@ export function createEmptySplit() {
|
||||
budget_id: null,
|
||||
category_name: '',
|
||||
piggy_bank_id: null,
|
||||
bill_id: null,
|
||||
tags: [],
|
||||
notes: '',
|
||||
|
||||
// other meta fields:
|
||||
internal_reference: '',
|
||||
external_url: '',
|
||||
|
||||
// map
|
||||
hasLocation: false,
|
||||
map: null,
|
||||
latitude: null,
|
||||
longitude: null,
|
||||
zoomLevel: null,
|
||||
marker: null,
|
||||
|
||||
|
||||
// date and time
|
||||
date: formatted,
|
||||
interest_date: '',
|
||||
book_date: '',
|
||||
process_date: '',
|
||||
due_date: '',
|
||||
payment_date: '',
|
||||
invoice_date: '',
|
||||
|
||||
errors: {
|
||||
'amount': [],
|
||||
|
||||
@@ -43,19 +43,32 @@ export function parseFromEntries(entries, transactionType) {
|
||||
|
||||
// dates
|
||||
current.date = entry.date;
|
||||
current.interest_date = entry.interest_date;
|
||||
current.book_date = entry.book_date;
|
||||
current.process_date = entry.process_date;
|
||||
current.due_date = entry.due_date;
|
||||
current.payment_date = entry.payment_date;
|
||||
current.invoice_date = entry.invoice_date;
|
||||
|
||||
// meta
|
||||
current.budget_id = entry.budget_id;
|
||||
current.category_name = entry.category_name;
|
||||
current.piggy_bank_id = entry.piggy_bank_id;
|
||||
|
||||
// location
|
||||
if (entry.hasLocation) {
|
||||
current.longitude = entry.longitude.toString();
|
||||
current.latitude = entry.latitude.toString();
|
||||
current.zoom_level = entry.zoomLevel;
|
||||
}
|
||||
|
||||
// if foreign amount currency code is set:
|
||||
if (typeof entry.foreign_currency_code !== 'undefined' && '' !== entry.foreign_currency_code.toString()) {
|
||||
current.foreign_currency_code = entry.foreign_currency_code;
|
||||
if(typeof entry.foreign_amount !== 'undefined' && '' !== entry.foreign_amount.toString()) {
|
||||
if (typeof entry.foreign_amount !== 'undefined' && '' !== entry.foreign_amount.toString()) {
|
||||
current.foreign_amount = entry.foreign_amount;
|
||||
}
|
||||
if(typeof entry.foreign_amount === 'undefined' || '' === entry.foreign_amount.toString()) {
|
||||
if (typeof entry.foreign_amount === 'undefined' || '' === entry.foreign_amount.toString()) {
|
||||
delete current.foreign_amount;
|
||||
delete current.foreign_currency_code;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user