starts work on adding view details link to grid component

This commit is contained in:
kevmodrome 2020-10-15 18:54:08 +02:00
parent e9a0c1c512
commit a31b30da7d
3 changed files with 37 additions and 8 deletions

View File

@ -20,6 +20,7 @@
export let theme = "alpine"
export let height = 500
export let pagination
export let detailUrl = 'https://someurl.com/'
// These can never change at runtime so don't need to be reactive
let canEdit = editable && datasource && datasource.type !== "view"
@ -91,7 +92,7 @@
// always 'row'
if (name === "type") return true
// tables are always tied to a single tableId, this is irrelevant
if (name === "tableId") return true
// if (name === "tableId") return true
return false
}

View File

@ -0,0 +1,6 @@
<script>
import { Icon } from '@budibase/bbui'
export let url
</script>
<a href={url}><Icon name="view" /></a>

View File

@ -2,6 +2,7 @@
// https://www.ag-grid.com/javascript-grid-cell-rendering-components/
import AttachmentCell from "./AttachmentCell/Button.svelte"
import ViewDetails from "./ViewDetails/Cell.svelte"
import Select from "./Select/Wrapper.svelte"
import DatePicker from "./DateTime/Wrapper.svelte"
import RelationshipDisplay from "./Relationship/RelationshipDisplay.svelte"
@ -11,18 +12,19 @@ const renderers = new Map([
["attachment", attachmentRenderer],
["options", optionsRenderer],
["link", linkedRowRenderer],
["tableId", viewDetailsRenderer]
])
export function getRenderer({ type, constraints }, editable) {
if (renderers.get(type)) {
return renderers.get(type)(constraints, editable)
export function getRenderer(schema, editable) {
if (renderers.get(schema.type)) {
return renderers.get(schema.type)(schema.options, editable)
} else {
return false
}
}
/* eslint-disable no-unused-vars */
function booleanRenderer(constraints, editable) {
function booleanRenderer(options, editable) {
return params => {
const toggle = e => {
params.value = !params.value
@ -44,7 +46,7 @@ function booleanRenderer(constraints, editable) {
}
}
/* eslint-disable no-unused-vars */
function attachmentRenderer(constraints, editable) {
function attachmentRenderer(options, editable) {
return params => {
const container = document.createElement("div")
@ -66,7 +68,7 @@ function attachmentRenderer(constraints, editable) {
}
}
/* eslint-disable no-unused-vars */
function dateRenderer(constraints, editable) {
function dateRenderer(options, editable) {
return function(params) {
const container = document.createElement("div")
const toggle = e => {
@ -111,7 +113,7 @@ function optionsRenderer({ inclusion }, editable) {
}
}
/* eslint-disable no-unused-vars */
function linkedRowRenderer(constraints, editable) {
function linkedRowRenderer(options, editable) {
return params => {
let container = document.createElement("div")
container.style.display = "grid"
@ -129,3 +131,23 @@ function linkedRowRenderer(constraints, editable) {
return container
}
}
/* eslint-disable no-unused-vars */
function viewDetailsRenderer(options) {
return params => {
console.log('Params: ', params)
let container = document.createElement("div")
container.style.display = "grid"
container.style.placeItems = "center"
container.style.height = "100%"
new ViewDetails({
target: container,
props: {
url: options.url + params.value
},
})
return container
}
}