Skip to content

Commit

Permalink
fix(nocodb): FormView model type error
Browse files Browse the repository at this point in the history
  • Loading branch information
rameshmane7218 committed Mar 2, 2024
1 parent 7f5b42b commit 6c788a9
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
10 changes: 5 additions & 5 deletions packages/nc-gui/components/smartsheet/Form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ function setFormData() {
systemFieldsIds.value = getSystemColumns(col).map((c) => c.fk_column_id)
formViewData.value = {
banner_image_url: '',
logo_url: '',
banner_image_url: null,
logo_url: null,
...formViewData.value,
submit_another_form: !!(formViewData.value?.submit_another_form ?? 0),
show_blank_form: !!(formViewData.value?.show_blank_form ?? 0),
Expand Down Expand Up @@ -504,7 +504,7 @@ onChangeFile((files) => {
}
})
const handleOnUploadImage = (data: AttachmentResType = '') => {
const handleOnUploadImage = (data: AttachmentResType = null) => {
if (imageCropperData.value.cropFor === 'banner') {
formViewData.value!.banner_image_url = data
} else {
Expand Down Expand Up @@ -725,7 +725,7 @@ useEventListener(
@click="
() => {
if (isEditable) {
formViewData!.banner_image_url = ''
formViewData!.banner_image_url = null
updateView()
}
}
Expand Down Expand Up @@ -788,7 +788,7 @@ useEventListener(
@click="
() => {
if (isEditable) {
formViewData!.logo_url = ''
formViewData!.logo_url = null
updateView()
}
}
Expand Down
11 changes: 8 additions & 3 deletions packages/nocodb/src/models/FormView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ import { deserializeJSON, serializeJSON } from '~/utils/serialize';
import { CacheGetType, CacheScope, MetaTable } from '~/utils/globals';
import { prepareForDb, prepareForResponse } from '~/utils/modelUtils';

export default class FormView implements FormType {
type FormViewType = Omit<FormType, 'banner_image_url' | 'logo_url'> & {
banner_image_url?: AttachmentResType | string;
logo_url?: AttachmentResType | string;
};

export default class FormView implements FormViewType {
show: BoolType;
is_default: BoolType;
order: number;
Expand Down Expand Up @@ -168,7 +173,7 @@ export default class FormView implements FormType {
return form;
}

static serializeAttachmentJSON(attachment: AttachmentResType) {
static serializeAttachmentJSON(attachment): string | null {
if (attachment) {
return serializeJSON(
extractProps(deserializeJSON(attachment), [
Expand All @@ -193,7 +198,7 @@ export default class FormView implements FormType {

for (const key in formAttachments) {
if (
formAttachments[key]?.trim() &&
formAttachments[key] &&
typeof formAttachments[key] === 'string'
) {
formAttachments[key] = deserializeJSON(formAttachments[key]);
Expand Down
18 changes: 16 additions & 2 deletions packages/nocodb/src/schema/swagger-v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -13216,7 +13216,14 @@
"type": "object",
"properties": {
"banner_image_url": {
"$ref": "#/components/schemas/AttachmentReq",
"oneOf": [
{
"$ref": "#/components/schemas/AttachmentReq"
},
{
"type" : "null"
}
],
"description": "Banner Image URL"
},
"email": {
Expand All @@ -13230,7 +13237,14 @@
"type": "string"
},
"logo_url": {
"$ref": "#/components/schemas/AttachmentReq",
"oneOf": [
{
"$ref": "#/components/schemas/AttachmentReq"
},
{
"type" : "null"
}
],
"description": "Logo URL."
},
"meta": {
Expand Down
18 changes: 16 additions & 2 deletions packages/nocodb/src/schema/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -18858,7 +18858,14 @@
"type": "object",
"properties": {
"banner_image_url": {
"$ref": "#/components/schemas/AttachmentReq",
"oneOf": [
{
"$ref": "#/components/schemas/AttachmentReq"
},
{
"type" : "null"
}
],
"description": "Banner Image URL"
},
"email": {
Expand All @@ -18872,7 +18879,14 @@
"type": "string"
},
"logo_url": {
"$ref": "#/components/schemas/AttachmentReq",
"oneOf": [
{
"$ref": "#/components/schemas/AttachmentReq"
},
{
"type" : "null"
}
],
"description": "Logo URL"
},
"meta": {
Expand Down

0 comments on commit 6c788a9

Please sign in to comment.