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,11 +49,13 @@
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:
schema[key].type, // type editable &&
schema[key].constraints // options getRenderer(
), schema[key].type, // type
schema[key].constraints // options
),
autoHeight: true, autoHeight: true,
} }
}) })
@ -97,16 +109,19 @@
<div class="container"> <div class="container">
{#if dataLoaded} {#if dataLoaded}
<div class="controls"> {#if editable}
<CreateRowButton {_bb} {model} on:newRecord={handleNewRecord} /> <div class="controls">
{#if selectedRows.length > 0} <CreateRowButton {_bb} {model} on:newRecord={handleNewRecord} />
<DeleteButton text small on:click={deleteRecords}> {#if selectedRows.length > 0}
<Icon name="addrow" /> <DeleteButton text small on:click={deleteRecords}>
Delete {selectedRows.length} row(s) <Icon name="addrow" />
</DeleteButton> Delete {selectedRows.length} row(s)
{/if} </DeleteButton>
</div> {/if}
</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
} }