Browse Source

fix: update form banner & logo url response type

pull/7768/head
Ramesh Mane 6 months ago
parent
commit
dcf41c8f47
  1. 4
      packages/nc-gui/components/general/FormBanner.vue
  2. 7
      packages/nc-gui/components/smartsheet/Form.vue
  3. 22
      packages/nocodb/src/models/FormView.ts
  4. 146
      packages/nocodb/src/schema/swagger-v2.json
  5. 146
      packages/nocodb/src/schema/swagger.json

4
packages/nc-gui/components/general/FormBanner.vue

@ -1,6 +1,8 @@
<script lang="ts" setup>
import type { AttachmentResType } from 'nocodb-sdk';
interface Props {
bannerImageUrl?: string | null
bannerImageUrl?: AttachmentResType
}
const { bannerImageUrl } = defineProps<Props>()

7
packages/nc-gui/components/smartsheet/Form.vue

@ -12,6 +12,7 @@ import {
isLinksOrLTAR,
isSelectTypeCol,
isVirtualCol,
type AttachmentResType,
} from 'nocodb-sdk'
import type { Permission } from '#imports'
import {
@ -503,11 +504,11 @@ onChangeFile((files) => {
}
})
const handleOnUploadImage = (data: Record<string, any> = {}) => {
const handleOnUploadImage = (data: AttachmentResType = '') => {
if (imageCropperData.value.cropFor === 'banner') {
formViewData.value!.banner_image_url = stringifyProp(data) ?? ''
formViewData.value!.banner_image_url = data
} else {
formViewData.value!.logo_url = stringifyProp(data) ?? ''
formViewData.value!.logo_url = data
}
updateView()
}

22
packages/nocodb/src/models/FormView.ts

@ -1,5 +1,9 @@
import type { MetaType } from 'nocodb-sdk';
import type { BoolType, FormType } from 'nocodb-sdk';
import type {
MetaType,
BoolType,
FormType,
AttachmentResType,
} from 'nocodb-sdk';
import { PresignedUrl } from '~/models';
import FormViewColumn from '~/models/FormViewColumn';
import View from '~/models/View';
@ -21,8 +25,8 @@ export default class FormView implements FormType {
redirect_url?: string;
redirect_after_secs?: string;
email?: string;
banner_image_url?: string;
logo_url?: string;
banner_image_url?: AttachmentResType;
logo_url?: AttachmentResType;
submit_another_form?: BoolType;
show_blank_form?: BoolType;
@ -59,8 +63,8 @@ export default class FormView implements FormType {
logo_url: view?.logo_url,
});
view.banner_image_url = serializeJSON(convertedAttachment.banner_image_url);
view.logo_url = serializeJSON(convertedAttachment.logo_url);
view.banner_image_url = convertedAttachment.banner_image_url;
view.logo_url = convertedAttachment.logo_url;
return view && new FormView(view);
}
@ -164,8 +168,8 @@ export default class FormView implements FormType {
return form;
}
static serializeAttachmentJSON(attachment: string) {
if (attachment?.trim()) {
static serializeAttachmentJSON(attachment: AttachmentResType) {
if (attachment) {
return serializeJSON(
extractProps(deserializeJSON(attachment), [
'url',
@ -177,7 +181,7 @@ export default class FormView implements FormType {
]),
);
}
return '';
return attachment;
}
protected static async convertAttachmentType(

146
packages/nocodb/src/schema/swagger-v2.json

@ -5714,7 +5714,12 @@
"examples": {
"Example 1": {
"value": {
"banner_image_url": "{\"path\":\"download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\",\"title\":\"Screenshot 2024-03-01 at 11.24.39AM.png\",\"mimetype\":\"image/png\",\"size\":392533}",
"banner_image_url": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"email": "user@example.com",
"heading": "My Form",
"lock_type": "collaborative",
@ -5755,7 +5760,13 @@
"Example 1": {
"value": {
"source_id": "ds_g4ccx6e77h1dmi",
"banner_image_url": "{\"path\":\"download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\",\"title\":\"Screenshot 2024-03-01 at 11.24.39AM.png\",\"mimetype\":\"image/png\",\"size\":392533,\"signedPath\":\"dltemp/93tI0NcweqZcn7qH/1709286000000/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\"}",
"banner_image_url": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg",
"signedPath": "dltemp/lNoLbqB62Jdo5Rmp/1709308800000/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"columns": [
{
"id": "fvc_ugj9zo5bzocxtl",
@ -11497,6 +11508,70 @@
"id": "6cr1iwhbyxncd"
}
},
"AttachmentRes": {
"description": "Model for Attachment Response",
"oneOf": [
{
"type": "object",
"x-examples": {
"Example 1": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg",
"signedPath": "dltemp/lNoLbqB62Jdo5Rmp/1709308800000/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"Example 2" :{
"mimetype": "image/jpeg",
"size": 146143,
"title": "2 be loved.jpeg",
"url": "https://some-s3-server.com/nc/uploads/2023/10/16/some-key/3niqHLngUKiU2Hupe8.jpeg",
"signedUrl": "https://some-s3-server.com/nc/uploads/2023/10/16/signed-url-misc-info"
}
},
"properties": {
"mimetype": {
"type": "string",
"description": "The mimetype of the attachment"
},
"path": {
"type": "string",
"description": "The attachment stored path"
},
"size": {
"type": "number",
"description": "The size of the attachment"
},
"title": {
"type": "string",
"description": "The title of the attachment used in UI"
},
"url": {
"type": "string",
"description": "The attachment stored url"
},
"signedPath": {
"type": "string",
"description": "Attachment signedPath will allow to access attachment directly"
},
"signedUrl": {
"type": "string",
"description": "Attachment signedUrl will allow to access attachment directly"
}
}
},
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Attachment Response Model",
"x-stoplight": {
"id": ""
}
},
"Audit": {
"description": "Model for Audit",
"examples": [
@ -12978,7 +13053,13 @@
"examples": [
{
"source_id": "ds_g4ccx6e77h1dmi",
"banner_image_url": "{\"path\":\"download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\",\"title\":\"Screenshot 2024-03-01 at 11.24.39AM.png\",\"mimetype\":\"image/png\",\"size\":392533}",
"banner_image_url": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg",
"signedPath": "dltemp/lNoLbqB62Jdo5Rmp/1709308800000/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"columns": [
{
"id": "fvc_ugj9zo5bzocxtl",
@ -13002,7 +13083,13 @@
"fk_model_id": "md_rsu68aqjsbyqtl",
"heading": "My Form",
"lock_type": "collaborative",
"logo_url": "{\"path\":\"download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\",\"title\":\"Screenshot 2024-03-01 at 11.24.39AM.png\",\"mimetype\":\"image/png\",\"size\":392533}",
"logo_url": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg",
"signedPath": "dltemp/lNoLbqB62Jdo5Rmp/1709308800000/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"meta": null,
"redirect_after_secs": null,
"redirect_url": null,
@ -13024,15 +13111,8 @@
}
},
"banner_image_url": {
"description": "Banner Image URL",
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/AttachmentRes",
"description": "Banner Image URL"
},
"columns": {
"type": "array",
@ -13074,15 +13154,8 @@
"example": "collaborative"
},
"logo_url": {
"description": "Logo URL.",
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/AttachmentRes",
"description": "Logo URL."
},
"meta": {
"$ref": "#/components/schemas/Meta",
@ -13127,7 +13200,12 @@
"description": "Model for Form Update Request",
"examples": [
{
"banner_image_url": "{\"path\":\"download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\",\"title\":\"Screenshot 2024-03-01 at 11.24.39AM.png\",\"mimetype\":\"image/png\",\"size\":392533}",
"banner_image_url": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"email": "user@example.com",
"heading": "My Form",
"logo_url": null,
@ -13144,15 +13222,8 @@
"type": "object",
"properties": {
"banner_image_url": {
"description": "Banner Image URL",
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/AttachmentReq",
"description": "Banner Image URL"
},
"email": {
"$ref": "#/components/schemas/StringOrNull",
@ -13165,15 +13236,8 @@
"type": "string"
},
"logo_url": {
"description": "Logo URL.",
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/AttachmentReq",
"description": "Logo URL."
},
"meta": {
"$ref": "#/components/schemas/Meta",

146
packages/nocodb/src/schema/swagger.json

@ -7426,7 +7426,12 @@
"examples": {
"Example 1": {
"value": {
"banner_image_url": "{\"path\":\"download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\",\"title\":\"Screenshot 2024-03-01 at 11.24.39AM.png\",\"mimetype\":\"image/png\",\"size\":392533}",
"banner_image_url": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"email": "user@example.com",
"heading": "My Form",
"lock_type": "collaborative",
@ -7467,7 +7472,13 @@
"Example 1": {
"value": {
"source_id": "ds_g4ccx6e77h1dmi",
"banner_image_url": "{\"path\":\"download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\",\"title\":\"Screenshot 2024-03-01 at 11.24.39AM.png\",\"mimetype\":\"image/png\",\"size\":392533,\"signedPath\":\"dltemp/93tI0NcweqZcn7qH/1709286000000/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\"}",
"banner_image_url": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg",
"signedPath": "dltemp/lNoLbqB62Jdo5Rmp/1709308800000/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"columns": [
{
"id": "fvc_ugj9zo5bzocxtl",
@ -17093,6 +17104,70 @@
"id": "6cr1iwhbyxncd"
}
},
"AttachmentRes": {
"description": "Model for Attachment Response",
"oneOf": [
{
"type": "object",
"x-examples": {
"Example 1": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg",
"signedPath": "dltemp/lNoLbqB62Jdo5Rmp/1709308800000/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"Example 2" :{
"mimetype": "image/jpeg",
"size": 146143,
"title": "2 be loved.jpeg",
"url": "https://some-s3-server.com/nc/uploads/2023/10/16/some-key/3niqHLngUKiU2Hupe8.jpeg",
"signedUrl": "https://some-s3-server.com/nc/uploads/2023/10/16/signed-url-misc-info"
}
},
"properties": {
"mimetype": {
"type": "string",
"description": "The mimetype of the attachment"
},
"path": {
"type": "string",
"description": "The attachment stored path"
},
"size": {
"type": "number",
"description": "The size of the attachment"
},
"title": {
"type": "string",
"description": "The title of the attachment used in UI"
},
"url": {
"type": "string",
"description": "The attachment stored url"
},
"signedPath": {
"type": "string",
"description": "Attachment signedPath will allow to access attachment directly"
},
"signedUrl": {
"type": "string",
"description": "Attachment signedUrl will allow to access attachment directly"
}
}
},
{
"type": "string"
},
{
"type": "null"
}
],
"title": "Attachment Response Model",
"x-stoplight": {
"id": ""
}
},
"FileReq": {
"description": "Model for File Request",
"type": "object",
@ -18620,7 +18695,13 @@
"examples": [
{
"source_id": "ds_g4ccx6e77h1dmi",
"banner_image_url": "{\"path\":\"download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\",\"title\":\"Screenshot 2024-03-01 at 11.24.39AM.png\",\"mimetype\":\"image/png\",\"size\":392533}",
"banner_image_url": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg",
"signedPath": "dltemp/lNoLbqB62Jdo5Rmp/1709308800000/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"columns": [
{
"id": "fvc_ugj9zo5bzocxtl",
@ -18644,7 +18725,13 @@
"fk_model_id": "md_rsu68aqjsbyqtl",
"heading": "My Form",
"lock_type": "collaborative",
"logo_url": "{\"path\":\"download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\",\"title\":\"Screenshot 2024-03-01 at 11.24.39AM.png\",\"mimetype\":\"image/png\",\"size\":392533}",
"logo_url": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg",
"signedPath": "dltemp/lNoLbqB62Jdo5Rmp/1709308800000/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"meta": null,
"redirect_after_secs": null,
"redirect_url": null,
@ -18666,15 +18753,8 @@
}
},
"banner_image_url": {
"description": "Banner Image URL",
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/AttachmentRes",
"description": "Banner Image URL"
},
"columns": {
"type": "array",
@ -18716,15 +18796,8 @@
"example": "collaborative"
},
"logo_url": {
"description": "Logo URL",
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/AttachmentRes",
"description": "Logo URL"
},
"meta": {
"$ref": "#/components/schemas/Meta",
@ -18769,7 +18842,12 @@
"description": "Model for Form Update Request",
"examples": [
{
"banner_image_url": "{\"path\":\"download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//7XeRtAlAOch-9THAFI.png\",\"title\":\"Screenshot 2024-03-01 at 11.24.39AM.png\",\"mimetype\":\"image/png\",\"size\":392533}",
"banner_image_url": {
"mimetype": "image/jpg",
"size": 32903,
"title": "Random-Pictures-of-Conceptual-and-Creative-Ideas-02.jpg",
"path": "download/noco/pm0umqsip16i1u5/m8yn03dncqal6ri//iDL5ednaHz2j2Sa3Cl.jpg"
},
"email": "user@example.com",
"heading": "My Form",
"logo_url": null,
@ -18786,15 +18864,8 @@
"type": "object",
"properties": {
"banner_image_url": {
"description": "Banner Image URL",
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/AttachmentRes",
"description": "Banner Image URL"
},
"email": {
"$ref": "#/components/schemas/StringOrNull",
@ -18807,15 +18878,8 @@
"type": "string"
},
"logo_url": {
"description": "Logo URL",
"oneOf": [
{
"type": "string"
},
{
"type": "null"
}
]
"$ref": "#/components/schemas/AttachmentRes",
"description": "Logo URL"
},
"meta": {
"$ref": "#/components/schemas/Meta",

Loading…
Cancel
Save