refactor and clean up

This commit is contained in:
kevmodrome 2020-10-09 11:35:52 +02:00
parent 4f3ebb29e9
commit 00d5857232
No known key found for this signature in database
GPG Key ID: E8F9CD141E63BF38
2 changed files with 6 additions and 10 deletions

View File

@ -42,7 +42,7 @@
editable: isEditable(schema[key].type),
cellRenderer: getRenderer(
schema[key].type, // type
schema[key].constraints.inclusion // options
schema[key].constraints // options
),
autoHeight: true,
}

View File

@ -61,7 +61,7 @@ function dateRenderer(options) {
}
function optionsRenderer(options) {
function optionsRenderer({ inclusion }) {
return params => {
const container = document.createElement("div")
const change = (e) => {
@ -72,7 +72,7 @@ function optionsRenderer(options) {
target: container,
props: {
value: params.value,
options
options: inclusion
}
});
@ -83,13 +83,9 @@ function optionsRenderer(options) {
}
export function getRenderer(type, options) {
// Complicated thing to set options for renderers
let customRenderer
if (type === "options" || type === 'datetime') {
customRenderer = renderers.get(type)(options)
if (renderers.get(type)) {
return renderers.get(type)(options)
} else {
let rendererGenerator = renderers.get(type)
customRenderer = rendererGenerator ? rendererGenerator() : false
return false
}
return customRenderer
}