From b2ddb08374a2b899b33aaf71a6fbd41bcda542c9 Mon Sep 17 00:00:00 2001 From: Keith Paterson Date: Wed, 2 Jun 2021 12:12:52 +0200 Subject: [PATCH] #130 --- src/renderer/components/ParkingEdit.vue | 38 ++++++++++++++----------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/renderer/components/ParkingEdit.vue b/src/renderer/components/ParkingEdit.vue index 4c7065a..60a4294 100644 --- a/src/renderer/components/ParkingEdit.vue +++ b/src/renderer/components/ParkingEdit.vue @@ -177,8 +177,7 @@ :step="0.1" :precision="1" :disabled="!editing || calculate === 'Heading'" - @focus="headingFocussed = true" - @blur="headingFocussed = false" + @change="headingChange" > @@ -245,7 +244,24 @@ const turfOptions = { units: 'kilometers' }; export default { + mounted() { + this.$store.watch( + function (state) { + return state.Editable.data.parking; + }, + () => { this.editedParking() } + , + { + deep: true //add this if u need to watch object properties change etc. + } + ); + }, methods: { + editedParking() { + this.externalChange = true + this.heading = Number(this.$store.state.Editable.data.parking.heading); + this.externalChange = false + }, rotate() { var heading = this.$store.state.Editable.data.parking.heading + 90; while (heading>=360) { @@ -254,9 +270,7 @@ while (heading<0) { heading += 360 } - this.rotateFocussed = true; this.headingChange(heading); - this.rotateFocussed = false; }, headingChange( newValue ) { while (newValue>=360) { @@ -265,8 +279,8 @@ while (newValue<0) { newValue += 360 } - if ( Math.abs( ( this.$store.state.Editable.data.parking.heading - newValue ) >= 0 && Math.abs( this.$store.state.Editable.data.parking.heading - newValue ) <= 0.1 ) - || this.headingFocussed || this.rotateFocussed) { + if ( ( Math.abs( this.$store.state.Editable.data.parking.heading - newValue ) >= 0 && Math.abs( this.$store.state.Editable.data.parking.heading - newValue ) <= 0.1 ) + || !this.externalChange) { if (Number(this.$store.state.Editable.data.parking.heading) !== newValue) { this.$store.commit('SET_EDIT_PARKING_HEADING', newValue) } @@ -331,7 +345,7 @@ } } }, - data () { return {rotateFocussed: false, headingFocussed: false, coordFocussed: false, noseCoordFocussed: false, calculateState: 'Nose Wheel', noseWheel: '', validRadii: [7.5, 10, 14, 18, 26, 33, 40], validN2M: [5, 5, 6, 10, 15, 24, 24] } }, + data () { return {rotateFocussed: false, externalChange: false, coordFocussed: false, noseCoordFocussed: false, calculateState: 'Nose Wheel', noseWheel: '', validRadii: [7.5, 10, 14, 18, 26, 33, 40], validN2M: [5, 5, 6, 10, 15, 24, 24], heading: 0 }}, computed: { editing: { get: function () { @@ -451,16 +465,6 @@ this.calcCenter(); } }, - heading: { - // getter - get: function () { - return this.$store.state.Editable.data.parking.heading - }, - // setter - set: function (newValue) { - this.headingChange(newValue) - } - }, wingspan: { // getter get: function () {