adds editable setting

This commit is contained in:
kevmodrome 2020-10-09 12:42:16 +02:00
parent a061d1d5b1
commit a117a18d0f
5 changed files with 39 additions and 91 deletions

View File

@ -326,6 +326,12 @@ export default {
key: "datasource", key: "datasource",
control: ModelViewSelect, control: ModelViewSelect,
}, },
{
label: "Editable",
key: "editable",
valueKey: "checked",
control: Checkbox,
},
], ],
}, },
children: [], children: [],

View File

@ -1,75 +0,0 @@
{
"categories": [
{
"name": "Basic",
"components": [
{
"component": "Container",
"description": "This component contains things within itself",
"icon": "ri-layout-row-fill",
"commonProps": {},
"type": []
},
{
"component": "Text",
"description": "This is a simple text component",
"icon": "ri-t-box-fill",
"commonProps": {
},
"type": [
{
"_component": "@budibase/standard-components/header",
"name": "Headline",
"icon": "headline",
"props": {
"type": {
"type": "options",
"options": [
"h1",
"h2"
],
"default": "h1"
}
}
},
{
"_component": "@budibase/standard-components/text",
"name": "Paragraph",
"icon": "paragraph",
"props": {
}
}
]
},
{
"component": "Button",
"description": "A basic html button that is ready for styling",
"icon": "ri-radio-button-fill",
"commonProps": {},
"type": []
},
{
"component": "Icon",
"description": "A basic component for displaying icons",
"icon": "ri-sun-fill",
"commonProps": {},
"type": []
},
{
"component": "Avatar",
"description": "A basic component for rendering an avatar",
"icon": "ri-user-smile-fill",
"commonProps": {},
"type": []
},
{
"component": "Link",
"description": "A basic link component for internal and external links",
"icon": "ri-link",
"commonProps": {},
"type": []
}
]
}
]
}

View File

@ -225,7 +225,8 @@
"description": "a datagrid component with functionality to add, remove and edit rows.", "description": "a datagrid component with functionality to add, remove and edit rows.",
"data": true, "data": true,
"props": { "props": {
"datasource": "models" "datasource": "models",
"editable": "bool"
} }
}, },
"dataform": { "dataform": {

View File

@ -16,12 +16,22 @@
export let _bb export let _bb
export let datasource = {} export let datasource = {}
export let editable
let dataLoaded = false let dataLoaded = false
let data let data
let columnDefs let columnDefs
let selectedRows = [] let selectedRows = []
let model let model
let options = {
defaultColDef: {
flex: 1,
minWidth: 150,
filter: true,
},
rowSelection: editable ? "multiple" : "single",
suppressRowClickSelection: !editable,
}
onMount(async () => { onMount(async () => {
if (datasource.modelId) { if (datasource.modelId) {
@ -39,8 +49,10 @@
field: key, field: key,
hide: shouldHideField(key), hide: shouldHideField(key),
sortable: true, sortable: true,
editable: isEditable(schema[key].type), editable: editable && isEditable(schema[key].type),
cellRenderer: getRenderer( cellRenderer:
editable &&
getRenderer(
schema[key].type, // type schema[key].type, // type
schema[key].constraints // options schema[key].constraints // options
), ),
@ -97,6 +109,7 @@
<div class="container"> <div class="container">
{#if dataLoaded} {#if dataLoaded}
{#if editable}
<div class="controls"> <div class="controls">
<CreateRowButton {_bb} {model} on:newRecord={handleNewRecord} /> <CreateRowButton {_bb} {model} on:newRecord={handleNewRecord} />
{#if selectedRows.length > 0} {#if selectedRows.length > 0}
@ -106,7 +119,9 @@
</DeleteButton> </DeleteButton>
{/if} {/if}
</div> </div>
{/if}
<AgGrid <AgGrid
{options}
{data} {data}
{columnDefs} {columnDefs}
on:update={handleUpdate} on:update={handleUpdate}

View File

@ -62,10 +62,11 @@ function dateRenderer(options) {
target: container, target: container,
props: { props: {
value: params.value, value: params.value,
thin: true
} }
}); });
datePickerInstance.$on('change', toggle) // datePickerInstance.$on('change', toggle)
return container return container
} }