From 6c173ac6b36fc6699101eed2c8bd0c40d9f581ec Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Wed, 7 Oct 2020 10:06:23 +0200 Subject: [PATCH] fixes editable cell bug --- .../src/DataGrid/AttachmentCell/Button.svelte | 41 +++++++++++++++++++ .../src/DataGrid/AttachmentCell/Modal.svelte | 0 .../src/DataGrid/Component.svelte | 3 +- .../src/DataGrid/customRenderer.js | 6 +-- .../src/attachments/AttachmentList.svelte | 14 ++----- 5 files changed, 49 insertions(+), 15 deletions(-) create mode 100644 packages/standard-components/src/DataGrid/AttachmentCell/Button.svelte create mode 100644 packages/standard-components/src/DataGrid/AttachmentCell/Modal.svelte diff --git a/packages/standard-components/src/DataGrid/AttachmentCell/Button.svelte b/packages/standard-components/src/DataGrid/AttachmentCell/Button.svelte new file mode 100644 index 0000000000..720cd78f42 --- /dev/null +++ b/packages/standard-components/src/DataGrid/AttachmentCell/Button.svelte @@ -0,0 +1,41 @@ + + +
+ + +
+ +
Edit Attachment(s)
+ +
+ + diff --git a/packages/standard-components/src/DataGrid/AttachmentCell/Modal.svelte b/packages/standard-components/src/DataGrid/AttachmentCell/Modal.svelte new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/standard-components/src/DataGrid/Component.svelte b/packages/standard-components/src/DataGrid/Component.svelte index f1ce5e6446..4ab465bfbc 100644 --- a/packages/standard-components/src/DataGrid/Component.svelte +++ b/packages/standard-components/src/DataGrid/Component.svelte @@ -31,6 +31,7 @@ const jsonModel = await _bb.api.get(`/api/models/${datasource.modelId}`) model = await jsonModel.json() const { schema } = model + console.log(schema) if (!isEmpty(datasource)) { data = await fetchData(datasource) columnDefs = Object.keys(schema).map((key, i) => { @@ -43,7 +44,7 @@ hide: shouldHideField(key), sortable: true, editable: - schema[key].type !== "boolean" || schema[key].type !== "attachment", + schema[key].type !== "boolean" && schema[key].type !== "attachment", cellRenderer: renderers.get(schema[key].type), autoHeight: schema[key].type === "attachment", } diff --git a/packages/standard-components/src/DataGrid/customRenderer.js b/packages/standard-components/src/DataGrid/customRenderer.js index 301817f0c4..3d5966aeb0 100644 --- a/packages/standard-components/src/DataGrid/customRenderer.js +++ b/packages/standard-components/src/DataGrid/customRenderer.js @@ -1,7 +1,7 @@ // Custom renderers to handle special types // https://www.ag-grid.com/javascript-grid-cell-rendering-components/ -import AttachmentList from '../attachments/AttachmentList.svelte' +import AttachmentCell from './AttachmentCell/Button.svelte' export const booleanRenderer = (params) => { const toggle = (e) => { @@ -18,11 +18,9 @@ export const booleanRenderer = (params) => { export const attachmentRenderer = (params) => { let container = document.createElement("div") - const app = new AttachmentList({ + const attachment = new AttachmentCell({ target: container, props: { - // assuming App.svelte contains something like - // `export let answer`: files: params.value || [], } }); diff --git a/packages/standard-components/src/attachments/AttachmentList.svelte b/packages/standard-components/src/attachments/AttachmentList.svelte index b116070ed7..eca7fbc582 100644 --- a/packages/standard-components/src/attachments/AttachmentList.svelte +++ b/packages/standard-components/src/attachments/AttachmentList.svelte @@ -1,18 +1,12 @@ -
+