mirror of
https://github.com/KevinMidboe/nova-map-fields.git
synced 2025-10-29 17:50:27 +00:00
Linting
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<field-map :center="position" :field="field">
|
||||
<l-marker :lat-lng="position" :draggable="edit" @dragend="onDragEnd"/>
|
||||
<l-marker :lat-lng="position" :draggable="edit" @dragend="onDragEnd" />
|
||||
</field-map>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {LMarker} from 'vue2-leaflet'
|
||||
import { LMarker } from "vue2-leaflet";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -20,13 +20,16 @@ export default {
|
||||
edit: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
position() {
|
||||
return L.latLng(this.value.lat || this.field.map.center.latitude, this.value.lng || this.field.map.center.longitude);
|
||||
}
|
||||
return L.latLng(
|
||||
this.value.lat || this.field.map.center.latitude,
|
||||
this.value.lng || this.field.map.center.longitude
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
mounted() {
|
||||
@@ -37,36 +40,46 @@ export default {
|
||||
onDragEnd(evt) {
|
||||
let latLng = evt.target.getLatLng();
|
||||
|
||||
this.$emit('input', {
|
||||
this.$emit("input", {
|
||||
lat: latLng.lat,
|
||||
lng: latLng.lng,
|
||||
});
|
||||
},
|
||||
|
||||
registerWatchers() {
|
||||
this.getGlobalFieldComponents().forEach(component => {
|
||||
if ([this.field.latitudeField, this.field.longitudeField].includes(component.field.attribute)) {
|
||||
component.$watch('value', (value) => {
|
||||
this.value[component.field.attribute] = value;
|
||||
}, {immediate: true})
|
||||
this.getGlobalFieldComponents().forEach((component) => {
|
||||
if (
|
||||
[
|
||||
this.field.latitudeField,
|
||||
this.field.longitudeField,
|
||||
].includes(component.field.attribute)
|
||||
) {
|
||||
component.$watch(
|
||||
"value",
|
||||
(value) => {
|
||||
this.value[component.field.attribute] = value;
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
getGlobalFieldComponents(components = null) {
|
||||
if (! components) {
|
||||
if (!components) {
|
||||
components = this.$root.$children;
|
||||
}
|
||||
|
||||
let returnArray = [];
|
||||
|
||||
components.forEach(component => {
|
||||
components.forEach((component) => {
|
||||
if (component.field) {
|
||||
return returnArray.push(component);
|
||||
}
|
||||
|
||||
returnArray = returnArray.concat(this.getGlobalFieldComponents(component.$children));
|
||||
returnArray = returnArray.concat(
|
||||
this.getGlobalFieldComponents(component.$children)
|
||||
);
|
||||
});
|
||||
|
||||
return returnArray;
|
||||
@@ -75,6 +88,6 @@ export default {
|
||||
|
||||
components: {
|
||||
LMarker,
|
||||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user