2019-10-10 07:18:02 +02:00
|
|
|
const headers = () => [
|
2020-02-03 10:24:25 +01:00
|
|
|
{
|
|
|
|
name: "common/H1",
|
|
|
|
description: "Header 1",
|
|
|
|
inherits: "@budibase/standard-components/text",
|
|
|
|
props: {
|
|
|
|
font: "20pt",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "common/H2",
|
|
|
|
description: "Header 2",
|
|
|
|
inherits: "@budibase/standard-components/text",
|
|
|
|
props: {
|
|
|
|
font: "15pt",
|
2019-10-10 07:18:02 +02:00
|
|
|
},
|
2020-02-03 10:24:25 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "common/H3",
|
|
|
|
description: "Header 3",
|
|
|
|
inherits: "@budibase/standard-components/text",
|
|
|
|
props: {
|
|
|
|
font: "12pt bold",
|
2019-10-10 07:18:02 +02:00
|
|
|
},
|
2020-02-03 10:24:25 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "common/H4",
|
|
|
|
description: "Header 4",
|
|
|
|
inherits: "@budibase/standard-components/text",
|
|
|
|
props: {
|
|
|
|
font: "10pt bold",
|
2019-10-10 07:18:02 +02:00
|
|
|
},
|
2020-02-03 10:24:25 +01:00
|
|
|
},
|
2020-02-10 16:51:09 +01:00
|
|
|
];
|
2019-10-10 07:18:02 +02:00
|
|
|
|
2020-02-10 16:51:09 +01:00
|
|
|
const forms = ({ records, indexes }) => [
|
|
|
|
...headers(),
|
|
|
|
...records.map(root),
|
|
|
|
];
|
2019-10-07 07:03:41 +02:00
|
|
|
|
|
|
|
const root = record => ({
|
2020-02-03 10:24:25 +01:00
|
|
|
name: `${record.name} Form`,
|
|
|
|
description: `All fields on record '${record.nodeKey()}' `,
|
|
|
|
inherits: "@budibase/standard-components/stackpanel",
|
|
|
|
props: {
|
|
|
|
direction: "vertical",
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
control: {
|
|
|
|
_component: "common/H1",
|
|
|
|
value: `Edit ${record.name}`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
form(record),
|
|
|
|
saveCancelButtons(record),
|
|
|
|
],
|
|
|
|
},
|
2020-02-10 16:51:09 +01:00
|
|
|
});
|
2019-10-07 07:03:41 +02:00
|
|
|
|
|
|
|
const form = record => ({
|
2020-02-03 10:24:25 +01:00
|
|
|
control: {
|
|
|
|
_component: "@budibase/standard-components/form",
|
|
|
|
formControls: record.fields.map(f => ({
|
|
|
|
label: f.label,
|
|
|
|
control: {
|
|
|
|
_component: "@budibase/standard-components/textbox",
|
|
|
|
value: {
|
|
|
|
"##bbstate": `current${record.name}.${f.name}`,
|
|
|
|
"##bbsource": "store",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})),
|
|
|
|
},
|
2020-02-10 16:51:09 +01:00
|
|
|
});
|
2020-02-03 10:24:25 +01:00
|
|
|
|
|
|
|
const saveCancelButtons = record => ({
|
|
|
|
control: {
|
|
|
|
_component: "@budibase/standard-components/stackpanel",
|
|
|
|
direction: "horizontal",
|
|
|
|
children: [
|
|
|
|
paddedPanelForButton({
|
|
|
|
_component: "common/Primary Button",
|
|
|
|
contentText: `Save ${record.name}`,
|
|
|
|
onClick: [
|
|
|
|
{
|
|
|
|
"##eventHandlerType": "Save Record",
|
|
|
|
parameters: {
|
|
|
|
statePath: `current${record.name}`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
paddedPanelForButton({
|
|
|
|
_component: "common/Secondary Button",
|
|
|
|
contentText: `Cancel`,
|
|
|
|
onClick: [
|
|
|
|
{
|
|
|
|
"##eventHandlerType": "Save Record",
|
|
|
|
parameters: {
|
|
|
|
statePath: `current${record.name}`,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
},
|
2020-02-10 16:51:09 +01:00
|
|
|
});
|
2020-02-03 10:24:25 +01:00
|
|
|
|
|
|
|
const paddedPanelForButton = button => ({
|
|
|
|
control: {
|
|
|
|
_component: "@budibase/standard-components/panel",
|
|
|
|
padding: "20px",
|
|
|
|
component: button,
|
|
|
|
},
|
2020-02-10 16:51:09 +01:00
|
|
|
});
|
2020-02-03 10:24:25 +01:00
|
|
|
|
|
|
|
const indexTables = ({ indexes, helpers }) =>
|
|
|
|
indexes
|
|
|
|
.filter(i => i.parent().type === "root")
|
2020-02-10 16:51:09 +01:00
|
|
|
.map(i => indexTable(i, helpers));
|
2019-10-07 07:03:41 +02:00
|
|
|
|
|
|
|
const indexTableProps = (index, helpers) => ({
|
2020-02-03 10:24:25 +01:00
|
|
|
data: {
|
|
|
|
"##bbstate": index.nodeKey(),
|
|
|
|
"##bbsource": "store",
|
|
|
|
},
|
|
|
|
columns: helpers.indexSchema(index).map(column),
|
2020-02-10 16:51:09 +01:00
|
|
|
});
|
2019-10-07 07:03:41 +02:00
|
|
|
|
|
|
|
const indexTable = (index, helpers) => ({
|
2020-02-03 10:24:25 +01:00
|
|
|
name: `tables/${index.name} Table`,
|
|
|
|
inherits: "@budibase/standard-components/table",
|
|
|
|
props: indexTableProps(index, helpers),
|
2020-02-10 16:51:09 +01:00
|
|
|
});
|
2020-02-03 10:24:25 +01:00
|
|
|
|
|
|
|
const column = col => ({
|
|
|
|
title: col.name,
|
|
|
|
value: {
|
|
|
|
"##bbstate": col.name,
|
|
|
|
"##bbsource": "context",
|
|
|
|
},
|
2020-02-10 16:51:09 +01:00
|
|
|
});
|
2020-02-03 10:24:25 +01:00
|
|
|
|
|
|
|
const nav = ({ records, indexes, helpers }) => [
|
|
|
|
{
|
|
|
|
name: "Application Root",
|
|
|
|
inherits: "@budibase/standard-components/nav",
|
|
|
|
props: {
|
|
|
|
items: indexes.filter(i => i.parent().type === "root").map(navItem),
|
|
|
|
selectedItem: {
|
|
|
|
"##bbstate": "selectedNav",
|
|
|
|
"##bbstatefallback": records[0].collectionName,
|
|
|
|
"##bbsource": "store",
|
|
|
|
},
|
2019-10-07 07:03:41 +02:00
|
|
|
},
|
2020-02-03 10:24:25 +01:00
|
|
|
},
|
|
|
|
...indexTables({ records, indexes, helpers }),
|
2020-02-10 16:51:09 +01:00
|
|
|
];
|
2019-10-07 07:03:41 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
const navItem = index => ({
|
|
|
|
title: index.name,
|
|
|
|
component: {
|
|
|
|
_component: `tables/${index.name} Table`,
|
|
|
|
},
|
2020-02-10 16:51:09 +01:00
|
|
|
});
|
2019-10-07 07:03:41 +02:00
|
|
|
|
2020-02-03 10:24:25 +01:00
|
|
|
const app = params => {
|
|
|
|
return [...nav(params), ...forms(params)]
|
2020-02-10 16:51:09 +01:00
|
|
|
};
|
2019-10-07 07:03:41 +02:00
|
|
|
|
|
|
|
const buttons = () => [
|
2020-02-03 10:24:25 +01:00
|
|
|
{
|
|
|
|
name: "common/Primary Button",
|
|
|
|
description: "a styled button",
|
|
|
|
inherits: "@budibase/standard-components/button",
|
|
|
|
props: {
|
|
|
|
padding: "5px 7px",
|
|
|
|
border: "1px solid #EEE",
|
|
|
|
color: "#5F6368",
|
|
|
|
background: "##f2f2f2",
|
|
|
|
hoverColor: "black",
|
|
|
|
hoverBackground: "#cccccc",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "common/Secondary Button",
|
|
|
|
description: "a styled button",
|
|
|
|
inherits: "@budibase/standard-components/button",
|
|
|
|
props: {
|
|
|
|
padding: "5px 7px",
|
|
|
|
border: "1px solid #EEE",
|
|
|
|
color: "#5F6368",
|
|
|
|
background: "##f2f2f2",
|
|
|
|
hoverColor: "black",
|
|
|
|
hoverBackground: "#cccccc",
|
2019-10-07 07:03:41 +02:00
|
|
|
},
|
2020-02-03 10:24:25 +01:00
|
|
|
},
|
2020-02-10 16:51:09 +01:00
|
|
|
];
|
2019-10-07 07:03:41 +02:00
|
|
|
|
2020-02-10 16:51:09 +01:00
|
|
|
export { app, buttons, forms, headers, indexTables, nav };
|
2020-02-14 12:51:45 +01:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf-8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h0OiBgU2F2ZSAke3JlY29yZC5uYW1lfWAsXHJcbiAgICAgICAgb25DbGljazogW1xyXG4gICAgICAgICAge1xyXG4gICAgICAgICAgICBcIiMjZXZlbnRIYW5kbGVyVHlwZVwiOiBcIlNhdmUgUmVjb3JkXCIsXHJcbiAgICAgICAgICAgIHBhcmFtZXRlcnM6IHtcclxuICAgICAgICAgICAgICBzdGF0ZVBhdGg6IGBjdXJyZW50JHtyZWNvcmQubmFtZX1gLFxyXG4gICAgICAgICAgICB9LFxyXG4gICAgICAgICAgfSxcclxuICAgICAgICBdLFxyXG4gICAgICB9KSxcclxuICAgICAgcGFkZGVkUGFuZWxGb3JCdXR0b24oe1xyXG4gICAgICAgIF9jb21wb25lbnQ6IFwiY29tbW9uL1NlY29uZGFyeSBCdXR0b25cIixcclxuICAgICAgICBjb250ZW50VGV4dDogYENhbmNlbGAsXHJcbiAgICAgICAgb25DbGljazogW1xyXG4gICAgICAgICAge1xyXG4gICAgICAgICAgICBcIiMjZXZlbnRIYW5kbGVyVHlwZVwiOiBcIlNhdmUgUmVjb3JkXCIsXHJcbiAgICAgICAgICAgIHBhcmFtZXRlcnM6IHtcclxuICAgICAgICAgICAgICBzdGF0ZVBhdGg6IGBjdXJyZW50JHtyZWNvcmQubmF
|