fix optional chaining error and adds guard for no model selected.
This commit is contained in:
parent
7b92482a8d
commit
48d7ff19c9
|
@ -113,7 +113,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<DropdownMenu
|
||||
class="menu"
|
||||
bind:this={dropdown}
|
||||
on:click={hideDropdown}
|
||||
width="170px"
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
"@budibase/client": "^0.1.25",
|
||||
"@rollup/plugin-commonjs": "^11.1.0",
|
||||
"lodash": "^4.17.15",
|
||||
"rollup": "^1.11.0",
|
||||
"rollup": "^2.11.2",
|
||||
"rollup-plugin-commonjs": "^10.0.2",
|
||||
"rollup-plugin-json": "^4.0.0",
|
||||
"rollup-plugin-livereload": "^1.0.1",
|
||||
"rollup-plugin-node-resolve": "^5.0.0",
|
||||
"rollup-plugin-postcss": "^3.1.5",
|
||||
"rollup-plugin-svelte": "^5.0.0",
|
||||
"rollup-plugin-svelte": "^5.0.3",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
"shortid": "^2.2.15",
|
||||
"sirv-cli": "^0.4.4",
|
||||
|
@ -48,4 +48,4 @@
|
|||
"svelte-flatpickr": "^2.4.0",
|
||||
"svelte-fusioncharts": "^1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ import svelte from "rollup-plugin-svelte"
|
|||
import resolve from "rollup-plugin-node-resolve"
|
||||
import commonjs from "@rollup/plugin-commonjs"
|
||||
import postcss from "rollup-plugin-postcss"
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
|
||||
const lodash_fp_exports = ["isEmpty"]
|
||||
|
||||
|
@ -16,6 +17,7 @@ export default {
|
|||
},
|
||||
],
|
||||
plugins: [
|
||||
terser(),
|
||||
postcss({
|
||||
plugins: [],
|
||||
}),
|
||||
|
|
|
@ -24,29 +24,32 @@
|
|||
let model
|
||||
|
||||
onMount(async () => {
|
||||
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) => {
|
||||
return {
|
||||
headerCheckboxSelection: i === 0,
|
||||
checkboxSelection: i === 0,
|
||||
valueSetter: setters.get(schema[key].type),
|
||||
headerName: key.charAt(0).toUpperCase() + key.slice(1),
|
||||
field: key,
|
||||
hide: shouldHideField(key),
|
||||
sortable: true,
|
||||
editable:
|
||||
schema[key].type !== "boolean" && schema[key].type !== "attachment",
|
||||
cellRenderer: renderers.get(schema[key].type),
|
||||
autoHeight: schema[key].type === "attachment",
|
||||
}
|
||||
})
|
||||
if (datasource.modelId) {
|
||||
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) => {
|
||||
return {
|
||||
headerCheckboxSelection: i === 0,
|
||||
checkboxSelection: i === 0,
|
||||
valueSetter: setters.get(schema[key].type),
|
||||
headerName: key.charAt(0).toUpperCase() + key.slice(1),
|
||||
field: key,
|
||||
hide: shouldHideField(key),
|
||||
sortable: true,
|
||||
editable:
|
||||
schema[key].type !== "boolean" &&
|
||||
schema[key].type !== "attachment",
|
||||
cellRenderer: renderers.get(schema[key].type),
|
||||
autoHeight: schema[key].type === "attachment",
|
||||
}
|
||||
})
|
||||
}
|
||||
dataLoaded = true
|
||||
}
|
||||
dataLoaded = true
|
||||
})
|
||||
|
||||
const shouldHideField = name => {
|
||||
|
|
Loading…
Reference in New Issue