Remove frequency

This commit is contained in:
portree_kid 2020-04-27 15:23:05 +02:00
parent 90740751dd
commit fb72f8d760
4 changed files with 23 additions and 5 deletions

View File

@ -98,6 +98,6 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.el-row { .el-row {
padding: 0em; padding: 0em;
margin-bottom: 10px; margin-bottom: 5px;
} }
</style> </style>

View File

@ -455,6 +455,9 @@
return return
} }
this.$store.dispatch('updatedParking', this.$store.state.Editable.data.parking); this.$store.dispatch('updatedParking', this.$store.state.Editable.data.parking);
if (this.featureLookup[this.$store.state.Editable.index]===undefined) {
return
}
this.featureLookup[this.$store.state.Editable.index].forEach((element,index) => { this.featureLookup[this.$store.state.Editable.index].forEach((element,index) => {
if (element instanceof L.ParkingSpot) { if (element instanceof L.ParkingSpot) {
element.options.attributes = Object.assign({}, this.$store.state.Editable.data.parking) element.options.attributes = Object.assign({}, this.$store.state.Editable.data.parking)

View File

@ -12,7 +12,7 @@
></el-option> ></el-option>
</el-select> </el-select>
</el-col> </el-col>
<el-col :span="15"> <el-col :span="13">
<el-input <el-input
placeholder="Please input frequency" placeholder="Please input frequency"
v-model="value" v-model="value"
@ -20,14 +20,19 @@
v-bind:class="{ invalid: !ok && editing}" v-bind:class="{ invalid: !ok && editing}"
></el-input> ></el-input>
</el-col> </el-col>
<el-col :span="2">
<el-button @click="remove" v-if="editing" ><i class="fas fa-trash-alt"></i></el-button>
</el-col>
</el-row> </el-row>
</span> </span>
</div> </div>
</template> </template>
<script lang="js"> <script lang="js">
import EditButton from './EditButton'
/* eslint-disable */ /* eslint-disable */
export default { export default {
name: 'frequency', name: 'frequency',
components: { EditButton },
props: {frequency: Object}, props: {frequency: Object},
mounted () { mounted () {
}, },
@ -37,6 +42,9 @@
} }
}, },
methods: { methods: {
remove () {
this.$store.dispatch('removeFrequency', this.frequency)
},
isValid (frequency) { isValid (frequency) {
let ok = frequency >= 118 && frequency <= 137 let ok = frequency >= 118 && frequency <= 137
if (!ok) { if (!ok) {
@ -87,7 +95,7 @@
value: { value: {
// getter // getter
get: function () { get: function () {
return this.frequency.value; return this.frequency.value;
}, },
// setter // setter
set: function (newValue) { set: function (newValue) {
@ -97,8 +105,6 @@
} }
} }
} }
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -10,6 +10,12 @@ const mutations = {
const existingItem = state.items.find((i) => i.id === item.id) const existingItem = state.items.find((i) => i.id === item.id)
Object.assign(existingItem, item) Object.assign(existingItem, item)
}, },
REMOVE_FREQUENCY: (state, item) => {
const index = state.items.indexOf(item)
if (index > -1) {
state.items.splice(index, 1)
}
},
SET_FREQUENCIES (state, frequencies) { SET_FREQUENCIES (state, frequencies) {
Vue.set(state, 'items', frequencies) Vue.set(state, 'items', frequencies)
} }
@ -22,6 +28,9 @@ const actions = {
async updateFrequency (context, frequency) { async updateFrequency (context, frequency) {
context.commit('SET_GROUND', frequency) context.commit('SET_GROUND', frequency)
}, },
async removeFrequency (context, frequency) {
context.commit('REMOVE_FREQUENCY', frequency)
},
async setFrequencies (context, frequencies) { async setFrequencies (context, frequencies) {
context.commit('SET_FREQUENCIES', frequencies) context.commit('SET_FREQUENCIES', frequencies)
} }