Skip to content
Snippets Groups Projects
Button.vue 1.17 KiB
Newer Older
jovuit's avatar
jovuit committed
  <button @click="toggleRadio" :class="['ui', 'blue', {'inverted': running}, 'icon', 'labeled', 'button']">
jovuit's avatar
jovuit committed
    <template v-if="running"><translate>Stop radio</translate></template>
    <template v-else><translate>Start radio</translate></template>
    customRadioId: {required: false},
    type: {type: String, required: false},
    objectId: {type: Number, default: null}
  },
  methods: {
    toggleRadio () {
      if (this.running) {
        this.$store.dispatch('radios/stop')
        this.$store.dispatch('radios/start', {type: this.type, objectId: this.objectId, customRadioId: this.customRadioId})
      let state = this.$store.state.radios
      let current = state.current
      if (!state.running) {
        return current.type === this.type && current.objectId === this.objectId && current.customRadioId === this.customRadioId
      }
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
i {
  cursor: pointer;
}
</style>