data now syncs in the grid
This commit is contained in:
parent
193f536834
commit
e501679813
|
@ -57,13 +57,11 @@
|
|||
return false
|
||||
}
|
||||
|
||||
const handleSubmit = e => {
|
||||
// Send off data here and update to display in grid component
|
||||
console.log("Submitting:", e.detail)
|
||||
const handleNewRecord = async () => {
|
||||
data = await fetchData(datasource)
|
||||
}
|
||||
|
||||
const handleUpdate = ({ detail }) => {
|
||||
console.log(detail)
|
||||
data[detail.row] = detail.data
|
||||
updateRecord(detail.data)
|
||||
}
|
||||
|
@ -74,11 +72,9 @@
|
|||
record
|
||||
)
|
||||
const json = await response.json()
|
||||
console.log(json)
|
||||
}
|
||||
|
||||
const deleteRecords = async () => {
|
||||
console.log(_bb.api)
|
||||
const response = await _bb.api.post(`/api/${datasource.name}/records`, {
|
||||
records: selectedRows,
|
||||
type: "delete",
|
||||
|
@ -91,7 +87,7 @@
|
|||
<div class="container">
|
||||
{#if dataLoaded}
|
||||
<div class="controls">
|
||||
<CreateRowButton {_bb} {model} />
|
||||
<CreateRowButton {_bb} {model} on:newRecord={handleNewRecord} />
|
||||
{#if selectedRows.length > 0}
|
||||
<DeleteButton text small on:click={deleteRecords}>
|
||||
<Icon name="addrow" />
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
<script>
|
||||
import { createEventDispatcher } from "svelte"
|
||||
import { DropdownMenu, TextButton as Button, Icon } from "@budibase/bbui"
|
||||
import Modal from "./Modal.svelte"
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
let anchor
|
||||
let dropdown
|
||||
|
||||
|
@ -16,7 +19,11 @@
|
|||
</div>
|
||||
<DropdownMenu bind:this={dropdown} {anchor} align="left">
|
||||
<h5>Add New Row</h5>
|
||||
<Modal {_bb} {model} onClosed={dropdown.hide} />
|
||||
<Modal
|
||||
{_bb}
|
||||
{model}
|
||||
onClosed={dropdown.hide}
|
||||
on:newRecord={() => dispatch('newRecord')} />
|
||||
</DropdownMenu>
|
||||
|
||||
<style>
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<script>
|
||||
import { onMount } from "svelte"
|
||||
import { onMount, createEventDispatcher } from "svelte"
|
||||
import { fade } from "svelte/transition"
|
||||
import { Button, Label, DatePicker } from "@budibase/bbui"
|
||||
import Dropzone from "../../attachments/Dropzone.svelte"
|
||||
import debounce from "lodash.debounce"
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
const DEFAULTS_FOR_TYPE = {
|
||||
string: "",
|
||||
|
@ -43,8 +44,6 @@
|
|||
|
||||
const json = await response.json()
|
||||
|
||||
console.log(json)
|
||||
|
||||
if (response.status === 200) {
|
||||
store.update(state => {
|
||||
state[model._id] = state[model._id]
|
||||
|
@ -60,6 +59,7 @@
|
|||
record = isNew ? { modelId: model._id } : json
|
||||
|
||||
onClosed()
|
||||
dispatch("newRecord")
|
||||
}
|
||||
|
||||
if (response.status === 400) {
|
||||
|
|
Loading…
Reference in New Issue