Budibase is an open-source low-code platform for creating internal apps in minutes. Supports PostgreSQL, MySQL, MSSQL, MongoDB, Rest API, Docker, K8s 🚀
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

65 lines
1.8 KiB

import { getRecordPath } from "./getRecordPath";
export const indexTables = ({indexes, helpers}) =>
indexes.map(i => indexTable(i, helpers));
const excludedColumns = ["id", "isNew", "key", "type", "sortKey"];
export const indexTableProps = (index, helpers) => ({
data: {
"##bbstate":index.nodeKey(),
"##bbsource":"store"
},
tableClass: "table table-hover",
theadClass: "thead-dark",
columns: helpers
.indexSchema(index)
.filter(c => !excludedColumns.includes(c.name))
.map(column),
onRowClick: [
{
"##eventHandlerType": "Load Record",
parameters: {
recordKey: {
"##bbstate": "key",
"##bbsource": "context"
},
statePath: {
"##bbstate": "type",
"##bbsource": "context"
}
},
"##eventHandlerType": "Set State",
parameters: {
path: "currentView",
value: {
"##bbstate": "type",
"##bbsource": "context"
}
},
}
]
});
export const getIndexTableName = (index, record) => {
record = record
|| index.parent().type === "record" ? index.parent() : null;
return (record
? `${getRecordPath(record)}/${index.name} Table`
: `${index.name} Table`);
}
const indexTable = (index, helpers) => ({
name: getIndexTableName(index),
inherits: "@budibase/standard-components/table",
props: indexTableProps(index, helpers)
});
const column = (col) => ({
title: col.name,
value: {
"##bbstate": col.name,
"##bbsource":"context"
}
})