mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 09:52:20 +00:00
Finalize create transaction form.
This commit is contained in:
1
public/build/assets/create-409a9a86.js
Normal file
1
public/build/assets/create-409a9a86.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
|||||||
import{d as l,g as i,l as r}from"./load-translations-23553922.js";import{I as s}from"./vendor-e194ad60.js";let t,d=function(){return{entries:[],init(){Promise.all([i("language","en_US")]).then(e=>{t=new s;const o=e[0].replace("-","_");t.locale=o,r(t,o).then(()=>{})})}}},a={transactions:d,dates:l};function n(){Object.keys(a).forEach(e=>{console.log(`Loading page component "${e}"`);let o=a[e]();Alpine.data(e,()=>o)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),n()});window.bootstrapped&&(console.log("Loaded through window variable."),n());
|
import{d as l,g as i,l as r}from"./load-translations-9dfbf635.js";import{I as s}from"./vendor-97200597.js";let t,d=function(){return{entries:[],init(){Promise.all([i("language","en_US")]).then(e=>{t=new s;const o=e[0].replace("-","_");t.locale=o,r(t,o).then(()=>{})})}}},a={transactions:d,dates:l};function n(){Object.keys(a).forEach(e=>{console.log(`Loading page component "${e}"`);let o=a[e]();Alpine.data(e,()=>o)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{console.log("Loaded through event listener."),n()});window.bootstrapped&&(console.log("Loaded through window variable."),n());
|
||||||
@@ -1 +1 @@
|
|||||||
import{a as r}from"./load-translations-23553922.js";function i(s,a){let t=window.__localeId__.replace("_","-");return Intl.NumberFormat(t,{style:"currency",currency:a}).format(s)}let p=class{list(a){return r.get("/api/v2/subscriptions",{params:a})}paid(a){return r.get("/api/v2/subscriptions/sum/paid",{params:a})}unpaid(a){return r.get("/api/v2/subscriptions/sum/unpaid",{params:a})}};class u{list(a){return r.get("/api/v2/piggy-banks",{params:a})}}export{p as G,u as a,i as f};
|
import{a as r}from"./load-translations-9dfbf635.js";function i(s,a){let t=window.__localeId__.replace("_","-");return Intl.NumberFormat(t,{style:"currency",currency:a}).format(s)}let p=class{list(a){return r.get("/api/v2/subscriptions",{params:a})}paid(a){return r.get("/api/v2/subscriptions/sum/paid",{params:a})}unpaid(a){return r.get("/api/v2/subscriptions/sum/unpaid",{params:a})}};class u{list(a){return r.get("/api/v2/piggy-banks",{params:a})}}export{p as G,u as a,i as f};
|
||||||
File diff suppressed because one or more lines are too long
1
public/build/assets/load-translations-9dfbf635.js
Normal file
1
public/build/assets/load-translations-9dfbf635.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"_get-748a816c.js": {
|
"_get-35a1642f.js": {
|
||||||
"file": "assets/get-748a816c.js",
|
"file": "assets/get-35a1642f.js",
|
||||||
"imports": [
|
"imports": [
|
||||||
"_load-translations-23553922.js"
|
"_load-translations-9dfbf635.js"
|
||||||
],
|
],
|
||||||
"integrity": "sha384-Q/jXZc5hCLcwX4RjNVIgz80TzISFu81Li1iE5ZNuARydr2CNLRxyl+RFkOj46dPc"
|
"integrity": "sha384-BEa5VVZeih2xh4PjZUO97mCQa3xQaqfJcN7vbBdx7E7UXOQu8naa5/GTkpqhuIWb"
|
||||||
},
|
},
|
||||||
"_load-translations-23553922.js": {
|
"_load-translations-9dfbf635.js": {
|
||||||
"file": "assets/load-translations-23553922.js",
|
"file": "assets/load-translations-9dfbf635.js",
|
||||||
"imports": [
|
"imports": [
|
||||||
"_vendor-e194ad60.js"
|
"_vendor-97200597.js"
|
||||||
],
|
],
|
||||||
"integrity": "sha384-pNfWxxe1sV2bLDoKsEg3oGRBm8+DLQ9lmeL4oFpBJBRNUWOUEfAXp0iYoZMT2hPh"
|
"integrity": "sha384-1Co07smilqsxPLnUynKQLLj4Wk+b19/DP6FWySWLQQaY27nZ1RtDoaCPUu4pY8Q/"
|
||||||
},
|
},
|
||||||
"_vendor-e194ad60.js": {
|
"_vendor-97200597.js": {
|
||||||
"assets": [
|
"assets": [
|
||||||
"assets/layers-1dbbe9d0.png",
|
"assets/layers-1dbbe9d0.png",
|
||||||
"assets/layers-2x-066daca8.png",
|
"assets/layers-2x-066daca8.png",
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
"css": [
|
"css": [
|
||||||
"assets/vendor-49001d3f.css"
|
"assets/vendor-49001d3f.css"
|
||||||
],
|
],
|
||||||
"file": "assets/vendor-e194ad60.js",
|
"file": "assets/vendor-97200597.js",
|
||||||
"integrity": "sha384-pBeK5qr0qG0MDsIfi2/X7NE5V+YUERUHOGDEL5JCGFtw8l+EiRe7D2uuMKV4/cxm"
|
"integrity": "sha384-p3/nuBVJT3mcAGf7EsH1MjtWO1bxn5euKI3XKEt5TjLKZ9q1uq82P2OAEASLhlCk"
|
||||||
},
|
},
|
||||||
"node_modules/@fortawesome/fontawesome-free/webfonts/fa-brands-400.ttf": {
|
"node_modules/@fortawesome/fontawesome-free/webfonts/fa-brands-400.ttf": {
|
||||||
"file": "assets/fa-brands-400-5656d596.ttf",
|
"file": "assets/fa-brands-400-5656d596.ttf",
|
||||||
@@ -71,36 +71,36 @@
|
|||||||
"integrity": "sha384-wg83fCOXjBtqzFAWhTL9Sd9vmLUNhfEEzfmNUX9zwv2igKlz/YQbdapF4ObdxF+R"
|
"integrity": "sha384-wg83fCOXjBtqzFAWhTL9Sd9vmLUNhfEEzfmNUX9zwv2igKlz/YQbdapF4ObdxF+R"
|
||||||
},
|
},
|
||||||
"resources/assets/v2/pages/dashboard/dashboard.js": {
|
"resources/assets/v2/pages/dashboard/dashboard.js": {
|
||||||
"file": "assets/dashboard-a55f7472.js",
|
"file": "assets/dashboard-4afa5a98.js",
|
||||||
"imports": [
|
"imports": [
|
||||||
"_load-translations-23553922.js",
|
"_load-translations-9dfbf635.js",
|
||||||
"_get-748a816c.js",
|
"_get-35a1642f.js",
|
||||||
"_vendor-e194ad60.js"
|
"_vendor-97200597.js"
|
||||||
],
|
],
|
||||||
"isEntry": true,
|
"isEntry": true,
|
||||||
"src": "resources/assets/v2/pages/dashboard/dashboard.js",
|
"src": "resources/assets/v2/pages/dashboard/dashboard.js",
|
||||||
"integrity": "sha384-4VlBovrF9JYeq8ywA4F+J+x+Rs9OIUKgZNtQuZz+F9XADHlvdaegrAx+MLmFc4zX"
|
"integrity": "sha384-jTx6wOomQpWwYjVUUeE6u/LGq0/zFbYp0pgKXNkzhicFT48r7KCI+G9+9/4hL0Ps"
|
||||||
},
|
},
|
||||||
"resources/assets/v2/pages/transactions/create.js": {
|
"resources/assets/v2/pages/transactions/create.js": {
|
||||||
"file": "assets/create-77b1cf47.js",
|
"file": "assets/create-409a9a86.js",
|
||||||
"imports": [
|
"imports": [
|
||||||
"_load-translations-23553922.js",
|
"_load-translations-9dfbf635.js",
|
||||||
"_vendor-e194ad60.js",
|
"_vendor-97200597.js",
|
||||||
"_get-748a816c.js"
|
"_get-35a1642f.js"
|
||||||
],
|
],
|
||||||
"isEntry": true,
|
"isEntry": true,
|
||||||
"src": "resources/assets/v2/pages/transactions/create.js",
|
"src": "resources/assets/v2/pages/transactions/create.js",
|
||||||
"integrity": "sha384-sUxpvAj5i3XiHoRluzCByokIDbqnDMb4gjxDxArjYodV3ymR2O9atDpCZtEBJshw"
|
"integrity": "sha384-hv2wsCs+Sl8+Uee2ivc9mBt9HCp5VuTuBBLOFrdde+Z63VMAcTnNDv2eUGYynBvI"
|
||||||
},
|
},
|
||||||
"resources/assets/v2/pages/transactions/edit.js": {
|
"resources/assets/v2/pages/transactions/edit.js": {
|
||||||
"file": "assets/edit-83707812.js",
|
"file": "assets/edit-81edf6b9.js",
|
||||||
"imports": [
|
"imports": [
|
||||||
"_load-translations-23553922.js",
|
"_load-translations-9dfbf635.js",
|
||||||
"_vendor-e194ad60.js"
|
"_vendor-97200597.js"
|
||||||
],
|
],
|
||||||
"isEntry": true,
|
"isEntry": true,
|
||||||
"src": "resources/assets/v2/pages/transactions/edit.js",
|
"src": "resources/assets/v2/pages/transactions/edit.js",
|
||||||
"integrity": "sha384-UkvRogZBJfe4zy9IAmFghhsyJfzcml29moISocvNyF1ujn+Op54PwrMYf5plap6Y"
|
"integrity": "sha384-0S1UAURUA6sHltypKX30GvPla6lpIJdspvfdmXYu6mGO+D4XgdPhW7TI6BvD6aCs"
|
||||||
},
|
},
|
||||||
"resources/assets/v2/sass/app.scss": {
|
"resources/assets/v2/sass/app.scss": {
|
||||||
"file": "assets/app-fb7b26ec.css",
|
"file": "assets/app-fb7b26ec.css",
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ import {loadBudgets} from "./shared/load-budgets.js";
|
|||||||
import {loadPiggyBanks} from "./shared/load-piggy-banks.js";
|
import {loadPiggyBanks} from "./shared/load-piggy-banks.js";
|
||||||
import {loadSubscriptions} from "./shared/load-subscriptions.js";
|
import {loadSubscriptions} from "./shared/load-subscriptions.js";
|
||||||
|
|
||||||
import L from "leaflet";
|
|
||||||
|
|
||||||
import 'leaflet/dist/leaflet.css';
|
import 'leaflet/dist/leaflet.css';
|
||||||
import {addAutocomplete} from "./shared/add-autocomplete.js";
|
import {addAutocomplete} from "./shared/add-autocomplete.js";
|
||||||
import {
|
import {
|
||||||
@@ -85,8 +83,7 @@ let transactions = function () {
|
|||||||
|
|
||||||
// form behaviour during transaction
|
// form behaviour during transaction
|
||||||
formBehaviour: {
|
formBehaviour: {
|
||||||
formType: 'create',
|
formType: 'create', foreignCurrencyEnabled: true,
|
||||||
foreignCurrencyEnabled: true,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// form data (except transactions) is stored in formData
|
// form data (except transactions) is stored in formData
|
||||||
@@ -102,27 +99,17 @@ let transactions = function () {
|
|||||||
|
|
||||||
// properties for the entire transaction group
|
// properties for the entire transaction group
|
||||||
groupProperties: {
|
groupProperties: {
|
||||||
transactionType: 'unknown',
|
transactionType: 'unknown', title: null, id: null, totalAmount: 0,
|
||||||
title: null,
|
|
||||||
id: null,
|
|
||||||
totalAmount: 0,
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// notifications
|
// notifications
|
||||||
notifications: {
|
notifications: {
|
||||||
error: {
|
error: {
|
||||||
show: false,
|
show: false, text: '', url: '',
|
||||||
text: '',
|
}, success: {
|
||||||
url: '',
|
show: false, text: '', url: '',
|
||||||
},
|
}, wait: {
|
||||||
success: {
|
show: false, text: '',
|
||||||
show: false,
|
|
||||||
text: '',
|
|
||||||
url: '',
|
|
||||||
},
|
|
||||||
wait: {
|
|
||||||
show: false,
|
|
||||||
text: '',
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -130,35 +117,22 @@ let transactions = function () {
|
|||||||
|
|
||||||
// part of the account selection auto-complete
|
// part of the account selection auto-complete
|
||||||
filters: {
|
filters: {
|
||||||
source: [],
|
source: [], destination: [],
|
||||||
destination: [],
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// old properties, no longer used.
|
|
||||||
|
|
||||||
|
|
||||||
// data sets
|
|
||||||
|
|
||||||
// used to display the success message
|
|
||||||
//newGroupTitle: '',
|
|
||||||
//newGroupId: 0,
|
|
||||||
|
|
||||||
// map things:
|
|
||||||
//hasLocation: false,
|
|
||||||
//latitude: 51.959659235274,
|
|
||||||
//longitude: 5.756805887265858,
|
|
||||||
//zoomLevel: 13,
|
|
||||||
|
|
||||||
// events in the form
|
// events in the form
|
||||||
changedDateTime(event) {
|
changedDateTime(event) {
|
||||||
console.log('changedDateTime');
|
console.warn('changedDateTime, event is not used');
|
||||||
},
|
},
|
||||||
|
|
||||||
changedDescription(event) {
|
changedDescription(event) {
|
||||||
console.log('changedDescription');
|
console.warn('changedDescription, event is not used');
|
||||||
},
|
},
|
||||||
|
|
||||||
changedDestinationAccount(event) {
|
changedDestinationAccount(event) {
|
||||||
this.detectTransactionType();
|
this.detectTransactionType();
|
||||||
},
|
},
|
||||||
|
|
||||||
changedSourceAccount(event) {
|
changedSourceAccount(event) {
|
||||||
this.detectTransactionType();
|
this.detectTransactionType();
|
||||||
},
|
},
|
||||||
@@ -218,8 +192,9 @@ let transactions = function () {
|
|||||||
}
|
}
|
||||||
console.warn('Unknown account combination between "' + sourceType + '" and "' + destType + '".');
|
console.warn('Unknown account combination between "' + sourceType + '" and "' + destType + '".');
|
||||||
},
|
},
|
||||||
|
|
||||||
formattedTotalAmount() {
|
formattedTotalAmount() {
|
||||||
if(this.entries.length === 0) {
|
if (this.entries.length === 0) {
|
||||||
return formatMoney(this.groupProperties.totalAmount, 'EUR');
|
return formatMoney(this.groupProperties.totalAmount, 'EUR');
|
||||||
}
|
}
|
||||||
return formatMoney(this.groupProperties.totalAmount, this.entries[0].currency_code ?? 'EUR');
|
return formatMoney(this.groupProperties.totalAmount, this.entries[0].currency_code ?? 'EUR');
|
||||||
@@ -255,6 +230,7 @@ let transactions = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
filterNativeCurrencies(code) {
|
filterNativeCurrencies(code) {
|
||||||
let list = [];
|
let list = [];
|
||||||
let currency;
|
let currency;
|
||||||
@@ -276,6 +252,7 @@ let transactions = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
changedAmount(e) {
|
changedAmount(e) {
|
||||||
const index = parseInt(e.target.dataset.index);
|
const index = parseInt(e.target.dataset.index);
|
||||||
this.entries[index].amount = parseFloat(e.target.value);
|
this.entries[index].amount = parseFloat(e.target.value);
|
||||||
@@ -287,7 +264,6 @@ let transactions = function () {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
addedSplit() {
|
addedSplit() {
|
||||||
// addedSplit, is called from the HTML
|
// addedSplit, is called from the HTML
|
||||||
// for source account
|
// for source account
|
||||||
@@ -329,9 +305,11 @@ let transactions = function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
processUpload(event) {
|
processUpload(event) {
|
||||||
this.showMessageOrRedirectUser();
|
this.showMessageOrRedirectUser();
|
||||||
},
|
},
|
||||||
|
|
||||||
processUploadError(event) {
|
processUploadError(event) {
|
||||||
this.notifications.success.show = false;
|
this.notifications.success.show = false;
|
||||||
this.notifications.wait.show = false;
|
this.notifications.wait.show = false;
|
||||||
@@ -382,12 +360,30 @@ let transactions = function () {
|
|||||||
document.addEventListener('upload-error', (event) => {
|
document.addEventListener('upload-error', (event) => {
|
||||||
this.processUploadError(event);
|
this.processUploadError(event);
|
||||||
});
|
});
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// source can never be expense account
|
// source can never be expense account
|
||||||
this.filters.source = ['Asset account', 'Loan', 'Debt', 'Mortgage', 'Revenue account'];
|
this.filters.source = ['Asset account', 'Loan', 'Debt', 'Mortgage', 'Revenue account'];
|
||||||
// destination can never be revenue account
|
// destination can never be revenue account
|
||||||
this.filters.destination = ['Expense account', 'Loan', 'Debt', 'Mortgage', 'Asset account'];
|
this.filters.destination = ['Expense account', 'Loan', 'Debt', 'Mortgage', 'Asset account'];
|
||||||
},
|
},
|
||||||
|
|
||||||
submitTransaction() {
|
submitTransaction() {
|
||||||
// reset all messages:
|
// reset all messages:
|
||||||
this.notifications.error.show = false;
|
this.notifications.error.show = false;
|
||||||
@@ -454,6 +450,7 @@ let transactions = function () {
|
|||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
showMessageOrRedirectUser() {
|
showMessageOrRedirectUser() {
|
||||||
// disable all messages:
|
// disable all messages:
|
||||||
this.notifications.error.show = false;
|
this.notifications.error.show = false;
|
||||||
@@ -475,6 +472,7 @@ let transactions = function () {
|
|||||||
}
|
}
|
||||||
window.location = 'transactions/show/' + this.groupProperties.id + '?transaction_group_id=' + this.groupProperties.id + '&message=created';
|
window.location = 'transactions/show/' + this.groupProperties.id + '?transaction_group_id=' + this.groupProperties.id + '&message=created';
|
||||||
},
|
},
|
||||||
|
|
||||||
parseErrors(data) {
|
parseErrors(data) {
|
||||||
// disable all messages:
|
// disable all messages:
|
||||||
this.notifications.error.show = true;
|
this.notifications.error.show = true;
|
||||||
@@ -483,10 +481,11 @@ let transactions = function () {
|
|||||||
this.formStates.isSubmitting = false;
|
this.formStates.isSubmitting = false;
|
||||||
this.notifications.error.text = i18n.t('firefly.errors_submission', {errorMessage: data.message});
|
this.notifications.error.text = i18n.t('firefly.errors_submission', {errorMessage: data.message});
|
||||||
|
|
||||||
if(data.hasOwnProperty('errors')) {
|
if (data.hasOwnProperty('errors')) {
|
||||||
this.entries = spliceErrorsIntoTransactions(i18n, data.errors, this.entries);
|
this.entries = spliceErrorsIntoTransactions(i18n, data.errors, this.entries);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
addSplit() {
|
addSplit() {
|
||||||
this.entries.push(createEmptySplit());
|
this.entries.push(createEmptySplit());
|
||||||
|
|
||||||
@@ -506,87 +505,39 @@ let transactions = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
console.log('in set timeout.');
|
|
||||||
const count = this.entries.length - 1;
|
const count = this.entries.length - 1;
|
||||||
if(document.querySelector('#location_map_' + count)) {
|
// if(document.querySelector('#location_map_' + count)) { }
|
||||||
addLocation(count);
|
addLocation(count);
|
||||||
}
|
}, 150);
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// const count = this.entries.length - 1;
|
|
||||||
// let map = L.map('location_map_' + count).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 ' + count + '</a>'
|
|
||||||
// }).addTo(map);
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
removeSplit(index) {
|
removeSplit(index) {
|
||||||
this.entries.splice(index, 1);
|
this.entries.splice(index, 1);
|
||||||
// fall back to index 0
|
// fall back to index 0
|
||||||
const triggerFirstTabEl = document.querySelector('#split-0-tab')
|
const triggerFirstTabEl = document.querySelector('#split-0-tab')
|
||||||
triggerFirstTabEl.click();
|
triggerFirstTabEl.click();
|
||||||
},
|
},
|
||||||
|
|
||||||
clearLocation(e) {
|
clearLocation(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
// remove location from entry, fire event, do nothing else (the map is somebody else's problem).
|
||||||
|
|
||||||
const target = e.currentTarget;
|
const target = e.currentTarget;
|
||||||
const index = parseInt(target.attributes['data-index'].value);
|
const index = parseInt(target.attributes['data-index'].value);
|
||||||
this.entries[index].hasLocation = false;
|
this.entries[index].hasLocation = false;
|
||||||
this.entries[index].marker.remove();
|
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;
|
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,40 +18,82 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import L from "leaflet";
|
||||||
|
|
||||||
let maps = [];
|
let maps = [];
|
||||||
|
let markers = [];
|
||||||
|
|
||||||
export function addLocation(index) {
|
// listen to event to remove marker:
|
||||||
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', {
|
// location-remove
|
||||||
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;
|
document.addEventListener('location-remove', (event) => {
|
||||||
// const map = () => {
|
markers[event.detail.index].remove();
|
||||||
// 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);
|
|
||||||
|
function addPointToMap(e) {
|
||||||
|
// index is always 0.
|
||||||
|
// let index = parseInt(e.originalEvent.currentTarget.attributes['data-index'].value);
|
||||||
|
let index = 0;
|
||||||
|
let hasLocation = document.querySelector('#form')._x_dataStack[0].$data.entries[index].hasLocation;
|
||||||
|
|
||||||
|
if (false === hasLocation) {
|
||||||
|
markers[index] = new L.marker(e.latlng, {draggable: true});
|
||||||
|
markers[index].on('dragend', dragEnd);
|
||||||
|
markers[index].addTo(maps[index]);
|
||||||
|
|
||||||
|
const setEvent = new CustomEvent('location-set', {detail: {
|
||||||
|
latitude: e.latlng.lat,
|
||||||
|
longitude: e.latlng.lng,
|
||||||
|
index: index,
|
||||||
|
zoomLevel: maps[index].getZoom()
|
||||||
|
}});
|
||||||
|
document.dispatchEvent(setEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function saveZoomOfMap(e) {
|
||||||
|
//let index = parseInt(e.sourceTarget._container.attributes['data-index'].value);
|
||||||
|
let index = 0;
|
||||||
|
const zoomEvent = new CustomEvent('location-zoom', {detail: {
|
||||||
|
index: index,
|
||||||
|
zoomLevel: maps[index].getZoom()
|
||||||
|
}});
|
||||||
|
document.dispatchEvent(zoomEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
function dragEnd(event) {
|
||||||
|
let marker = event.target;
|
||||||
|
let position = marker.getLatLng();
|
||||||
|
marker.setLatLng(new L.LatLng(position.lat, position.lng), {draggable: 'true'});
|
||||||
|
const moveEvent = new CustomEvent('location-move', {
|
||||||
|
detail: {
|
||||||
|
latitude: position.lat,
|
||||||
|
longitude: position.lng,
|
||||||
|
index: 0
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.dispatchEvent(moveEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addLocation(index) {
|
||||||
|
if (index > 0) {
|
||||||
|
console.warn('Corwardly refuse to add a map on split #' + (index + 1));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof maps[index] === 'undefined') {
|
||||||
|
// map holder is always the same:
|
||||||
|
|
||||||
|
//let holder = document.getElementById('location_map_' + index);
|
||||||
|
let holder = document.getElementById('location_map');
|
||||||
|
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]);
|
||||||
|
maps[index].on('click', addPointToMap);
|
||||||
|
maps[index].on('zoomend', saveZoomOfMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,15 +1,21 @@
|
|||||||
@if(true === $optionalFields['location'])
|
@if(true === $optionalFields['location'])
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<label :for="'map_' + index" class="col-sm-1 col-form-label d-none d-sm-block">
|
<label :for="'map_' + index" class="col-sm-1 col-form-label d-none d-sm-block">
|
||||||
<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">
|
<template x-if="index > 0">
|
||||||
<div
|
<div class="col-sm-10">
|
||||||
data-latitude="{{ $latitude }}"
|
<label class="custom-control-label small">{{ __('firefly.location_first_split') }}</label>
|
||||||
data-longitude="{{ $longitude }}"
|
</div>
|
||||||
data-zoom-level="{{ $zoomLevel }}"
|
</template>
|
||||||
:id="'location_map_' + index" style="height:300px;" :data-index="index"></div>
|
<template x-if="0 === index">
|
||||||
<span class="muted small">
|
<div class="col-sm-10">
|
||||||
|
<div
|
||||||
|
data-latitude="{{ $latitude }}"
|
||||||
|
data-longitude="{{ $longitude }}"
|
||||||
|
data-zoom-level="{{ $zoomLevel }}"
|
||||||
|
id="location_map" style="height:300px;" :data-index="index"></div>
|
||||||
|
<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>
|
||||||
</template>
|
</template>
|
||||||
@@ -17,6 +23,7 @@
|
|||||||
<a :data-index="index" href="#" @click="clearLocation">{{ __('firefly.clear_location') }}</a>
|
<a :data-index="index" href="#" @click="clearLocation">{{ __('firefly.clear_location') }}</a>
|
||||||
</template>
|
</template>
|
||||||
</span>
|
</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
@endif
|
@endif
|
||||||
|
|||||||
Reference in New Issue
Block a user