move renderer map to separate file
This commit is contained in:
parent
da32029c31
commit
e43dc488e4
|
@ -1,14 +1,10 @@
|
||||||
<script>
|
<script>
|
||||||
// Import valueSetters and custom renderers
|
// Import valueSetters and custom renderers
|
||||||
import { number } from "./valueSetters"
|
import { number } from "./valueSetters"
|
||||||
import { booleanRenderer, attachmentRenderer } from "./customRenderer"
|
import renderers from "./customRenderer"
|
||||||
|
|
||||||
// These maps need to be set up to handle whatever types that are used in the models.
|
// These maps need to be set up to handle whatever types that are used in the models.
|
||||||
const setters = new Map([["number", number]])
|
const setters = new Map([["number", number]])
|
||||||
const renderers = new Map([
|
|
||||||
["boolean", booleanRenderer],
|
|
||||||
["attachment", attachmentRenderer],
|
|
||||||
])
|
|
||||||
|
|
||||||
import fetchData from "../fetchData.js"
|
import fetchData from "../fetchData.js"
|
||||||
import { isEmpty } from "lodash/fp"
|
import { isEmpty } from "lodash/fp"
|
||||||
|
|
|
@ -2,8 +2,15 @@
|
||||||
// https://www.ag-grid.com/javascript-grid-cell-rendering-components/
|
// https://www.ag-grid.com/javascript-grid-cell-rendering-components/
|
||||||
|
|
||||||
import AttachmentCell from './AttachmentCell/Button.svelte'
|
import AttachmentCell from './AttachmentCell/Button.svelte'
|
||||||
|
import { DatePicker } from "@budibase/bbui"
|
||||||
|
|
||||||
export const booleanRenderer = (params) => {
|
export default new Map([
|
||||||
|
["boolean", booleanRenderer],
|
||||||
|
["attachment", attachmentRenderer],
|
||||||
|
["datetime", dateRenderer],
|
||||||
|
])
|
||||||
|
|
||||||
|
function booleanRenderer(params) {
|
||||||
const toggle = (e) => {
|
const toggle = (e) => {
|
||||||
params.value = !params.value
|
params.value = !params.value
|
||||||
params.setValue(e.currentTarget.checked)
|
params.setValue(e.currentTarget.checked)
|
||||||
|
@ -15,15 +22,27 @@ export const booleanRenderer = (params) => {
|
||||||
|
|
||||||
return input
|
return input
|
||||||
}
|
}
|
||||||
export const attachmentRenderer = (params) => {
|
function attachmentRenderer(params) {
|
||||||
let container = document.createElement("div")
|
const container = document.createElement("div")
|
||||||
|
|
||||||
const attachment = new AttachmentCell({
|
const attachmentInstance = new AttachmentCell({
|
||||||
target: container,
|
target: container,
|
||||||
props: {
|
props: {
|
||||||
files: params.value || [],
|
files: params.value || [],
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return container
|
||||||
|
}
|
||||||
|
function dateRenderer(params) {
|
||||||
|
const container = document.createElement("div")
|
||||||
|
|
||||||
|
const datePickerInstance = new DatePicker({
|
||||||
|
target: container,
|
||||||
|
props: {
|
||||||
|
value: params.value,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return container
|
return container
|
||||||
}
|
}
|
Loading…
Reference in New Issue