Browse Source

fix: handle missing col options for button

pull/9469/head
mertmit 2 months ago
parent
commit
6e8750886d
  1. 7
      packages/nc-gui/components/smartsheet/column/ButtonOptions.vue
  2. 13
      packages/nocodb/src/models/Column.ts

7
packages/nc-gui/components/smartsheet/column/ButtonOptions.vue

@ -26,7 +26,8 @@ const vModel = useVModel(props, 'value', emit)
const meta = inject(MetaInj, ref())
const { isEdit, setAdditionalValidations, validateInfos, sqlUi, column, isWebhookCreateModalOpen } = useColumnCreateStoreOrThrow()
const { isEdit, setAdditionalValidations, validateInfos, sqlUi, column, isWebhookCreateModalOpen, validate } =
useColumnCreateStoreOrThrow()
const uiTypesNotSupportedInFormulas = [UITypes.QrCode, UITypes.Barcode, UITypes.Button]
@ -77,7 +78,7 @@ const validators = {
validator: (_: any, formula: any) => {
return (async () => {
if (vModel.value.type === 'url') {
if (!formula?.trim()) throw new Error('Required')
if (!formula?.trim()) throw new Error('Formula is required for URL Button')
try {
await validateFormulaAndExtractTreeWithType({
@ -191,6 +192,8 @@ if ((column.value?.colOptions as any)?.formula_raw) {
meta?.value?.columns as ColumnType[],
(column.value?.colOptions as any)?.formula_raw,
) || ''
} else {
vModel.value.formula_raw = ''
}
const colorClass = {

13
packages/nocodb/src/models/Column.ts

@ -503,6 +503,19 @@ export default class Column<T = any> implements ColumnType {
break;
case UITypes.Button:
res = await ButtonColumn.read(context, this.id, ncMeta);
// add default values if options are missing
if (!res) {
res = {
type: 'url',
theme: 'solid',
color: 'brand',
label: 'Button',
error: 'Invalid configuration',
formula_raw: '',
};
}
break;
case UITypes.QrCode:
res = await QrCodeColumn.read(context, this.id, ncMeta);

Loading…
Cancel
Save