8000 Nc fix: Form view bug fixes by rameshmane7218 · Pull Request #7899 · nocodb/nocodb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Nc fix: Form view bug fixes #7899

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4602c7f
fix(nc-gui): show inline form field validation errors
rameshmane7218 Mar 20, 2024
56c9c20
fix(nc-gui): display inline validation error in shared form and form …
rameshmane7218 Mar 20, 2024
8a23148
fix(nc-gui): shared form default value issue
rameshmane7218 Mar 20, 2024
c535dcf
fix(nc-gui): limit option spell mistake
rameshmane7218 Mar 20, 2024
6289bb5
fix(nc-gui): form title update issue when toggle between grid & form …
rameshmane7218 Mar 20, 2024
8dd27e6
fix(nc-gui): form banner & logo display issue on upload
rameshmane7218 Mar 20, 2024
9106b39
chore(nc-gui): lint
rameshmane7218 Mar 20, 2024
1f25f11
fix(nc-gui): show error message on press non numeric keys in numeric …
rameshmane7218 Mar 20, 2024
062bc8f
fix(nc-gui): add key for form banner and logo
8000 rameshmane7218 Mar 20, 2024
c850a8c
fix(nc-gui): show currency suffix only in form
rameshmane7218 Mar 20, 2024
5d77ad6
fix(nc-gui): edit column default value input height issue
rameshmane7218 Mar 20, 2024
5a548e3
fix(nc-gui): form checkbox field enter keypress should navigate to ne…
rameshmane7218 Mar 20, 2024
38559ec
fix(nc-gui): escape should blur focus field in survey form
rameshmane7218 Mar 20, 2024
70a0a52
fix(nc-gui): add currency code suffix in form view currency field
rameshmane7218 Mar 20, 2024
a7d6162
chore(nc-gui): lint
rameshmane7218 Mar 20, 2024
f802c72
fix(nc-gui): add percent suffix in form view percent field
rameshmane7218 Mar 20, 2024
c9dbadb
fix(nc-gui): survey form pw test fail issue
rameshmane7218 Mar 20, 2024
68274ed
fix(nc-gui): filter pw test fail issue
rameshmane7218 Mar 20, 2024
a44f8ce
fix(nc-gui): add missing classname in oss
rameshmane7218 Mar 20, 2024
33fb503
fix(nc-gui): survey form ui break issue
rameshmane7218 Mar 20, 2024
36b1502
fix(nc-gui): update oss survey form file
rameshmane7218 Mar 20, 2024
2d22a0c
fix(nc-gui): in survey form branding text color should be dynamic bas…
rameshmane7218 Mar 20, 2024
25d80af
chore(nc-gui): lint
rameshmane7218 Mar 20, 2024
77ec1e1
fix(nc-gui): ai pr review changes
rameshmane7218 Mar 20, 2024
029b497
fix(nc-gui): pr review changes #2555
rameshmane7218 Mar 20, 2024
9a88329
fix(nc-gui): use handler instead on ternery condition
rameshmane7218 Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions packages/nc-gui/components/cell/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const vModel = computed<boolean | number>({
set: (val: any) => emits('update:modelValue', isMssql(column?.value?.source_id) ? +val : val),
})

