turns off some functionality and adds theme options

This commit is contained in:
kevmodrome 2020-10-12 11:44:43 +02:00
parent ad5103786d
commit 5bafa97c40
7 changed files with 53 additions and 30 deletions

View File

@ -332,6 +332,13 @@ export default {
valueKey: "checked", valueKey: "checked",
control: Checkbox, control: Checkbox,
}, },
{
label: "Theme",
key: "theme",
control: OptionSelect,
options: ["alpine", "alpine-dark", "balham", "balham-dark", "material"],
placeholder: "alpine",
},
], ],
}, },
children: [], children: [],

View File

@ -226,7 +226,18 @@
"data": true, "data": true,
"props": { "props": {
"datasource": "models", "datasource": "models",
"editable": "bool" "editable": "bool",
"theme": {
"type": "options",
"default": "alpine",
"options": [
"alpine",
"alpine-dark",
"balham",
"balham-dark",
"material"
]
}
} }
}, },
"dataform": { "dataform": {

View File

@ -26,7 +26,7 @@
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"shortid": "^2.2.15", "shortid": "^2.2.15",
"sirv-cli": "^0.4.4", "sirv-cli": "^0.4.4",
"svelte": "^3.28.0" "svelte": "^3.29.0"
}, },
"keywords": [ "keywords": [
"svelte" "svelte"
@ -37,15 +37,16 @@
"dependencies": { "dependencies": {
"@beyonk/svelte-googlemaps": "^2.2.0", "@beyonk/svelte-googlemaps": "^2.2.0",
"@budibase/bbui": "^1.41.0", "@budibase/bbui": "^1.41.0",
"@budibase/svelte-ag-grid": "^0.0.11", "@budibase/svelte-ag-grid": "^0.0.12",
"@fortawesome/fontawesome-free": "^5.14.0", "@fortawesome/fontawesome-free": "^5.14.0",
"@svelteschool/svelte-forms": "^0.7.0", "@svelteschool/svelte-forms": "^0.7.0",
"britecharts": "^2.16.1", "britecharts": "^2.16.1",
"d3-selection": "^1.4.2", "d3-selection": "^1.4.2",
"fast-sort": "^2.2.0", "fast-sort": "^2.2.0",
"flatpickr": "^4.6.6",
"fusioncharts": "^3.15.1-sr.1", "fusioncharts": "^3.15.1-sr.1",
"lodash.debounce": "^4.0.8", "lodash.debounce": "^4.0.8",
"svelte-flatpickr": "^2.4.0", "svelte-flatpickr": "^3.1.0",
"svelte-fusioncharts": "^1.0.0" "svelte-fusioncharts": "^1.0.0"
} }
} }

View File

@ -12,22 +12,22 @@
export let files export let files
</script> </script>
<div bind:this={anchor}> <AttachmentList {files} />
<!-- <div bind:this={anchor}>
<Button text small on:click={dropdown.show}> <Button text small on:click={dropdown.show}>
<Icon name="edit" /> <Icon name="edit" />
</Button> </Button>
<AttachmentList {files} />
</div> </div>
<DropdownMenu bind:this={dropdown} {anchor} align="left"> <DropdownMenu bind:this={dropdown} {anchor} align="left">
<h5>Edit Attachment(s)</h5> <h5>Edit Attachment(s)</h5>
<!-- <Modal <Modal
{_bb} {_bb}
{model} {model}
onClosed={dropdown.hide} onClosed={dropdown.hide}
on:newRecord={() => dispatch('newRecord')} /> --> on:newRecord={() => dispatch('newRecord')} />
</DropdownMenu> </DropdownMenu> -->
<style> <!-- <style>
div { div {
display: grid; display: grid;
grid-template-columns: auto auto; grid-template-columns: auto auto;
@ -38,4 +38,4 @@
margin: 0; margin: 0;
font-weight: 500; font-weight: 500;
} }
</style> </style> -->

View File

@ -17,6 +17,7 @@
export let _bb export let _bb
export let datasource = {} export let datasource = {}
export let editable export let editable
export let theme = 'alpine'
let dataLoaded = false let dataLoaded = false
let data let data
@ -29,7 +30,7 @@
minWidth: 150, minWidth: 150,
filter: true, filter: true,
}, },
rowSelection: editable ? "multiple" : "single", rowSelection: editable ? "multiple" : false,
suppressRowClickSelection: !editable, suppressRowClickSelection: !editable,
} }
@ -50,12 +51,7 @@
hide: shouldHideField(key), hide: shouldHideField(key),
sortable: true, sortable: true,
editable: editable && isEditable(schema[key].type), editable: editable && isEditable(schema[key].type),
cellRenderer: cellRenderer: editable && getRenderer(schema[key]),
editable &&
getRenderer(
schema[key].type, // type
schema[key].constraints // options
),
autoHeight: true, autoHeight: true,
} }
}) })
@ -67,8 +63,8 @@
const isEditable = type => const isEditable = type =>
type !== "boolean" && type !== "boolean" &&
type !== "options" && type !== "options" &&
type !== "attachment" && // type !== "datetime" &&
type !== "datetime" type !== "attachment"
const shouldHideField = name => { const shouldHideField = name => {
if (name.startsWith("_")) return true if (name.startsWith("_")) return true
@ -107,6 +103,12 @@
} }
</script> </script>
<svelte:head>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css" />
</svelte:head>
<div class="container"> <div class="container">
{#if dataLoaded} {#if dataLoaded}
{#if editable} {#if editable}
@ -121,6 +123,7 @@
</div> </div>
{/if} {/if}
<AgGrid <AgGrid
{theme}
{options} {options}
{data} {data}
{columnDefs} {columnDefs}
@ -131,7 +134,7 @@
<style> <style>
.container { .container {
--grid-height: 400px; --grid-height: 800px;
} }
.container :global(form) { .container :global(form) {
display: grid; display: grid;

View File

@ -0,0 +1,5 @@
<script>
import { DatePicker } from "@budibase/bbui"
</script>
<DatePicker />

View File

@ -3,19 +3,18 @@
import AttachmentCell from './AttachmentCell/Button.svelte' import AttachmentCell from './AttachmentCell/Button.svelte'
import Select from './Select/Wrapper.svelte' import Select from './Select/Wrapper.svelte'
import { DatePicker } from "@budibase/bbui" import DatePicker from "./DateTime/Wrapper.svelte"
const renderers = new Map([ const renderers = new Map([
["boolean", booleanRenderer], ["boolean", booleanRenderer],
["attachment", attachmentRenderer], ["attachment", attachmentRenderer],
["datetime", dateRenderer],
["options", optionsRenderer], ["options", optionsRenderer],
]) ])
export function getRenderer(type, options) { export function getRenderer({ type, constraints }) {
if (renderers.get(type)) { if (renderers.get(type)) {
return renderers.get(type)(options) return renderers.get(type)(constraints)
} else { } else {
return false return false
} }
@ -50,7 +49,7 @@ function attachmentRenderer(options) {
} }
} }
function dateRenderer(options) { function dateRenderer(options) {
return params => { return function (params) {
const container = document.createElement("div") const container = document.createElement("div")
const toggle = (e) => { const toggle = (e) => {
params.setValue(e.detail[0][0]) params.setValue(e.detail[0][0])
@ -62,12 +61,9 @@ function dateRenderer(options) {
target: container, target: container,
props: { props: {
value: params.value, value: params.value,
thin: true
} }
}); });
datePickerInstance.$on('change', toggle)
return container return container
} }
} }