1
0
Fork 0
mirror of synced 2024-10-02 10:08:09 +13:00

adds editable setting

This commit is contained in:
kevmodrome 2020-10-09 12:42:16 +02:00
parent 892bac9808
commit 2af12c6801
No known key found for this signature in database
GPG key ID: E8F9CD141E63BF38
5 changed files with 39 additions and 91 deletions

View file

@ -326,6 +326,12 @@ export default {
key: "datasource",
control: ModelViewSelect,
},
{
label: "Editable",
key: "editable",
valueKey: "checked",
control: Checkbox,
},
],
},
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.",
"data": true,
"props": {
"datasource": "models"
"datasource": "models",
"editable": "bool"
}
},
"dataform": {

View file

@ -16,12 +16,22 @@
export let _bb
export let datasource = {}
export let editable
let dataLoaded = false
let data
let columnDefs
let selectedRows = []
let model
let options = {
defaultColDef: {
flex: 1,
minWidth: 150,
filter: true,
},
rowSelection: editable ? "multiple" : "single",
suppressRowClickSelection: !editable,
}
onMount(async () => {
if (datasource.modelId) {
@ -39,11 +49,13 @@
field: key,
hide: shouldHideField(key),
sortable: true,
editable: isEditable(schema[key].type),
cellRenderer: getRenderer(
schema[key].type, // type
schema[key].constraints // options
),
editable: editable && isEditable(schema[key].type),
cellRenderer:
editable &&
getRenderer(
schema[key].type, // type
schema[key].constraints // options
),
autoHeight: true,
}
})
@ -97,16 +109,19 @@
<div class="container">
{#if dataLoaded}
<div class="controls">
<CreateRowButton {_bb} {model} on:newRecord={handleNewRecord} />
{#if selectedRows.length > 0}
<DeleteButton text small on:click={deleteRecords}>
<Icon name="addrow" />
Delete {selectedRows.length} row(s)
</DeleteButton>
{/if}
</div>
{#if editable}
<div class="controls">
<CreateRowButton {_bb} {model} on:newRecord={handleNewRecord} />
{#if selectedRows.length > 0}
<DeleteButton text small on:click={deleteRecords}>
<Icon name="addrow" />
Delete {selectedRows.length} row(s)
</DeleteButton>
{/if}
</div>
{/if}
<AgGrid
{options}
{data}
{columnDefs}
on:update={handleUpdate}

View file

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