function onClick(force?: boolean, event?: MouseEvent) {
function onClick(force?: boolean, event?: MouseEvent | KeyboardEvent) {
if (
(event?.target as HTMLElement)?.classList?.contains('nc-checkbox') ||
(event?.target as HTMLElement)?.closest('.nc-checkbox')
Expand All @@ -75,6 +75,19 @@ function onClick(force?: boolean, event?: MouseEvent) {
}
}

const keydownEnter = (e: KeyboardEvent) => {
if (!isSurveyForm.value) {
onClick(true, e)
e.stopPropagation()
}
}
const keydownSpace = (e: KeyboardEvent) => {
if (isSurveyForm.value) {
onClick(true, e)
e.stopPropagation()
}
}

useSelectedCellKeyupListener(active, (e) => {
switch (e.key) {
case 'Enter':
Expand All @@ -101,8 +114,8 @@ useSelectedCellKeyupListener(active, (e) => {
}"
:tabindex="readOnly ? -1 : 0"
@click="onClick(false, $event)"
@keydown.enter.stop="!isSurveyForm ? onClick(true, $event) : undefined"
@keydown.space.stop="isSurveyForm ? onClick(true, $event) : undefined"
@keydown.enter="keydownEnter"
@keydown.space="keydownSpace($event)"
>
<div
class="flex items-center"
Expand Down
11 changes: 10 additions & 1 deletion packages/nc-gui/components/cell/Currency.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,21 @@ onMounted(() => {
</script>

<template>
<div
v-if="isForm && !isEditColumn"
class="nc-currency-code h-full !bg-gray-100 border-r border-gray-200 px-3 mr-1 flex items-center"
>
<span>
{{ currencyMeta.currency_code }}
</span>
</div>
<input
v-if="!readOnly && editEnabled"
:ref="focus"
v-model="vModel"
type="number"
class="nc-cell-field w-full h-full text-sm border-none rounded-md py-1 outline-none focus:outline-none focus:ring-0"
class="nc-cell-field h-full text-sm border-none rounded-md py-1 outline-none focus:outline-none focus:ring-0"
:class="isForm && !isEditColumn ? 'flex flex-1' : 'w-full'"
:placeholder="isEditColumn ? $t('labels.optional') : ''"
@blur="onBlur"
@keydown.enter="onKeydownEnter"
Expand Down
21 changes: 12 additions & 9 deletions packages/nc-gui/components/cell/Email.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
EditModeInj,
IsExpandedFormOpenInj,
IsFormInj,
IsSurveyFormInj,
ReadonlyInj,
computed,
inject,
Expand All @@ -31,38 +30,42 @@ const editEnabled = inject(EditModeInj)!

const column = inject(ColumnInj)!

const isSurveyForm = inject(IsSurveyFormInj, ref(false))

const isEditColumn = inject(EditColumnInj, ref(false))

const readOnly = inject(ReadonlyInj, ref(false))

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const isForm = inject(IsFormInj)!

// Used in the logic of when to display error since we are not storing the email if it's not valid
const localState = ref(value)

const vModel = computed({
get: () => value,
set: (val) => {
localState.value = val
if (!parseProp(column.value.meta)?.validate || (val && validateEmail(val)) || !val || isSurveyForm.value) {
if (!parseProp(column.value.meta)?.validate || (val && validateEmail(val)) || !val || isForm.value) {
emit('update:modelValue', val)
}
},
})

const validEmail = computed(() => vModel.value && validateEmail(vModel.value))

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const isForm = inject(IsFormInj)!

const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()

watch(
() => editEnabled.value,
() => {
if (parseProp(column.value.meta)?.validate && !editEnabled.value && localState.value && !validateEmail(localState.value)) {
if (
!isForm.value &&
parseProp(column.value.meta)?.validate &&
!editEnabled.value &&
localState.value &&
!validateEmail(localState.value)
) {
message.error(t('msg.error.invalidEmail'))
localState.value = undefined
return
Expand Down
9E19 15 changes: 10 additions & 5 deletions packages/nc-gui/components/cell/Integer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const isEditColumn = inject(EditColumnInj, ref(false))

const readOnly = inject(ReadonlyInj, ref(false))

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const isForm = inject(IsFormInj)!

const _vModel = useVModel(props, 'modelValue', emits)

const displayValue = computed(() => {
Expand All @@ -42,15 +46,15 @@ const vModel = computed({
// if we clear / empty a cell in sqlite,
// the value is considered as ''
_vModel.value = null
} else if (isForm.value && !isEditColumn.value) {
_vModel.value = isNaN(Number(value)) ? value : Number(value)
} else {
_vModel.value = value
}
},
})

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const isForm = inject(IsFormInj)!
const inputType = computed(() => (isForm.value && !isEditColumn.value ? 'text' : 'number'))

const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()
Expand Down Expand Up @@ -91,7 +95,7 @@ function onKeyDown(e: any) {
:ref="focus"
v-model="vModel"
class="nc-cell-field outline-none py-1 border-none w-full h-full text-sm"
type="number"
:type="inputType"
style="letter-spacing: 0.06rem"
:placeholder="isEditColumn ? $t('labels.optional') : ''"
@blur="editEnabled = false"
Expand All @@ -109,7 +113,8 @@ function onKeyDown(e: any) {
</template>

<style scoped lang="scss">
input[type='number']:focus {
input[type='number']:focus,
input[type='text']:focus {
@apply ring-transparent;
}

Expand Down
5 changes: 4 additions & 1 deletion packages/nc-gui/components/cell/MultiSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ const KeyboardEvent) => {
if (e.key === 'Tab') {
isOpen.value = false
return
} else if (e.key === 'Escape' && isForm.value) {
isOpen.value = false
return
}

e.stopPropagation()
Expand All @@ -394,7 +397,7 @@ const => {
@click="toggleMenu"
>
<div v-if="!isEditColumn && isForm && parseProp(column.meta)?.isList" class="w-full max-w-full">
<a-checkbox-group v-model:value="vModel" :disabled="readOnly || !editAllowed" class="nc-field-layout-list">
<a-checkbox-group v-model:value="vModel" :disabled="readOnly || !editAllowed" class="nc-field-layout-list" @click.stop>
<a-checkbox
v-for="op of options"
:key="op.title"
Expand Down
38 changes: 25 additions & 13 deletions packages/nc-gui/components/cell/Percent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ const _vModel = useVModel(props, 'modelValue', emits)

const wrapperRef = ref<HTMLElement>()

const vModel = computed({
get: () => _vModel.value,
set: (value) => {
if (value === '') {
_vModel.value = null
} else {
_vModel.value = value
}
},
})

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const isForm = inject(IsFormInj)!
Expand All @@ -46,13 +35,32 @@ const cellFocused = ref(false)

const expandedEditEnabled = ref(false)

const vModel = computed({
get: () => {
return isForm.value && !isEditColumn.value && _vModel.value && !cellFocused.value && !isNaN(Number(_vModel.value))
? `${_vModel.value}%`
: _vModel.value
},
set: (value) => {
if (value === '') {
_vModel.value = null
} else if (isForm.value && !isEditColumn.value) {
_vModel.value = isNaN(Number(value)) ? value : Number(value)
} else {
_vModel.value = value
}
},
})

const percentMeta = computed(() => {
return {
is_progress: false,
...parseProp(column.value?.meta),
}
})

const inputType = computed(() => (isForm.value && !isEditColumn.value ? 'text' : 'number'))

const => {
if (editEnabled) {
editEnabled.value = false
Expand Down Expand Up @@ -106,7 +114,11 @@ const KeyboardEvent) => {
)

for (let i = focusesNcCellIndex - 1; i >= 0; i--) {
const lastFormItem = nodes[i].querySelector('[tabindex="0"]') as HTMLElement
const node = nodes[i]
const lastFormItem = (node.querySelector('[tabindex="0"]') ??
node.querySelector('input') ??
node.querySelector('textarea') ??
node.querySelector('button')) as HTMLElement
if (lastFormItem) {
lastFormItem.focus()
break
Expand All @@ -132,7 +144,7 @@ const KeyboardEvent) => {
:ref="focus"
v-model="vModel"
class="nc-cell-field w-full !text-sm !border-none !outline-none focus:ring-0 text-base py-1"
type="number"
:type="inputType"
:placeholder="isEditColumn ? $t('labels.optional') : ''"
@blur="onBlur"
@focus="onFocus"
Expand Down
22 changes: 21 additions & 1 deletion packages/nc-gui/components/cell/SingleSelect.vue
< 2615 tr data-hunk="8c7610e587d4872ce5802910d5999e1e7904faceb43e9deaaad991ca8c2d6066" class="show-top-border">
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,26 @@ const KeyboardEvent) => {
if (e.key === 'Escape') {
isOpen.value = false

if (isForm.value) return

setTimeout(() => {
aselect.value?.$el.querySelector('.ant-select-selection-search > input').focus()
}, 100)
}
}

const handleKeyDownList = (e: KeyboardEvent) => {
switch (e.key) {
case 'ArrowUp':
case 'ArrowDown':
case 'ArrowRight':
case 'ArrowLeft':
// skip
e.stopPropagation()
break
}
}

const => {
isOpen.value = false
isEditable.value = false
Expand Down Expand Up @@ -315,7 +329,13 @@ const => {
@keydown.enter.stop.prevent="toggleMenu"
>
<div v-if="!isEditColumn && isForm && parseProp(column.meta)?.isList" class="w-full max-w-full">
<a-radio-group v-model:value="vModel" :disabled="readOnly || !editAllowed" class="nc-field-layout-list">
<a-radio-group
v-model:value="vModel"
:disabled="readOnly || !editAllowed"
class="nc-field-layout-list"
@keydown="handleKeyDownList"
@click.stop
>
<a-radio
v-for="op of options"
:key="op.title"
Expand Down
21 changes: 12 additions & 9 deletions packages/nc-gui/components/cell/Url.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
EditModeInj,
IsExpandedFormOpenInj,
IsFormInj,
IsSurveyFormInj,
ReadonlyInj,
computed,
inject,
Expand Down Expand Up @@ -42,18 +41,20 @@ const disableOverlay = inject(CellUrlDisableOverlayInj, ref(false))

const rowHeight = inject(RowHeightInj, ref(undefined))

const isSurveyForm = inject(IsSurveyFormInj, ref(false))

const readOnly = inject(ReadonlyInj, ref(false))

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const isForm = inject(IsFormInj)!

// Used in the logic of when to display error since we are not storing the url if it's not valid
const localState = ref(value)

const vModel = computed({
get: () => value,
set: (val) => {
localState.value = val
if (!parseProp(column.value.meta)?.validate || (val && isValidURL(val)) || !val || isSurveyForm.value) {
if (!parseProp(column.value.meta)?.validate || (val && isValidURL(val)) || !val || isForm.value) {
emit('update:modelValue', val)
}
},
Expand All @@ -72,17 +73,19 @@ const url = computed(() => {

const { cellUrlOptions } = useCellUrlConfig(url)

const isExpandedFormOpen = inject(IsExpandedFormOpenInj, ref(false))!

const isForm = inject(IsFormInj)!

const focus: VNodeRef = (el) =>
!isExpandedFormOpen.value && !isEditColumn.value && !isForm.value && (el as HTMLInputElement)?.focus()

watch(
() => editEnabled.value,
() => {
if (parseProp(column.value.meta)?.validate && !editEnabled.value && localState.value && !isValidURL(localState.value)) {
if (
!isForm.value &&
parseProp(column.value.meta)?.validate &&
!editEnabled.value &&
localState.value &&
!isValidURL(localState.value)
) {
message.error(t('msg.error.invalidURL'))
localState.value = undefined
return
Expand Down
17 changes: 15 additions & 2 deletions packages/nc-gui/components/cell/attachment/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,19 @@ const any) => {

selectedImage.value = item
}

const keydownEnter = (e: KeyboardEvent) => {
if (!isSurveyForm.value) {
open(e)
e.stopPropagation()
}
}
const keydownSpace = (e: KeyboardEvent) => {
if (isSurveyForm.value) {
open(e)
e.stopPropagation()
}
}
</script>

<template>
Expand Down Expand Up @@ -211,8 +224,8 @@ const any) => {
data-testid="attachment-cell-file-picker-button"
tabindex="0"
@click="open"
@keydown.enter="!isSurveyForm ? open($event) : undefined"
@keydown.space="isSurveyForm ? open($event) : undefined"
@keydown.enter="keydownEnter"
@keydown.space="keydownSpace"
>
<component :is="iconMap.reload" v-if="isLoading" :class="{ 'animate-infinite animate-spin': isLoading }" />

Expand Down
Loading
0