1
0
mirror of https://gitlab.com/bramw/baserow.git synced 2024-11-25 00:46:46 +00:00
bramw_baserow/web-frontend/modules/database/components/view/grid/fields/GridViewFieldBoolean.vue
Jonathan Adeline 4321aaea9a Replace icons
2023-09-28 13:39:41 +00:00

49 lines
1.2 KiB
Vue

<template>
<div class="grid-view__cell active">
<div class="grid-field-boolean">
<div
class="grid-field-boolean__checkbox"
:class="{
active: value,
'grid-field-boolean__checkbox--read-only': readOnly,
}"
@click="toggle(value)"
>
<i class="iconoir-check grid-field-boolean__checkbox-icon"></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.key === 'Enter') {
this.toggle(this.value)
}
}
document.body.addEventListener('keydown', this.$el.keydownEvent)
},
beforeUnSelect() {
document.body.removeEventListener('keydown', this.$el.keydownEvent)
},
toggle(value) {
if (this.readOnly) {
return
}
const oldValue = !!value
const newValue = !value
this.$emit('update', newValue, oldValue)
},
},
}
</script>