mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
95 lines
2.5 KiB
95 lines
2.5 KiB
2 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import type { ColumnType } from 'nocodb-sdk'
|
||
2 years ago
|
import { computed, inject } from 'vue'
|
||
2 years ago
|
|
||
2 years ago
|
const { modelValue: value } = defineProps<{ modelValue: any }>()
|
||
|
const emit = defineEmits(['update:modelValue'])
|
||
|
const column = inject<ColumnType & { meta?: any }>('column')
|
||
|
const isForm = inject<boolean>('isForm')
|
||
2 years ago
|
|
||
|
const checkboxMeta = computed(() => {
|
||
|
return {
|
||
|
icon: {
|
||
2 years ago
|
checked: 'mdi-check-circle-outline',
|
||
|
unchecked: 'mdi-checkbox-blank-circle-outline',
|
||
2 years ago
|
},
|
||
2 years ago
|
color: 'primary',
|
||
|
...(column?.meta || {}),
|
||
|
}
|
||
|
})
|
||
2 years ago
|
const localState = computed({
|
||
2 years ago
|
get() {
|
||
2 years ago
|
return value
|
||
|
},
|
||
|
set(val) {
|
||
|
emit('update:modelValue', val)
|
||
|
},
|
||
|
})
|
||
2 years ago
|
|
||
2 years ago
|
const toggle = () => {
|
||
2 years ago
|
localState.value = !localState.value
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
// const checkedIcon = computed(() => {
|
||
|
// return defineAsyncComponent( ()=>import('~icons/material-symbols/'+checkboxMeta?.value?.icon?.checked))
|
||
|
// });
|
||
|
// const uncheckedIcon = computed(() => {
|
||
|
// return defineAsyncComponent(()=>import('~icons/material-symbols/'+checkboxMeta?.value?.icon?.unchecked))
|
||
|
// });
|
||
|
|
||
2 years ago
|
/* export default {
|
||
2 years ago
|
name: 'BooleanCell',
|
||
|
props: {
|
||
|
column: Object,
|
||
|
value: [String, Number, Boolean],
|
||
|
isForm: Boolean,
|
||
2 years ago
|
readOnly: Boolean,
|
||
2 years ago
|
},
|
||
|
computed: {
|
||
|
checkedIcon() {
|
||
|
return (this.checkboxMeta && this.checkboxMeta.icon && this.checkboxMeta.icon.checked) || 'mdi-check-bold'
|
||
|
},
|
||
|
uncheckedIcon() {
|
||
|
return (this.checkboxMeta && this.checkboxMeta.icon && this.checkboxMeta.icon.unchecked) || 'mdi-crop-square'
|
||
|
},
|
||
|
localState: {
|
||
|
get() {
|
||
|
return this.value
|
||
|
},
|
||
|
set(val) {
|
||
|
this.$emit('input', val)
|
||
2 years ago
|
},
|
||
2 years ago
|
},
|
||
|
parentListeners() {
|
||
|
const $listeners = {}
|
||
|
return $listeners
|
||
|
},
|
||
|
checkboxMeta() {
|
||
|
return {
|
||
|
icon: {
|
||
|
checked: 'mdi-check-circle-outline',
|
||
2 years ago
|
unchecked: 'mdi-checkbox-blank-circle-outline',
|
||
2 years ago
|
},
|
||
|
color: 'primary',
|
||
2 years ago
|
...(this.column && this.column.meta ? this.column.meta : {}),
|
||
2 years ago
|
}
|
||
2 years ago
|
},
|
||
2 years ago
|
},
|
||
|
methods: {
|
||
|
toggle() {
|
||
|
this.localState = !this.localState
|
||
2 years ago
|
},
|
||
|
},
|
||
2 years ago
|
} */
|
||
2 years ago
|
</script>
|
||
|
|
||
2 years ago
|
<template>
|
||
2 years ago
|
<div class="d-flex align-center" :class="{ 'justify-center': !isForm, 'nc-cell-hover-show': !localState }">
|
||
|
<!-- <span :is="localState ? checkedIcon : uncheckedIcon" small :color="checkboxMeta.color" @click="toggle"> -->
|
||
|
<!-- {{ localState ? checkedIcon : uncheckedIcon }} -->
|
||
|
<!-- </span> -->
|
||
2 years ago
|
|
||
2 years ago
|
<input v-model="localState" type="checkbox" />
|
||
2 years ago
|
</div>
|
||
|
</template>
|