From 67aebd410b3f4db599cdcbfa0b48f6710d4b5bf4 Mon Sep 17 00:00:00 2001 From: Shams mosowi Date: Sun, 21 Feb 2021 21:13:08 +0800 Subject: [PATCH] csv import parser for json --- www/package.json | 2 +- www/src/components/fields/Json/index.tsx | 7 +++++++ www/yarn.lock | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/www/package.json b/www/package.json index 1dbc3ada..182c8a28 100644 --- a/www/package.json +++ b/www/package.json @@ -9,7 +9,7 @@ "private": true, "dependencies": { "@antlerengineering/form-builder": "^0.9.7", - "@antlerengineering/multiselect": "^0.8.0", + "@antlerengineering/multiselect": "^0.8.2", "@date-io/date-fns": "1.x", "@material-ui/core": "^4.11.0", "@material-ui/icons": "^4.9.1", diff --git a/www/src/components/fields/Json/index.tsx b/www/src/components/fields/Json/index.tsx index ec995096..cc151631 100644 --- a/www/src/components/fields/Json/index.tsx +++ b/www/src/components/fields/Json/index.tsx @@ -25,6 +25,13 @@ export const config: IFieldConfig = { description: "JSON object editable with a visual JSON editor.", TableCell: withBasicCell(BasicCell), TableEditor: withSideDrawerEditor(BasicCell), + csvImportParser: (value) => { + try { + return JSON.parse(value); + } catch (e) { + return null; + } + }, SideDrawerField, settings: Settings, }; diff --git a/www/yarn.lock b/www/yarn.lock index b8a2a9e9..f560dc27 100644 --- a/www/yarn.lock +++ b/www/yarn.lock @@ -129,6 +129,11 @@ resolved "https://registry.yarnpkg.com/@antlerengineering/multiselect/-/multiselect-0.8.0.tgz#3faec82c8ef3055c01f2c7b37a874b9d079381e8" integrity sha512-w0Sg23T9Ob2xuAWT2gGc9rtElCMjZUUbB2Jx1zs1Gef81yN7ZM0RB0EwG+rMd/L1i+NI2Kr7MtF2P26llWVDyg== +"@antlerengineering/multiselect@^0.8.2": + version "0.8.2" + resolved "https://registry.yarnpkg.com/@antlerengineering/multiselect/-/multiselect-0.8.2.tgz#160294f75a5772aa2ceecdff3dd837520f5b90c8" + integrity sha512-u/J59NkTBMU8voB3RuvVo6OCZLg4mG+gOQQ1vT/hrCw66oPE48+nDmPQEZDhrGwXWSrsqaYNNbt8zjF6sdkYMQ== + "@apidevtools/json-schema-ref-parser@^9.0.3": version "9.0.6" resolved "https://registry.yarnpkg.com/@apidevtools/json-schema-ref-parser/-/json-schema-ref-parser-9.0.6.tgz#5d9000a3ac1fd25404da886da6b266adcd99cf1c"