From c9eaa64156bdf18222e619262806a622c87a1d42 Mon Sep 17 00:00:00 2001 From: flisowna Date: Mon, 26 Dec 2022 16:55:04 +0100 Subject: [PATCH] barcode: fix barcode value in cleaner way --- .../components/virtual-cell/barcode/Barcode.vue | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/packages/nc-gui/components/virtual-cell/barcode/Barcode.vue b/packages/nc-gui/components/virtual-cell/barcode/Barcode.vue index 7b0b17b67a..7b73433962 100644 --- a/packages/nc-gui/components/virtual-cell/barcode/Barcode.vue +++ b/packages/nc-gui/components/virtual-cell/barcode/Barcode.vue @@ -7,14 +7,9 @@ const cellValue = inject(CellValueInj) const column = inject(ColumnInj) -const barcodeValue = computed(() => { - if (cellValue?.value === undefined) { - return undefined - } - return String(cellValue.value) -}) +const barcodeValue: ComputedRef = computed(() => String(cellValue?.value || '')) -const tooManyCharsForBarcode = computed(() => barcodeValue?.value?.length > maxNumberOfAllowedCharsForBarcodeValue) +const tooManyCharsForBarcode = computed(() => barcodeValue.value.length > maxNumberOfAllowedCharsForBarcodeValue) const modalVisible = ref(false) @@ -31,9 +26,7 @@ const barcodeMeta = $computed(() => { const handleModalOkClick = () => (modalVisible.value = false) -const showBarcode = computed(() => { - return barcodeValue && barcodeValue?.value?.length > 0 && !tooManyCharsForBarcode.value -}) +const showBarcode = computed(() => barcodeValue?.value.length > 0 && !tooManyCharsForBarcode.value) const { showEditNonEditableFieldWarning, showClearNonEditableFieldWarning } = useShowNotEditableWarning()