diff --git a/packages/builder/src/components/design/ScreenDetailsModal.svelte b/packages/builder/src/components/design/ScreenDetailsModal.svelte index 295f03c518..34872daf8c 100644 --- a/packages/builder/src/components/design/ScreenDetailsModal.svelte +++ b/packages/builder/src/components/design/ScreenDetailsModal.svelte @@ -6,8 +6,8 @@ export let onConfirm export let onCancel - export let screenUrl - export let screenRole + export let route + export let role export let confirmText = "Continue" const appPrefix = "/app" @@ -15,17 +15,17 @@ let error let modal - $: appUrl = screenUrl - ? `${window.location.origin}${appPrefix}${screenUrl}` + $: appUrl = route + ? `${window.location.origin}${appPrefix}${route}` : `${window.location.origin}${appPrefix}` const routeChanged = event => { if (!event.detail.startsWith("/")) { - screenUrl = "/" + event.detail + route = "/" + event.detail } touched = true - screenUrl = sanitizeUrl(screenUrl) - if (routeExists(screenUrl)) { + route = sanitizeUrl(route) + if (routeExists(route)) { error = "This URL is already taken for this access role" } else { error = null @@ -33,19 +33,19 @@ } const routeExists = url => { - if (!screenRole) { + if (!role) { return false } return get(screenStore).screens.some( screen => screen.routing.route.toLowerCase() === url.toLowerCase() && - screen.routing.roleId === screenRole + screen.routing.roleId === role ) } const confirmScreenDetails = async () => { await onConfirm({ - screenUrl, + route, }) } @@ -58,13 +58,13 @@ onConfirm={confirmScreenDetails} {onCancel} cancelText={"Back"} - disabled={!screenUrl || error || !touched} + disabled={!route || error || !touched} >
modal.confirm()}>
diff --git a/packages/builder/src/components/design/settings/controls/DataSourceSelect/DataSourceSelect.svelte b/packages/builder/src/components/design/settings/controls/DataSourceSelect/DataSourceSelect.svelte index 99b5ace847..410af53648 100644 --- a/packages/builder/src/components/design/settings/controls/DataSourceSelect/DataSourceSelect.svelte +++ b/packages/builder/src/components/design/settings/controls/DataSourceSelect/DataSourceSelect.svelte @@ -34,6 +34,7 @@ import ClientBindingPanel from "components/common/bindings/ClientBindingPanel.svelte" import DataSourceCategory from "components/design/settings/controls/DataSourceSelect/DataSourceCategory.svelte" import { API } from "api" + import { datasourceSelect as format } from "helpers/data/format" export let value = {} export let otherSources @@ -51,24 +52,15 @@ let modal $: text = value?.label ?? "Choose an option" - $: tables = $tablesStore.list.map(m => ({ - label: m.name, - tableId: m._id, - type: "table", - datasource: $datasources.list.find( - ds => ds._id === m.sourceId || m.datasourceId - ), - })) + $: tables = $tablesStore.list.map(table => + format.table(table, $datasources.list) + ) $: viewsV1 = $viewsStore.list.map(view => ({ ...view, label: view.name, type: "view", })) - $: viewsV2 = $viewsV2Store.list.map(view => ({ - ...view, - label: view.name, - type: "viewV2", - })) + $: viewsV2 = $viewsV2Store.list.map(format.viewV2) $: views = [...(viewsV1 || []), ...(viewsV2 || [])] $: queries = $queriesStore.list .filter(q => showAllQueries || q.queryVerb === "read" || q.readable) diff --git a/packages/builder/src/components/design/settings/controls/TableSelect.svelte b/packages/builder/src/components/design/settings/controls/TableSelect.svelte index 7b73d0a7cf..545110a8cc 100644 --- a/packages/builder/src/components/design/settings/controls/TableSelect.svelte +++ b/packages/builder/src/components/design/settings/controls/TableSelect.svelte @@ -2,24 +2,14 @@ import { Select } from "@budibase/bbui" import { createEventDispatcher, onMount } from "svelte" import { tables as tablesStore, viewsV2 } from "stores/builder" + import { tableSelect as format } from "helpers/data/format" export let value const dispatch = createEventDispatcher() - $: tables = $tablesStore.list.map(table => ({ - type: "table", - label: table.name, - tableId: table._id, - resourceId: table._id, - })) - $: views = $viewsV2.list.map(view => ({ - type: "viewV2", - id: view.id, - label: view.name, - tableId: view.tableId, - resourceId: view.id, - })) + $: tables = $tablesStore.list.map(format.table) + $: views = $viewsV2.list.map(format.viewV2) $: options = [...(tables || []), ...(views || [])] const onChange = e => { diff --git a/packages/builder/src/helpers/data/format.js b/packages/builder/src/helpers/data/format.js new file mode 100644 index 0000000000..51b0f12566 --- /dev/null +++ b/packages/builder/src/helpers/data/format.js @@ -0,0 +1,31 @@ +export const datasourceSelect = { + table: (table, datasources) => ({ + label: table.name, + tableId: table._id, + type: "table", + datasource: datasources.find( + datasource => datasource._id === table.sourceId || table.datasourceId + ), + }), + viewV2: view => ({ + ...view, + label: view.name, + type: "viewV2", + }), +} + +export const tableSelect = { + table: table => ({ + type: "table", + label: table.name, + tableId: table._id, + resourceId: table._id, + }), + viewV2: view => ({ + type: "viewV2", + id: view.id, + label: view.name, + tableId: view.tableId, + resourceId: view.id, + }), +} diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ScreenList/ScreenNavItem.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ScreenList/ScreenNavItem.svelte index 2a0da6bac3..e533145fa1 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ScreenList/ScreenNavItem.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/ScreenList/ScreenNavItem.svelte @@ -20,7 +20,7 @@ let confirmDeleteDialog let screenDetailsModal - const createDuplicateScreen = async ({ screenName, screenUrl }) => { + const createDuplicateScreen = async ({ route }) => { // Create a dupe and ensure it is unique let duplicateScreen = Helpers.cloneDeep(screen) delete duplicateScreen._id @@ -28,9 +28,8 @@ duplicateScreen.props = makeComponentUnique(duplicateScreen.props) // Attach the new name and URL - duplicateScreen.routing.route = sanitizeUrl(screenUrl) + duplicateScreen.routing.route = sanitizeUrl(route) duplicateScreen.routing.homeScreen = false - duplicateScreen.props._instanceName = screenName try { // Create the screen @@ -136,8 +135,8 @@ diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/CreateScreenModal.svelte b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/CreateScreenModal.svelte index 7c2775e054..554a2c80f5 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/CreateScreenModal.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/CreateScreenModal.svelte @@ -1,8 +1,9 @@ - - - - Select which datasources you would like to use to create your screens - - - {#each datasources as datasource} -
-
- -
{datasource.name}
-
- - {#each datasource.tablesAndViews as tableOrView} - {@const selected = selectedTablesAndViews.some( - selected => selected.id === tableOrView.id - )} - toggleSelection(tableOrView)} - {selected} - {tableOrView} - /> - {/each} + + + Select which datasources you would like to use to create your screens + + + {#each datasources as datasource} +
+
+ +

{datasource.name}

- {/each} - - - + + {#each datasource.tablesAndViews as tableOrView} + {@const selected = selectedTablesAndViews.some( + selected => selected.id === tableOrView.id + )} + toggleSelection(tableOrView)} + {selected} + {tableOrView} + /> + {/each} +
+ {/each} +
+
diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/FormTypeModal.svelte b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/FormTypeModal.svelte deleted file mode 100644 index b7108fd9aa..0000000000 --- a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/FormTypeModal.svelte +++ /dev/null @@ -1,115 +0,0 @@ - - - - onConfirm(type)} - {onCancel} - disabled={!type} - size="L" - > - - - -
(type = "Create")} - > -
-
- Create a new row - - For capturing and storing new data from your users - -
- {#if type === "Create"} - - - - {/if} -
-
-
(type = "Update")} - > -
-
- Update an existing row - For viewing and updating existing data -
- {#if type === "Update"} - - - - {/if} -
-
-
(type = "View")} - > -
-
- View an existing row - For a read only view of your data -
- {#if type === "View"} - - - - {/if} -
-
-
-
-
- - diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/TableOrViewOption.svelte b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/TableOrViewOption.svelte index b0b9f3dfc1..47a4a834ff 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/TableOrViewOption.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/TableOrViewOption.svelte @@ -1,49 +1,14 @@
-
- - {tableOrView.name} -
- -
- -
- read - -
-
- -
- write - -
-
-
+ + {tableOrView.name}
diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/TypeModal.svelte b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/TypeModal.svelte new file mode 100644 index 0000000000..045e3000e7 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/TypeModal.svelte @@ -0,0 +1,82 @@ + + + onConfirm(selectedType)} + {onCancel} + disabled={!selectedType} + size="L" +> + + + + {#each types as type} +
(selectedType = type.id)} + > +
+ {type.img.alt} +
+
+ {type.title} + {type.description} +
+
+ {/each} +
+
+ + diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/formTypes.js b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/formTypes.js new file mode 100644 index 0000000000..c1e0d93f5a --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/formTypes.js @@ -0,0 +1,35 @@ +import formView from "./images/formView.svg" +import formUpdate from "./images/formUpdate.svg" +import formCreate from "./images/formCreate.svg" + +const tableTypes = [ + { + id: "create", + img: { + alt: "A form containing new data", + src: formCreate, + }, + title: "Create a new row", + description: "For capturing and storing new data from your users", + }, + { + id: "update", + img: { + alt: "A form containing edited data", + src: formUpdate, + }, + title: "Update an existing row", + description: "For viewing and updating existing data", + }, + { + id: "view", + img: { + alt: "A form containing read-only data", + src: formView, + }, + title: "View an existing row", + description: "For a read only view of your data", + }, +] + +export default tableTypes diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/blank.png b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/blank.png deleted file mode 100644 index 4867cc8dc3..0000000000 Binary files a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/blank.png and /dev/null differ diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/blank.svg b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/blank.svg new file mode 100644 index 0000000000..6a225a3271 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/blank.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/form.png b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/form.png deleted file mode 100644 index cb9b57d23b..0000000000 Binary files a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/form.png and /dev/null differ diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/formCreate.svg b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/formCreate.svg new file mode 100644 index 0000000000..d8d0220142 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/formCreate.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/formUpdate.svg b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/formUpdate.svg new file mode 100644 index 0000000000..674dbb12cc --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/formUpdate.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/formView.svg b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/formView.svg new file mode 100644 index 0000000000..0b65846b16 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/formView.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/grid.png b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/grid.png deleted file mode 100644 index c3efa30a67..0000000000 Binary files a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/grid.png and /dev/null differ diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/table.png b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/table.png deleted file mode 100644 index 0bfda10bbe..0000000000 Binary files a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/table.png and /dev/null differ diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableDetails.png b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableDetails.png deleted file mode 100644 index f67495f3aa..0000000000 Binary files a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableDetails.png and /dev/null differ diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableInline.png b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableInline.png deleted file mode 100644 index 905294a9ae..0000000000 Binary files a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableInline.png and /dev/null differ diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableInline.svg b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableInline.svg new file mode 100644 index 0000000000..d2d2fb8134 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableInline.svg @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableModal.svg b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableModal.svg new file mode 100644 index 0000000000..a638c0eec8 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableModal.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableNewScreen.svg b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableNewScreen.svg new file mode 100644 index 0000000000..462ddfc4a2 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableNewScreen.svg @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableSidePanel.svg b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableSidePanel.svg new file mode 100644 index 0000000000..c590f1ab70 --- /dev/null +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/images/tableSidePanel.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/index.svelte b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/index.svelte index ef07b277ef..3101ce41ea 100644 --- a/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/index.svelte +++ b/packages/builder/src/pages/builder/app/[application]/design/_components/NewScreen/index.svelte @@ -1,10 +1,9 @@