Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix(nc-gui): Number based filters - restrict input for filter value to numbers

Ramesh Maneb8d590e81b05
diff --git a/packages/nc-gui/components/cell/Currency/Editor.vue b/packages/nc-gui/components/cell/Currency/Editor.vue
index 0b37e0acd3..cb549abc2f 100644
--- a/packages/nc-gui/components/cell/Currency/Editor.vue
+++ b/packages/nc-gui/components/cell/Currency/Editor.vue
@@ -6,6 +6,7 @@ interface Props {
modelValue: number | null | undefined
placeholder?: string
hidePrefix?: boolean
+ location?: 'cell' | 'filter'
}
const props = defineProps<Props>()
@@ -24,7 +25,9 @@ const _vModel = useVModel(props, 'modelValue', emit)
const lastSaved = ref()
const cellFocused = ref(false)
-const inputType = computed(() => (isExpandedFormOpen.value && !cellFocused.value ? 'text' : 'number'))
+const inputType = computed(() =>
+ isExpandedFormOpen.value && !cellFocused.value && props.location !== 'filter' ? 'text' : 'number',
+)
const currencyMeta = computed(() => {
return {
diff --git a/packages/nc-gui/components/cell/Currency/index.vue b/packages/nc-gui/components/cell/Currency/index.vue
index 525d1b7491..82f49998d7 100644
--- a/packages/nc-gui/components/cell/Currency/index.vue
+++ b/packages/nc-gui/components/cell/Currency/index.vue
@@ -6,6 +6,7 @@ interface Props {
modelValue: number | null | undefined
placeholder?: string
hidePrefix?: boolean
+ location?: 'cell' | 'filter'
}
const props = defineProps<Props>()
@@ -30,7 +31,9 @@ const _vModel = useVModel(props, 'modelValue', emit)
const cellFocused = ref(false)
-const inputType = computed(() => (isExpandedFormOpen.value && !cellFocused.value ? 'text' : 'number'))
+const inputType = computed(() =>
+ isExpandedFormOpen.value && !cellFocused.value && props.location !== 'filter' ? 'text' : 'number',
+)
const vModel = computed({
get: () => _vModel.value,
diff --git a/packages/nc-gui/components/cell/Integer/Editor.vue b/packages/nc-gui/components/cell/Integer/Editor.vue
index 8377c38416..31e35aa370 100644
--- a/packages/nc-gui/components/cell/Integer/Editor.vue
+++ b/packages/nc-gui/components/cell/Integer/Editor.vue
@@ -7,6 +7,7 @@ interface Props {
// for sqlite, when we clear a cell or empty the cell, it returns ""
// otherwise, it is null type
modelValue?: number | null | string
+ location?: 'cell' | 'filter'
}
interface Emits {
@@ -42,7 +43,7 @@ const vModel = computed({
},
})
-const inputType = computed(() => (isForm.value && !isEditColumn.value ? 'text' : 'number'))
+const inputType = computed(() => (isForm.value && !isEditColumn.value && props.location !== 'filter' ? 'text' : 'number'))
const focus: VNodeRef = (el) => {
if (!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value) {
diff --git a/packages/nc-gui/components/cell/Integer/index.vue b/packages/nc-gui/components/cell/Integer/index.vue
index e8af978d3c..c172cf6e38 100644
--- a/packages/nc-gui/components/cell/Integer/index.vue
+++ b/packages/nc-gui/components/cell/Integer/index.vue
@@ -6,6 +6,7 @@ interface Props {
// for sqlite, when we clear a cell or empty the cell, it returns ""
// otherwise, it is null type
modelValue?: number | null | string
+ location?: 'cell' | 'filter'
}
interface Emits {
@@ -57,7 +58,7 @@ const vModel = computed({
},
})
-const inputType = computed(() => (isForm.value && !isEditColumn.value ? 'text' : 'number'))
+const inputType = computed(() => (isForm.value && !isEditColumn.value && props.location !== 'filter' ? 'text' : 'number'))
const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()
diff --git a/packages/nc-gui/components/cell/Percent/Editor.vue b/packages/nc-gui/components/cell/Percent/Editor.vue
index 729acc4b44..3dd9150490 100644
--- a/packages/nc-gui/components/cell/Percent/Editor.vue
+++ b/packages/nc-gui/components/cell/Percent/Editor.vue
@@ -5,6 +5,7 @@ interface Props {
modelValue?: number | string | null
placeholder?: string
localEditEnabled?: boolean
+ location?: 'cell' | 'filter'
}
const props = defineProps<Props>()
@@ -61,7 +62,7 @@ const vModelNumber = computed<number>(() => {
return 0
})
-const inputType = computed(() => (isForm.value && !isEditColumn.value ? 'text' : 'number'))
+const inputType = computed(() => (isForm.value && !isEditColumn.value && props.location !== 'filter' ? 'text' : 'number'))
const onBlur = () => {
if (isExpandedFormOpen.value) {
diff --git a/packages/nc-gui/components/cell/Percent/index.vue b/packages/nc-gui/components/cell/Percent/index.vue
index 26573bce5b..5acd01cee4 100644
--- a/packages/nc-gui/components/cell/Percent/index.vue
+++ b/packages/nc-gui/components/cell/Percent/index.vue
@@ -4,6 +4,7 @@ import type { VNodeRef } from '@vue/runtime-core'
interface Props {
modelValue?: number | string | null
placeholder?: string
+ location?: 'cell' | 'filter'
}
const props = defineProps<Props>()
@@ -61,7 +62,7 @@ const percentMeta = computed(() => {
}
})
-const inputType = computed(() => (isForm.value && !isEditColumn.value ? 'text' : 'number'))
+const inputType = computed(() => (isForm.value && !isEditColumn.value && props.location !== 'filter' ? 'text' : 'number'))
const onBlur = () => {
if (editEnabled) {