From 00d5857232427a72ccb8d7844abe8c3e878019ba Mon Sep 17 00:00:00 2001 From: kevmodrome Date: Fri, 9 Oct 2020 11:35:52 +0200 Subject: [PATCH] refactor and clean up --- .../src/DataGrid/Component.svelte | 2 +- .../src/DataGrid/customRenderer.js | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/standard-components/src/DataGrid/Component.svelte b/packages/standard-components/src/DataGrid/Component.svelte index b0d19a2004..83ed9c0ef2 100644 --- a/packages/standard-components/src/DataGrid/Component.svelte +++ b/packages/standard-components/src/DataGrid/Component.svelte @@ -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, } diff --git a/packages/standard-components/src/DataGrid/customRenderer.js b/packages/standard-components/src/DataGrid/customRenderer.js index 5ecc74466b..1c2e136f79 100644 --- a/packages/standard-components/src/DataGrid/customRenderer.js +++ b/packages/standard-components/src/DataGrid/customRenderer.js @@ -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 } \ No newline at end of file