8000 Nc fix/form view bug fixes by rameshmane7218 · Pull Request #8498 · 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 #8498

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 5 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 6 additions & 2 deletions packages/nc-gui/assets/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ body {
--navbar-bg: #fafafa;
--navbar-border: #e0e0e0;
--nc-grid-bg: #fdfdfd;

--ant-primary-color-hover: #5c85ff !important;
--ant-primary-color-active: #3366ff !important;
--ant-primary-color-outline: rgba(51, 102, 255, 0.24) !important;
}

::-moz-selection {
Expand Down Expand Up @@ -810,6 +814,6 @@ svg.nc-virtual-cell-icon {
box-shadow: 0 0 0 2px #fff, 0 0 0 4px #3366ff;
}

.text-nowrap{
.text-nowrap {
text-wrap: nowrap;
}
}
19 changes: 17 additions & 2 deletions packages/nc-gui/components/smartsheet/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ useEventListener(
<Pane min-size="30" size="50" class="nc-form-right-splitpane-item p-4 flex flex-col space-y-4 !min-h-200px">
<div class="flex flex-wrap justify-between items-center gap-2">
<div class="flex gap-3">
<div class="text-base font-bold text-gray-900">
<div class="text-base font-bold text-gray-600">
{{ $t('objects.viewType.form') }} {{ $t('objects.fields') }}
</div>
<NcBadge color="border-gray-200">
Expand Down Expand Up @@ -1633,7 +1633,7 @@ useEventListener(
<LazyCellRichText
v-if="!isLocked && isEditable"
v-model:value="formViewData.success_msg"
class="nc-form-after-submit-msg"
class="nc-form-after-submit-msg editable"
is-form-field
:hidden-bubble-menu-options="hiddenBubbleMenuOptions"
data-testid="nc-form-after-submit-msg"
Expand Down Expand Up @@ -1833,6 +1833,13 @@ useEventListener(
.form-meta-input {
.nc-textarea-rich-editor {
@apply pl-3 pr-4 !rounded-lg !text-sm border-1 border-gray-200 focus-within:border-brand-500;

&:hover {
@apply border-brand-400;
}
10000 &:focus-within {
@apply shadow-selected;
}
}

&.nc-form-input-label .nc-textarea-rich-editor {
Expand All @@ -1848,6 +1855,14 @@ useEventListener(
.nc-form-after-submit-msg {
.nc-textarea-rich-editor {
@apply pl-1 pr-2 pt-2 pb-1 !rounded-lg !text-sm border-1 border-gray-200 focus-within:border-brand-500;

&:hover {
@apply border-brand-400;
}
&:focus-within {
@apply shadow-selected;
}

.ProseMirror {
min-height: 5rem;
max-height: 7.5rem !important;
Expand Down
4 changes: 2 additions & 2 deletions packages/nc-gui/components/smartsheet/form/field-settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const columnSupportsScanning = (elementType: UITypes) =>
<div v-if="isSelectTypeCol(activeField.uidt)" class="w-full flex items-start justify-between gap-3">
<div class="flex-1 max-w-[calc(100%_-_40px)]">
<div class="font-medium text-gray-800">{{ $t('labels.limitOptions') }}</div>
<div class="text-gray-500 mt-2">{{ $t('labels.limitOptionsSubtext') }}.</div>
<div class="text-gray-500 mt-1">{{ $t('labels.limitOptionsSubtext') }}.</div>
<div v-if="activeField.meta.isLimitOption" class="mt-3">
<LazySmartsheetFormLimitOptions
v-model:model-value="activeField.meta.limitOptions"
Expand Down Expand Up @@ -95,7 +95,7 @@ const columnSupportsScanning = (elementType: UITypes) =>
v-if="isSelectTypeCol(activeField.uidt)"
class="nc-form-field-appearance-settings p-4 flex flex-col gap-4 border-b border-gray-200"
>
<div class="text-base font-bold">{{ $t('general.appearance') }}</div>
<div class="text-base font-bold text-gray-600">{{ $t('general.appearance') }}</div>
<div class="flex flex-col gap-6">
<!-- Select type field Options Layout -->
<div>
Expand Down
21 changes: 18 additions & 3 deletions packages/nc-gui/composables/useFormViewStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,24 @@ const [useProvideFormViewStore, useFormViewStore] = useInjectionState(
for (const column of visibleColumns.value) {
let rules: RuleObject[] = [
{
required: isRequired(column, column.required),
message: t('msg.error.fieldRequired'),
...(column.uidt === UITypes.Checkbox && isRequired(column, column.required) ? { type: 'enum', enum: [1, true] } : {}),
validator: (_rule: RuleObject, value: any) => {
return new Promise((resolve, reject) => {
if (isRequired(column, column.required)) {
if (typeof value === 'string') {
value = value.trim()
}

if (
(column.uidt === UITypes.Checkbox && !value) ||
(column.uidt !== UITypes.Checkbox && !requiredFieldValidatorFn(value))
) {
return reject(t('msg.error.fieldRequired'))
}
}

return resolve()
})
},
},
]

Expand Down
33 changes: 19 additions & 14 deletions packages/nc-gui/composables/useSharedFormViewStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,23 +194,28 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
if (!formColumns.value) return rulesObj

for (const column of formColumns.value) {
let rules: RuleObject[] = []

rules.push({
validator: (_rule: RuleObject, value: any) => {
return new Promise((resolve, reject) => {
if (isRequired(column)) {
if (column.uidt === UITypes.Checkbox && !value) {
return reject(t('msg.error.fieldRequired'))
} else if (column.uidt !== UITypes.Checkbox)
if (value === null || !value?.length) {
let rules: RuleObject[] = [
{
validator: (_rule: RuleObject, value: any) => {
return new Promise((resolve, reject) => {
if (isRequired(column)) {
if (typeof value === 'string') {
value = value.trim()
}

if (
(column.uidt === UITypes.Checkbox && !value) ||
(column.uidt !== UITypes.Checkbox && !requiredFieldValidatorFn(value))
) {
return reject(t('msg.error.fieldRequired'))
}
}
return resolve()
})
}

return resolve()
})
},
},
})
]

const additionalRules = extractFieldValidator(parseProp(column.meta).validators ?? [], column)
rules = [...rules, ...additionalRules]
Expand Down
2 changes: 1 addition & 1 deletion packages/nc-gui/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@
"theAcceptedFileTypesAreXlsXlsxXlsmOdsOts": "The accepted file types are .xls, .xlsx, .xlsm, .ods, .ots",
"parameterKeyCannotBeEmpty": "Parameter key cannot be empty",
"duplicateParameterKeysAreNotAllowed": "Duplicate parameter keys are not allowed",
"fieldRequired": "{value} cannot be empty.",
"fieldRequired": "This field cannot be empty.",
"projectNotAccessible": "Base not accessible",
"copyToClipboardError": "Failed to copy to clipboard",
"pasteFromClipboardError": "Failed to paste from clipboard",
Expand Down
31 changes: 31 additions & 0 deletions packages/nc-gui/utils/formValidations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,37 @@ export const formNumberInputValidator = (cal: ColumnType) => {
}
}

export const requiredFieldValidatorFn = (value: unknown) => {
value = unref(value)
if (Array.isArray(value)) return !!value.length

if (value === undefined || value === null) {
return false
}

if (value === false) {
return true
}

if (typeof value === 'object') {
for (let _ in value) return true

return false
}

return !!String(value).length
}

export const isEmptyValidatorValue = (v: Validation) => {
if (v.type === StringValidationType.Regex) {
return v.type && typeof v.regex === 'string' ? !v.regex.trim() : v.regex === null
} else if (v.type && v.value !== undefined) {
return v.type && typeof v.value === 'string' ? !v.value.trim() : v.value === null
}

return false
}

export const extractFieldValidator = (_validators: Validation[], element: ColumnType) => {
const rules: RuleObject[] = []

Expand Down
3 changes: 3 additions & 0 deletions packages/nc-gui/windi.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ export default defineConfig({
primary: 'rgba(var(--color-primary), var(--tw-ring-opacity))',
accent: 'rgba(var(--color-accent), var(--tw-ring-opacity))',
},
boxShadow: {
selected: '0px 0px 0px 2px var(--ant-primary-color-outline)',
},
colors: {
...windiColors,
...themeColors,
Expand Down
Loading
0