diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 2c2354d5d0..649f78b95a 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -37,7 +37,7 @@ "dependencies": { "@beyonk/svelte-googlemaps": "^2.2.0", "@budibase/bbui": "^1.34.6", - "@budibase/svelte-ag-grid": "^0.0.6", + "@budibase/svelte-ag-grid": "^0.0.8", "@fortawesome/fontawesome-free": "^5.14.0", "@svelteschool/svelte-forms": "^0.7.0", "britecharts": "^2.16.1", @@ -48,4 +48,4 @@ "svelte-flatpickr": "^2.4.0", "svelte-fusioncharts": "^1.0.0" } -} +} \ No newline at end of file diff --git a/packages/standard-components/src/DataGrid/Component.svelte b/packages/standard-components/src/DataGrid/Component.svelte index 66372f5997..0f276bad0d 100644 --- a/packages/standard-components/src/DataGrid/Component.svelte +++ b/packages/standard-components/src/DataGrid/Component.svelte @@ -6,6 +6,7 @@ import AgGrid from "@budibase/svelte-ag-grid" import InputForm from "./InputForm.svelte" + export let _bb export let datasource = {} let dataLoaded = false @@ -13,6 +14,10 @@ let columnDefs onMount(async () => { + console.log(datasource) + const jsonModel = await _bb.api.get(`/api/models/${datasource.modelId}`) + const model = await jsonModel.json() + console.log(model) if (!isEmpty(datasource)) { data = await fetchData(datasource) if (data) { @@ -45,14 +50,30 @@ // Send off data here and update to display in grid component console.log("Submitting:", e.detail) } + + const handleUpdate = ({ detail }) => { + console.log(detail) + data[detail.row] = detail.data + updateRecord(detail.data) + } + + const updateRecord = async record => { + const response = await _bb.api.patch( + `/api/${record.modelId}/records/${record._id}`, + record + ) + const json = await response.json() + console.log(json) + }
{#if dataLoaded} - + {/if}
+
{JSON.stringify(data, 0, 2)}