kevmodrome
6 years ago
No known key found for this signature in database
GPG Key ID: E8F9CD141E63BF38
2 changed files with
24 additions and
3 deletions
-
packages/standard-components/package.json
-
packages/standard-components/src/DataGrid/Component.svelte
|
|
|
@ -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" |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -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) |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<div class="container"> |
|
|
|
{#if dataLoaded} |
|
|
|
<AgGrid bind:data {columnDefs} /> |
|
|
|
<AgGrid {data} {columnDefs} on:update={handleUpdate} /> |
|
|
|
<InputForm fields={columnDefs} on:submit={handleSubmit} /> |
|
|
|
{/if} |
|
|
|
</div> |
|
|
|
<pre>{JSON.stringify(data, 0, 2)}</pre> |
|
|
|
|
|
|
|
<style> |
|
|
|
.container { |
|
|
|
|