mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 08:18:42 +00:00
Update the nuxt3 version. Co-authored-by: Jonathan Adeline <jonathan@baserow.io> Co-authored-by: Bram Wiepjes <bramw@protonmail.com> Co-authored-by: Cezary <cezary@baserow.io> Co-authored-by: Tsering Paljor <tsering@baserow.io> Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io> Co-authored-by: Bram <bram2w@users.noreply.github.com>
56 lines
1.3 KiB
Vue
56 lines
1.3 KiB
Vue
<template>
|
|
<div ref="cell" 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],
|
|
emits: ['update'],
|
|
data() {
|
|
return {
|
|
// Event handler reference for cleanup
|
|
keydownEvent: null,
|
|
}
|
|
},
|
|
methods: {
|
|
select() {
|
|
// While the field is selected we want to toggle the value by pressing the enter
|
|
// key.
|
|
this.keydownEvent = (event) => {
|
|
if (event.key === 'Enter') {
|
|
this.toggle(this.value)
|
|
}
|
|
}
|
|
document.body.addEventListener('keydown', this.keydownEvent)
|
|
},
|
|
beforeUnSelect() {
|
|
document.body.removeEventListener('keydown', this.keydownEvent)
|
|
},
|
|
toggle(value) {
|
|
if (this.readOnly) {
|
|
return
|
|
}
|
|
|
|
const oldValue = !!value
|
|
const newValue = !value
|
|
this.$emit('update', newValue, oldValue)
|
|
},
|
|
},
|
|
}
|
|
</script>
|