diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index dadba69e44..87a2cb3118 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -153,35 +153,13 @@ const _saveScreen = async (store, s, screen) => { return s } -const createScreen = store => ({ - screenName, - route, - baseComponent, - screen, -}) => { +const createScreen = store => screen => { store.update(state => { - const rootComponent = - state.components[ - baseComponent || "@budibase/standard-components/container" - ] - - const newScreen = screen || { - description: "", - url: "", - _css: "", - props: createProps(rootComponent).props, - route, - } - newScreen.name = newScreen.props._id - if (screenName) { - newScreen.props._instanceName = screenName - } - - state.currentPreviewItem = newScreen - state.currentComponentInfo = newScreen.props + state.currentPreviewItem = screen + state.currentComponentInfo = screen.props state.currentFrontEndType = "screen" - _saveScreen(store, state, newScreen) + _saveScreen(store, state, screen) return state }) diff --git a/packages/builder/src/builderStore/store/screenTemplates/emptyContainerScreen.js b/packages/builder/src/builderStore/store/screenTemplates/emptyContainerScreen.js new file mode 100644 index 0000000000..c567c31026 --- /dev/null +++ b/packages/builder/src/builderStore/store/screenTemplates/emptyContainerScreen.js @@ -0,0 +1,22 @@ +export default { + name: `Create from Scratch`, + create: () => createScreen(), +} + +const createScreen = () => ({ + props: { + _id: "", + _component: "@budibase/standard-components/container", + _styles: { + normal: {}, + hover: {}, + active: {}, + selected: {}, + }, + type: "div", + _children: [], + _instanceName: "", + }, + route: "", + name: "screen-id", +}) diff --git a/packages/builder/src/builderStore/store/screenTemplates/emptyNewRecordScreen.js b/packages/builder/src/builderStore/store/screenTemplates/emptyNewRecordScreen.js new file mode 100644 index 0000000000..7dfca668a4 --- /dev/null +++ b/packages/builder/src/builderStore/store/screenTemplates/emptyNewRecordScreen.js @@ -0,0 +1,22 @@ +export default { + name: `New Record (Empty)`, + create: () => createScreen(), +} + +const createScreen = () => ({ + props: { + _id: "", + _component: "@budibase/standard-components/recorddetail", + _styles: { + normal: {}, + hover: {}, + active: {}, + selected: {}, + }, + _children: [], + _instanceName: "", + model: "", + }, + route: "", + name: "screen-id", +}) diff --git a/packages/builder/src/builderStore/store/screenTemplates/emptyRecordDetailScreen.js b/packages/builder/src/builderStore/store/screenTemplates/emptyRecordDetailScreen.js new file mode 100644 index 0000000000..412d8692bb --- /dev/null +++ b/packages/builder/src/builderStore/store/screenTemplates/emptyRecordDetailScreen.js @@ -0,0 +1,22 @@ +export default { + name: `Record Detail (Empty)`, + create: () => createScreen(), +} + +const createScreen = () => ({ + props: { + _id: "", + _component: "@budibase/standard-components/recorddetail", + _styles: { + normal: {}, + hover: {}, + active: {}, + selected: {}, + }, + _children: [], + _instanceName: "", + model: "", + }, + route: "", + name: "screen-id", +}) diff --git a/packages/builder/src/builderStore/store/screenTemplates/index.js b/packages/builder/src/builderStore/store/screenTemplates/index.js index 6825b8b973..a6896ab1cd 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/index.js +++ b/packages/builder/src/builderStore/store/screenTemplates/index.js @@ -1,11 +1,17 @@ import newRecordScreen from "./newRecordScreen" import recordDetailScreen from "./recordDetailScreen" +import emptyNewRecordScreen from "./emptyNewRecordScreen" +import emptyContainerScreen from "./emptyContainerScreen" +import emptyRecordDetailScreen from "./emptyRecordDetailScreen" import { generateNewIdsForComponent } from "../../storeUtils" import { uuid } from "builderStore/uuid" const allTemplates = models => [ + emptyContainerScreen, ...newRecordScreen(models), + emptyNewRecordScreen, ...recordDetailScreen(models), + emptyRecordDetailScreen, ] // allows us to apply common behaviour to all create() functions diff --git a/packages/builder/src/builderStore/store/screenTemplates/newRecordScreen.js b/packages/builder/src/builderStore/store/screenTemplates/newRecordScreen.js index 4c3466ca1c..b4ceeeeff6 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/newRecordScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/newRecordScreen.js @@ -1,6 +1,6 @@ export default function(models) { return models.map(model => ({ - name: `New ${model.name}`, + name: `New Record - ${model.name}`, create: () => createScreen(model), })) } @@ -8,16 +8,14 @@ export default function(models) { const createScreen = model => ({ props: { _id: "f684460e-1f79-42b4-8ffd-1f708bca93ed", - _component: "@budibase/standard-components/container", + _component: "@budibase/standard-components/newrecord", _styles: { normal: {}, hover: {}, active: {}, selected: {}, }, - className: "", - onLoad: [], - type: "div", + model: model._id, _children: [ { _id: "7d1d6b43-b444-46a5-a75c-267fd6b5baf6", diff --git a/packages/builder/src/builderStore/store/screenTemplates/recordDetailScreen.js b/packages/builder/src/builderStore/store/screenTemplates/recordDetailScreen.js index 252e0f5e20..afda29f6cc 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/recordDetailScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/recordDetailScreen.js @@ -1,6 +1,6 @@ export default function(models) { return models.map(model => ({ - name: `New ${model.name}`, + name: `Record Detail - ${model.name}`, create: () => createScreen(model), })) } @@ -15,9 +15,7 @@ const createScreen = model => ({ active: {}, selected: {}, }, - className: "", - onLoad: [], - type: "div", + model: model._id, _children: [ { _id: "7d1d6b43-b444-46a5-a75c-267fd6b5baf6", @@ -39,6 +37,6 @@ const createScreen = model => ({ ], _instanceName: `${model.name} Detail`, }, - route: `/${model.name}/new`, + route: `/${model.name}/:id`, name: "screen-id", }) diff --git a/packages/builder/src/components/userInterface/CreateScreen/ChooseTemplate.svelte b/packages/builder/src/components/userInterface/CreateScreen/ChooseTemplate.svelte deleted file mode 100644 index a0b1e88ac8..0000000000 --- a/packages/builder/src/components/userInterface/CreateScreen/ChooseTemplate.svelte +++ /dev/null @@ -1,62 +0,0 @@ - - -