mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 18:41:08 +00:00
Location is submitted and added to the array through events.
This commit is contained in:
@@ -113,6 +113,10 @@ const state = () => ({
|
|||||||
// transaction links:
|
// transaction links:
|
||||||
links: [],
|
links: [],
|
||||||
attachments: [],
|
attachments: [],
|
||||||
|
// location:
|
||||||
|
zoom_level: null,
|
||||||
|
longitude: null,
|
||||||
|
latitude: null,
|
||||||
|
|
||||||
// error handling
|
// error handling
|
||||||
errors: {},
|
errors: {},
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
:custom-fields="customFields"
|
:custom-fields="customFields"
|
||||||
:submitted-transaction="submittedTransaction"
|
:submitted-transaction="submittedTransaction"
|
||||||
v-on:uploaded-attachments="uploadedAttachment($event)"
|
v-on:uploaded-attachments="uploadedAttachment($event)"
|
||||||
|
v-on:set-marker-location="storeLocation(index, $event)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -346,7 +347,14 @@ export default {
|
|||||||
this.submittedAttachments = true;
|
this.submittedAttachments = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
storeLocation: function(index, event) {
|
||||||
|
let zoomLevel = event.hasMarker ? event.zoomLevel : null;
|
||||||
|
let lat = event.hasMarker ? event.lat : null;
|
||||||
|
let lng = event.hasMarker ? event.lng : null;
|
||||||
|
this.updateField({index: index, field: 'zoom_level', value: zoomLevel});
|
||||||
|
this.updateField({index: index, field: 'latitude', value: lat});
|
||||||
|
this.updateField({index: index, field: 'longitude', value: lng});
|
||||||
|
},
|
||||||
submitTransactionLinks(data, response) {
|
submitTransactionLinks(data, response) {
|
||||||
console.log('submitTransactionLinks()');
|
console.log('submitTransactionLinks()');
|
||||||
let promises = [];
|
let promises = [];
|
||||||
@@ -590,6 +598,11 @@ export default {
|
|||||||
notes: array.notes,
|
notes: array.notes,
|
||||||
external_id: array.external_id,
|
external_id: array.external_id,
|
||||||
|
|
||||||
|
// location:
|
||||||
|
zoom_level: array.zoom_level,
|
||||||
|
longitude: array.longitude,
|
||||||
|
latitude: array.latitude,
|
||||||
|
|
||||||
// from thing:
|
// from thing:
|
||||||
order: 0,
|
order: 0,
|
||||||
reconciled: false,
|
reconciled: false,
|
||||||
|
@@ -211,6 +211,7 @@
|
|||||||
:custom-fields.sync="customFields"
|
:custom-fields.sync="customFields"
|
||||||
/>
|
/>
|
||||||
<TransactionLocation
|
<TransactionLocation
|
||||||
|
v-on="$listeners"
|
||||||
:index="index"
|
:index="index"
|
||||||
v-model="transaction.notes"
|
v-model="transaction.notes"
|
||||||
:errors="transaction.errors.location"
|
:errors="transaction.errors.location"
|
||||||
|
@@ -23,19 +23,104 @@
|
|||||||
<div class="text-xs d-none d-lg-block d-xl-block">
|
<div class="text-xs d-none d-lg-block d-xl-block">
|
||||||
{{ $t('firefly.location') }}
|
{{ $t('firefly.location') }}
|
||||||
</div>
|
</div>
|
||||||
<div class="input-group">
|
<div style="width:100%;height:300px;">
|
||||||
(TODO)
|
<l-map
|
||||||
|
style="width:100%;height:300px;"
|
||||||
|
:zoom="zoom"
|
||||||
|
ref="myMap" @ready="prepMap()"
|
||||||
|
:center="center"
|
||||||
|
@update:zoom="zoomUpdated"
|
||||||
|
@update:center="centerUpdated"
|
||||||
|
@update:bounds="boundsUpdated"
|
||||||
|
>
|
||||||
|
<l-tile-layer :url="url"></l-tile-layer>
|
||||||
|
<l-marker :lat-lng="marker" :visible="hasMarker"></l-marker>
|
||||||
|
</l-map>
|
||||||
|
<span>
|
||||||
|
<button class="btn btn-default btn-xs" @click="clearLocation">{{ $t('firefly.clear_location') }}</button>
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
// If you need to reference 'L', such as in 'L.icon', then be sure to
|
||||||
|
// explicitly import 'leaflet' into your component
|
||||||
|
// import L from 'leaflet';
|
||||||
|
import {LMap, LMarker, LTileLayer} from 'vue2-leaflet';
|
||||||
|
import 'leaflet/dist/leaflet.css';
|
||||||
|
|
||||||
|
import L from 'leaflet';
|
||||||
|
|
||||||
|
delete L.Icon.Default.prototype._getIconUrl;
|
||||||
|
|
||||||
|
L.Icon.Default.mergeOptions({
|
||||||
|
iconRetinaUrl: require('leaflet/dist/images/marker-icon-2x.png'),
|
||||||
|
iconUrl: require('leaflet/dist/images/marker-icon.png'),
|
||||||
|
shadowUrl: require('leaflet/dist/images/marker-shadow.png')
|
||||||
|
});
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "TransactionLocation",
|
name: "TransactionLocation",
|
||||||
props: ['index', 'value', 'errors', 'customFields'],
|
props: ['index', 'value', 'errors', 'customFields'],
|
||||||
|
components: {
|
||||||
|
LMap,
|
||||||
|
LTileLayer,
|
||||||
|
LMarker,
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
axios.get('./api/v1/configuration/static/firefly.default_location').then(response => {
|
||||||
|
this.zoom = parseInt(response.data['firefly.default_location'].zoom_level);
|
||||||
|
this.center =
|
||||||
|
[
|
||||||
|
parseFloat(response.data['firefly.default_location'].latitude),
|
||||||
|
parseFloat(response.data['firefly.default_location'].longitude),
|
||||||
|
]
|
||||||
|
;
|
||||||
|
});
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
availableFields: this.customFields
|
availableFields: this.customFields,
|
||||||
|
url: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||||
|
zoom: 3,
|
||||||
|
center: [0, 0],
|
||||||
|
bounds: null,
|
||||||
|
map: null,
|
||||||
|
hasMarker: false,
|
||||||
|
marker: [0, 0],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
prepMap: function () {
|
||||||
|
this.map = this.$refs.myMap.mapObject;
|
||||||
|
this.map.on('contextmenu', this.setObjectLocation);
|
||||||
|
this.map.on('zoomend', this.saveZoomLevel);
|
||||||
|
},
|
||||||
|
setObjectLocation: function (event) {
|
||||||
|
this.marker = [event.latlng.lat, event.latlng.lng];
|
||||||
|
this.hasMarker = true;
|
||||||
|
this.emitEvent();
|
||||||
|
},
|
||||||
|
saveZoomLevel: function () {
|
||||||
|
this.emitEvent();
|
||||||
|
},
|
||||||
|
clearLocation: function () {
|
||||||
|
this.hasMarker = false;
|
||||||
|
this.emitEvent();
|
||||||
|
},
|
||||||
|
emitEvent() {
|
||||||
|
this.$emit('set-marker-location', {zoomLevel: this.zoom, lat: this.marker[0], lng: this.marker[1], hasMarker: this.hasMarker});
|
||||||
|
},
|
||||||
|
zoomUpdated(zoom) {
|
||||||
|
this.zoom = zoom;
|
||||||
|
},
|
||||||
|
centerUpdated(center) {
|
||||||
|
this.center = center;
|
||||||
|
},
|
||||||
|
boundsUpdated(bounds) {
|
||||||
|
this.bounds = bounds;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
Reference in New Issue
Block a user