mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-30 07:06:47 +00:00
barcode: fix all the issues from PR review
This commit is contained in:
@@ -7,9 +7,14 @@ const cellValue = inject(CellValueInj)
|
||||
|
||||
const column = inject(ColumnInj)
|
||||
|
||||
const barcodeValue = computed(() => String(cellValue?.value))
|
||||
const barcodeValue = computed(() => {
|
||||
if (cellValue?.value === undefined) {
|
||||
return undefined
|
||||
}
|
||||
return String(cellValue.value)
|
||||
})
|
||||
|
||||
const tooManyCharsForBarcode = computed(() => barcodeValue?.value.length > maxNumberOfAllowedCharsForBarcodeValue)
|
||||
const tooManyCharsForBarcode = computed(() => barcodeValue?.value?.length > maxNumberOfAllowedCharsForBarcodeValue)
|
||||
|
||||
const modalVisible = ref(false)
|
||||
|
||||
@@ -27,7 +32,7 @@ const barcodeMeta = $computed(() => {
|
||||
const handleModalOkClick = () => (modalVisible.value = false)
|
||||
|
||||
const showBarcode = computed(() => {
|
||||
return cellValue?.value?.length > 0 && !tooManyCharsForBarcode.value
|
||||
return barcodeValue && barcodeValue?.value?.length > 0 && !tooManyCharsForBarcode.value
|
||||
})
|
||||
|
||||
const { showEditNonEditableFieldWarning, showClearNonEditableFieldWarning } = useShowNotEditableWarning()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import JsBarcode from 'jsbarcode'
|
||||
import { onMounted } from '#imports'
|
||||
|
||||
const props = defineProps({
|
||||
barcodeValue: { type: String, required: true },
|
||||
@@ -7,6 +8,7 @@ const props = defineProps({
|
||||
})
|
||||
|
||||
const emit = defineEmits(['onClickBarcode'])
|
||||
|
||||
const barcodeSvgRef = ref(null)
|
||||
const errorForCurrentInput = ref(false)
|
||||
|
||||
@@ -27,8 +29,7 @@ const onBarcodeClick = (ev: MouseEvent) => {
|
||||
emit('onClickBarcode')
|
||||
}
|
||||
|
||||
watch(() => props.barcodeValue, generate)
|
||||
watch(() => props.barcodeFormat, generate)
|
||||
watch([() => props.barcodeValue, () => props.barcodeFormat], generate)
|
||||
onMounted(generate)
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user