Newer
Older
Eliot Berriot
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<template>
<button @click="toggleRadio" :class="['ui', 'blue', {'inverted': running}, 'button']">
<i class="ui feed icon"></i>
<template v-if="running">Stop</template>
<template v-else>Start</template>
radio
</button>
</template>
<script>
import radios from '@/radios'
export default {
props: {
type: {type: String, required: true},
objectId: {type: Number, default: null}
},
data () {
return {
radios
}
},
methods: {
toggleRadio () {
if (this.running) {
radios.stop()
} else {
radios.start(this.type, this.objectId)
}
}
},
computed: {
running () {
if (!radios.running) {
return false
} else {
return radios.current.type === this.type & radios.current.objectId === this.objectId
}
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
i {
cursor: pointer;
}
</style>