mirror of
https://gitlab.com/bramw/baserow.git
synced 2025-04-16 01:54:12 +00:00
44 lines
1.1 KiB
Vue
44 lines
1.1 KiB
Vue
<template>
|
|
<div class="grid-view-cell" :class="{ active: selected }">
|
|
<div class="grid-field-boolean">
|
|
<div
|
|
class="grid-field-checkbox"
|
|
:class="{ active: value }"
|
|
@click="toggle(value)"
|
|
>
|
|
<i class="fas fa-check check"></i>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import gridField from '@baserow/modules/database/mixins/gridField'
|
|
|
|
export default {
|
|
mixins: [gridField],
|
|
methods: {
|
|
select() {
|
|
// While the field is selected we want to toggle the value by pressing the enter
|
|
// key.
|
|
this.$el.keydownEvent = (event) => {
|
|
if (event.keyCode === 13) {
|
|
this.toggle(this.value)
|
|
}
|
|
}
|
|
document.body.addEventListener('keydown', this.$el.keydownEvent)
|
|
},
|
|
beforeUnSelect() {
|
|
document.body.removeEventListener('keydown', this.$el.keydownEvent)
|
|
},
|
|
toggle(value) {
|
|
if (!this.selected) {
|
|
return
|
|
}
|
|
const oldValue = !!value
|
|
const newValue = !value
|
|
this.$emit('update', newValue, oldValue)
|
|
},
|
|
},
|
|
}
|
|
</script>
|