Remove a lot of hacks around screenslots and allow naming them

This commit is contained in:
Andrew Kingston 2021-06-30 09:05:03 +01:00
parent 1cf0d3b0cf
commit 24172d111c
6 changed files with 70 additions and 71 deletions

View File

@ -330,15 +330,6 @@ export const getFrontendStore = () => {
const asset = get(currentAsset) const asset = get(currentAsset)
const state = get(store) const state = get(store)
// Only allow one screen slot, and in the layout
if (componentName.endsWith("screenslot")) {
const isLayout = state.currentFrontEndType === FrontendTypes.LAYOUT
const slot = findComponentType(asset.props, componentName)
if (!isLayout || slot != null) {
return
}
}
// Create new component // Create new component
const componentInstance = store.actions.components.createInstance( const componentInstance = store.actions.components.createInstance(
componentName, componentName,

View File

@ -57,13 +57,6 @@
"icon", "icon",
"embed" "embed"
] ]
},
{
"name": "Other",
"icon": "More",
"children": [
"screenslot"
]
} }
] ]

View File

@ -65,52 +65,56 @@
} }
</script> </script>
<ActionMenu> {#if definition.editable !== false}
<div slot="control" class="icon"> <ActionMenu>
<Icon size="S" hoverable name="MoreSmallList" /> <div slot="control" class="icon">
</div> <Icon size="S" hoverable name="MoreSmallList" />
<MenuItem icon="Delete" on:click={confirmDeleteDialog.show}>Delete</MenuItem> </div>
<MenuItem noClose icon="ChevronUp" on:click={moveUpComponent}> <MenuItem icon="Delete" on:click={confirmDeleteDialog.show}>
Move up Delete
</MenuItem> </MenuItem>
<MenuItem noClose icon="ChevronDown" on:click={moveDownComponent}> <MenuItem noClose icon="ChevronUp" on:click={moveUpComponent}>
Move down Move up
</MenuItem> </MenuItem>
<MenuItem noClose icon="Duplicate" on:click={duplicateComponent}> <MenuItem noClose icon="ChevronDown" on:click={moveDownComponent}>
Duplicate Move down
</MenuItem> </MenuItem>
<MenuItem icon="Cut" on:click={() => storeComponentForCopy(true)}> <MenuItem noClose icon="Duplicate" on:click={duplicateComponent}>
Cut Duplicate
</MenuItem> </MenuItem>
<MenuItem icon="Copy" on:click={() => storeComponentForCopy(false)}> <MenuItem icon="Cut" on:click={() => storeComponentForCopy(true)}>
Copy Cut
</MenuItem> </MenuItem>
<MenuItem <MenuItem icon="Copy" on:click={() => storeComponentForCopy(false)}>
icon="LayersBringToFront" Copy
on:click={() => pasteComponent("above")} </MenuItem>
disabled={noPaste} <MenuItem
> icon="LayersBringToFront"
Paste above on:click={() => pasteComponent("above")}
</MenuItem> disabled={noPaste}
<MenuItem >
icon="LayersSendToBack" Paste above
on:click={() => pasteComponent("below")} </MenuItem>
disabled={noPaste} <MenuItem
> icon="LayersSendToBack"
Paste below on:click={() => pasteComponent("below")}
</MenuItem> disabled={noPaste}
<MenuItem >
icon="ShowOneLayer" Paste below
on:click={() => pasteComponent("inside")} </MenuItem>
disabled={noPaste || noChildrenAllowed} <MenuItem
> icon="ShowOneLayer"
Paste inside on:click={() => pasteComponent("inside")}
</MenuItem> disabled={noPaste || noChildrenAllowed}
</ActionMenu> >
<ConfirmDialog Paste inside
bind:this={confirmDeleteDialog} </MenuItem>
title="Confirm Deletion" </ActionMenu>
body={`Are you sure you wish to delete this '${definition?.name}' component?`} <ConfirmDialog
okText="Delete Component" bind:this={confirmDeleteDialog}
onOk={deleteComponent} title="Confirm Deletion"
/> body={`Are you sure you wish to delete this '${definition?.name}' component?`}
okText="Delete Component"
onOk={deleteComponent}
/>
{/if}

View File

@ -3,6 +3,7 @@
import { DropEffect, DropPosition } from "./dragDropStore" import { DropEffect, DropPosition } from "./dragDropStore"
import ComponentDropdownMenu from "../ComponentDropdownMenu.svelte" import ComponentDropdownMenu from "../ComponentDropdownMenu.svelte"
import NavItem from "components/common/NavItem.svelte" import NavItem from "components/common/NavItem.svelte"
import { capitalise } from "helpers"
export let components = [] export let components = []
export let currentComponent export let currentComponent
@ -10,8 +11,6 @@
export let level = 0 export let level = 0
export let dragDropStore export let dragDropStore
const isScreenslot = name => name?.endsWith("screenslot")
const selectComponent = component => { const selectComponent = component => {
store.actions.components.select(component) store.actions.components.select(component)
} }
@ -42,6 +41,16 @@
return false return false
} }
const getComponentText = component => {
if (component._instanceName) {
return component._instanceName
}
const type =
component._component.replace("@budibase/standard-components/", "") ||
"component"
return capitalise(type)
}
</script> </script>
<ul> <ul>
@ -63,9 +72,7 @@
on:dragstart={dragstart(component)} on:dragstart={dragstart(component)}
on:dragover={dragover(component, index)} on:dragover={dragover(component, index)}
on:drop={dragDropStore.actions.drop} on:drop={dragDropStore.actions.drop}
text={isScreenslot(component._component) text={getComponentText(component)}
? "Screenslot"
: component._instanceName}
withArrow withArrow
indentLevel={level + 1} indentLevel={level + 1}
selected={$store.selectedComponentId === component._id} selected={$store.selectedComponentId === component._id}

View File

@ -15,6 +15,7 @@ const EMPTY_LAYOUT = {
{ {
_id: "7fcf11e4-6f5b-4085-8e0d-9f3d44c98967", _id: "7fcf11e4-6f5b-4085-8e0d-9f3d44c98967",
_component: "@budibase/standard-components/screenslot", _component: "@budibase/standard-components/screenslot",
_instanceName: "Screen slot",
_styles: { _styles: {
normal: { normal: {
flex: "1 1 auto", flex: "1 1 auto",
@ -63,6 +64,7 @@ const BASE_LAYOUTS = [
{ {
_id: "7fcf11e4-6f5b-4085-8e0d-9f3d44c98967", _id: "7fcf11e4-6f5b-4085-8e0d-9f3d44c98967",
_component: "@budibase/standard-components/screenslot", _component: "@budibase/standard-components/screenslot",
_instanceName: "Screen slot",
_styles: { _styles: {
normal: { normal: {
flex: "1 1 auto", flex: "1 1 auto",
@ -109,6 +111,7 @@ const BASE_LAYOUTS = [
{ {
_id: "7fcf11e4-6f5b-4085-8e0d-9f3d44c98967", _id: "7fcf11e4-6f5b-4085-8e0d-9f3d44c98967",
_component: "@budibase/standard-components/screenslot", _component: "@budibase/standard-components/screenslot",
_instanceName: "Screen slot",
_styles: { _styles: {
normal: { normal: {
flex: "1 1 auto", flex: "1 1 auto",

View File

@ -230,7 +230,8 @@
"screenslot": { "screenslot": {
"name": "Screenslot", "name": "Screenslot",
"icon": "WebPage", "icon": "WebPage",
"description": "Contains your app screens" "description": "Contains your app screens",
"editable": false
}, },
"button": { "button": {
"name": "Button", "name": "Button",