Change Type via multiselect

This commit is contained in:
Keith Paterson 2021-06-24 08:00:05 +02:00
parent ba533e8942
commit 7a58b4bde1
3 changed files with 39 additions and 26 deletions

View File

@ -216,6 +216,11 @@ You should have received a copy of the GNU General Public License along with FG
element.updateRadius(event.wingspan/2) element.updateRadius(event.wingspan/2)
}); });
break; break;
case 'parking-group-type':
this.selection.forEach(element => {
element.updateType(event.parking_type)
});
break;
default: default:
break; break;
} }

View File

@ -11,7 +11,7 @@
radius: 18 radius: 18
type: "gate" type: "gate"
--> -->
<!-- <!--
<el-row> <el-row>
<el-col :span="4"> <el-col :span="4">
<span class="label">Name :</span> <span class="label">Name :</span>
@ -90,13 +90,12 @@
</el-button> </el-button>
</el-col> </el-col>
</el-row> </el-row>
<!--
<el-row> <el-row>
<el-col :span="7"> <el-col :span="7">
<span class="label">Parking Type :</span> <span class="label">Parking Type :</span>
</el-col> </el-col>
<el-col :span="17"> <el-col :span="17">
<el-select v-model="parking_type" placeholder="Select" :disabled="!editing"> <el-select v-model="parking_type" @change="typeChange" placeholder="Select" :disabled="!editing">
<el-option <el-option
v-for="type in options" v-for="type in options"
:key="type.value" :key="type.value"
@ -107,6 +106,7 @@
</el-select> </el-select>
</el-col> </el-col>
</el-row> </el-row>
<!--
<el-row> <el-row>
<el-col :span="7"> <el-col :span="7">
<span class="label">Airline :</span> <span class="label">Airline :</span>
@ -128,15 +128,15 @@
<script lang="js"> <script lang="js">
/* eslint-disable */ /* eslint-disable */
import Vue from 'vue' import Vue from 'vue'
const convert = require('geo-coordinates-parser'); const convert = require('geo-coordinates-parser');
const Coordinates = require('coordinate-parser'); const Coordinates = require('coordinate-parser');
export default { export default {
data () { data () {
return { return {
data: Object, avgHeading: 5, editing: Boolean, wingspan: 0 data: Object, avgHeading: 5, editing: Boolean, wingspan: 0, parking_type: ''
} }
}, },
@ -153,10 +153,11 @@ const convert = require('geo-coordinates-parser');
}, },
show (idx) { show (idx) {
this.$parent.$parent.$parent.$refs.editLayer.show(idx) this.$parent.$parent.$parent.$refs.editLayer.show(idx)
}, },
setData (data) { setData (data) {
this.data = data; this.data = data;
this.setAvgHeading(); this.setAvgHeading();
this.setAvgType();
}, },
setEditing(editing) { setEditing(editing) {
this.editing = editing this.editing = editing
@ -164,18 +165,29 @@ const convert = require('geo-coordinates-parser');
setAvgHeading() { setAvgHeading() {
if( this.data === null || this.data === undefined) { if( this.data === null || this.data === undefined) {
return 0 return 0
} }
this.avgHeading = Number( this.data.reduce(function (r, parking) { this.avgHeading = Number( this.data.reduce(function (r, parking) {
r.sum = r.sum + parking.options.attributes.heading; r.sum = r.sum + parking.options.attributes.heading;
r.avg = r.sum / ++r.count; r.avg = r.sum / ++r.count;
return r; return r;
}, { sum: 0, count: 0, avg: 0 }).avg); }, { sum: 0, count: 0, avg: 0 }).avg);
}, },
setAvgType() {
if( this.data === null || this.data === undefined) {
return 0
}
var types = this.data.map(parking => parking.options.attributes.type).filter((v, i, a) => a.indexOf(v) === i);
if (types.length == 1) {
this.parking_type = types[0];
} else {
this.parking_type = '';
}
},
wingspanChange( newValue ) { wingspanChange( newValue ) {
if ( newValue ) { if ( newValue ) {
this.$emit('editParking', {type: 'parking-group-wingspan', wingspan: newValue} ) this.$emit('editParking', {type: 'parking-group-wingspan', wingspan: newValue} )
} }
}, },
headingChange( newValue ) { headingChange( newValue ) {
while (newValue>=360) { while (newValue>=360) {
newValue -= 360 newValue -= 360
@ -186,9 +198,14 @@ const convert = require('geo-coordinates-parser');
if ( newValue ) { if ( newValue ) {
this.$emit('editParking', {type: 'parking-group-angle', angle: newValue} ) this.$emit('editParking', {type: 'parking-group-angle', angle: newValue} )
} }
},
typeChange( newValue ) {
if ( newValue ) {
this.$emit('editParking', {type: 'parking-group-type', parking_type: newValue} )
}
} }
}, },
computed: { computed: {
parking: function () { parking: function () {
return this.data !== null && this.$store.state.Editable.type === 'parking-group' return this.data !== null && this.$store.state.Editable.type === 'parking-group'
@ -209,7 +226,7 @@ const convert = require('geo-coordinates-parser');
}, },
airlineCodes: { airlineCodes: {
// getter // getter
get: function () { get: function () {
}, },
// setter // setter
set: function (newValue) { set: function (newValue) {
@ -271,19 +288,6 @@ const convert = require('geo-coordinates-parser');
{value: 'mil-fighter', label: 'military fighter'}, {value: 'mil-fighter', label: 'military fighter'},
{value: 'mil-cargo', label: 'military cargo'} {value: 'mil-cargo', label: 'military cargo'}
] ]
},
parking_type: {
// getter
get: function () {
if (this.$store.state.Editable.data.parking.type === undefined) {
return 'none'
}
return this.$store.state.Editable.data.parking.type
},
// setter
set: function (newValue) {
this.$store.commit('SET_EDIT_PARKING_TYPE', newValue)
}
} }
} }
} }

View File

@ -96,6 +96,10 @@ L.ParkingSpot = L.Circle.extend({
this.updateWheelPos(); this.updateWheelPos();
this.updateBox(); this.updateBox();
}, },
updateType(type) {
this.options.attributes.type = type;
this.deselect();
},
// Update the direction vertex from the direction // Update the direction vertex from the direction
updateVertexFromDirection() { updateVertexFromDirection() {
if (this.editEnabled()) { if (this.editEnabled()) {