Add new template for new row autoscreen

This commit is contained in:
Andrew Kingston 2020-10-16 08:38:27 +01:00
parent 534f00515d
commit 02bd7fa075
1 changed files with 183 additions and 67 deletions

View File

@ -1,10 +1,8 @@
export default function(tables) { export default function(tables) {
return tables.map(table => { return tables.map(table => {
const fields = Object.keys(table.schema)
const heading = fields.length > 0 ? `{{ data.${fields[0]} }}` : "Add Row"
return { return {
name: `${table.name} - New`, name: `${table.name} - New`,
create: () => createScreen(table, heading), create: () => createScreen(table),
id: NEW_ROW_TEMPLATE, id: NEW_ROW_TEMPLATE,
} }
}) })
@ -12,10 +10,10 @@ export default function(tables) {
export const NEW_ROW_TEMPLATE = "NEW_ROW_TEMPLATE" export const NEW_ROW_TEMPLATE = "NEW_ROW_TEMPLATE"
const createScreen = (table, heading) => ({ const createScreen = table => ({
props: { props: {
_id: "", _id: "c683c4ca8ffc849c6bdd3b7d637fbbf3c",
_component: "@budibase/standard-components/newrow", _component: "@budibase/standard-components/rowdetail",
_styles: { _styles: {
normal: {}, normal: {},
hover: {}, hover: {},
@ -25,43 +23,22 @@ const createScreen = (table, heading) => ({
table: table._id, table: table._id,
_children: [ _children: [
{ {
_id: "", _id: "ccad6cc135c7947a7ba9c631f655d6e0f",
_component: "@budibase/standard-components/heading",
_styles: {
normal: {},
hover: {},
active: {},
selected: {},
},
_code: "",
className: "",
text: heading,
type: "h1",
_instanceName: "Heading 1",
_children: [],
},
{
_id: "",
_component: "@budibase/standard-components/dataform",
_styles: {
normal: {},
hover: {},
active: {},
selected: {},
},
_code: "",
_instanceName: `${table.name} Form`,
_children: [],
},
{
_id: "",
_component: "@budibase/standard-components/container", _component: "@budibase/standard-components/container",
_styles: { _styles: {
normal: { normal: {
display: "flex", width: "700px",
"flex-direction": "row", padding: "0px",
"align-items": "center", background: "white",
"justify-content": "flex-end", "border-radius": "0.5rem",
"box-shadow": "0 1px 2px 0 rgba(0, 0, 0, 0.05)",
margin: "auto",
"margin-top": "20px",
"padding-top": "48px",
"padding-bottom": "48px",
"padding-right": "48px",
"padding-left": "48px",
"margin-bottom": "20px",
}, },
hover: {}, hover: {},
active: {}, active: {},
@ -71,40 +48,157 @@ const createScreen = (table, heading) => ({
className: "", className: "",
onLoad: [], onLoad: [],
type: "div", type: "div",
_instanceName: "Buttons Container", _instanceId: "inst_app_8fb_631af42f9dc94da2b5c48dc6c5124610",
_instanceName: "Container",
_children: [ _children: [
{ {
_id: "", _id: "c6e91622ba7984f468f70bf4bf5120246",
_component: "@budibase/standard-components/button", _component: "@budibase/standard-components/container",
_styles: { _styles: {
normal: { normal: {
"margin-right": "20px", "font-size": "14px",
color: "#757575",
}, },
hover: {}, hover: {},
active: {}, active: {},
selected: {}, selected: {},
}, },
_code: "", _code: "",
text: "Back",
className: "", className: "",
disabled: false, onLoad: [],
onClick: [ type: "div",
_instanceId: "inst_app_8fb_631af42f9dc94da2b5c48dc6c5124610",
_instanceName: "Breadcrumbs",
_children: [
{ {
parameters: { _id: "caa33353c252c4931b2a51b48a559a7fc",
_component: "@budibase/standard-components/link",
_styles: {
normal: {
color: "#757575",
"text-transform": "capitalize",
},
hover: {
color: "#4285f4",
},
active: {},
selected: {},
},
_code: "",
url: `/${table.name.toLowerCase()}`, url: `/${table.name.toLowerCase()}`,
}, openInNewTab: false,
"##eventHandlerType": "Navigate To", text: table.name,
}, color: "",
], hoverColor: "",
_instanceName: "Back Button", underline: false,
fontSize: "",
fontFamily: "initial",
_instanceId: "inst_app_8fb_631af42f9dc94da2b5c48dc6c5124610",
_instanceName: "Back Link",
_children: [], _children: [],
}, },
{ {
_id: "", _id: "c6e218170201040e7a74e2c8304fe1860",
_component: "@budibase/standard-components/text",
_styles: {
normal: {
"margin-right": "4px",
"margin-left": "4px",
},
hover: {},
active: {},
selected: {},
},
_code: "",
text: ">",
type: "none",
_instanceId: "inst_app_8fb_631af42f9dc94da2b5c48dc6c5124610",
_instanceName: "Arrow",
_children: [],
},
{
_id: "c799da1fa3a84442e947cc9199518f64c",
_component: "@budibase/standard-components/text",
_styles: {
normal: {
color: "#000000",
},
hover: {},
active: {},
selected: {},
},
_code: "",
text: "New",
type: "none",
_instanceId: "inst_app_8fb_631af42f9dc94da2b5c48dc6c5124610",
_instanceName: "Identifier",
_children: [],
},
],
},
{
_id: "cbd1637cd1e274287a3c28ef0bf235d08",
_component: "@budibase/standard-components/container",
_styles: {
normal: {
display: "flex",
"flex-direction": "row",
"justify-content": "space-between",
"align-items": "center",
"margin-top": "32px",
"margin-bottom": "32px",
},
hover: {},
active: {},
selected: {},
},
_code: "",
className: "",
onLoad: [],
type: "div",
_instanceId: "inst_app_8fb_631af42f9dc94da2b5c48dc6c5124610",
_instanceName: "Title Container",
_children: [
{
_id: "c98d3675d04114558bbf28661c5ccfb8e",
_component: "@budibase/standard-components/heading",
_styles: {
normal: {
margin: "0px",
"margin-bottom": "0px",
"margin-right": "0px",
"margin-top": "0px",
"margin-left": "0px",
flex: "1 1 auto",
},
hover: {},
active: {},
selected: {},
},
_code: "",
className: "",
text: "New Row",
type: "h3",
_instanceName: "Title",
_children: [],
},
{
_id: "cae402bd3c6a44618a8341bf7ab9ab086",
_component: "@budibase/standard-components/button", _component: "@budibase/standard-components/button",
_styles: { _styles: {
normal: {}, normal: {
hover: {}, background: "#000000",
"border-width": "0",
"border-style": "None",
color: "#fff",
"font-family": "Inter",
"font-weight": "500",
"font-size": "14px",
"margin-left": "16px",
},
hover: {
background: "#9e9e9e",
},
active: {}, active: {},
selected: {}, selected: {},
}, },
@ -120,12 +214,34 @@ const createScreen = (table, heading) => ({
}, },
"##eventHandlerType": "Save Row", "##eventHandlerType": "Save Row",
}, },
{
parameters: {
url: `/${table.name.toLowerCase()}`,
},
"##eventHandlerType": "Navigate To",
},
], ],
_instanceName: "Save Button", _instanceName: "Save Button",
_children: [], _children: [],
}, },
], ],
}, },
{
_id: "c5e6c98d7363640f9ad3a7d19c8c10f67",
_component: "@budibase/standard-components/dataformwide",
_styles: {
normal: {},
hover: {},
active: {},
selected: {},
},
_code: "",
_instanceId: "inst_app_8fb_631af42f9dc94da2b5c48dc6c5124610",
_instanceName: "Form",
_children: [],
},
],
},
], ],
_instanceName: `${table.name} - New`, _instanceName: `${table.name} - New`,
_code: "", _code: "",