1
0
Fork 0
mirror of synced 2024-07-04 14:01:27 +12:00

Fix instance name on layouts

This commit is contained in:
Andrew Kingston 2021-06-23 12:26:46 +01:00
parent 997efa62b3
commit d7cc6836a9
7 changed files with 61 additions and 64 deletions

View file

@ -87,14 +87,16 @@
</script> </script>
<DetailSummary name="General" collapsible={false}> <DetailSummary name="General" collapsible={false}>
<PropertyControl {#if !componentInstance._component.endsWith("/layout")}
bindable={false} <PropertyControl
control={Input} bindable={false}
label="Name" control={Input}
key="_instanceName" label="Name"
value={componentInstance._instanceName} key="_instanceName"
onChange={val => updateProp("_instanceName", val)} value={componentInstance._instanceName}
/> onChange={val => updateProp("_instanceName", val)}
/>
{/if}
{#if settings && settings.length > 0} {#if settings && settings.length > 0}
{#each settings as setting (`${componentInstance._id}-${setting.key}`)} {#each settings as setting (`${componentInstance._id}-${setting.key}`)}
{#if canRenderControl(setting)} {#if canRenderControl(setting)}
@ -114,8 +116,6 @@
/> />
{/if} {/if}
{/each} {/each}
{:else}
<div class="text">This component doesn't have any additional settings.</div>
{/if} {/if}
{#if componentDefinition?.info} {#if componentDefinition?.info}
<div class="text"> <div class="text">

View file

@ -1,5 +1,5 @@
<script> <script>
import PropertyGroup from "./PropertyControls/PropertyGroup.svelte" import StyleSection from "./StyleSection.svelte"
import * as ComponentStyles from "./componentStyles" import * as ComponentStyles from "./componentStyles"
export let componentDefinition export let componentDefinition
@ -23,10 +23,10 @@
{#if styles?.length > 0} {#if styles?.length > 0}
{#each styles as style} {#each styles as style}
<PropertyGroup <StyleSection
{style} {style}
name={style.label} name={style.label}
inline={style.inline} columns={style.columns}
properties={style.settings} properties={style.settings}
{componentInstance} {componentInstance}
/> />

View file

@ -1,10 +1,10 @@
<script> <script>
import PropertyControl from "./PropertyControl.svelte" import PropertyControl from "./PropertyControls/PropertyControl.svelte"
import { DetailSummary } from "@budibase/bbui" import { DetailSummary } from "@budibase/bbui"
import { store } from "builderStore" import { store } from "builderStore"
export let name export let name
export let inline = false export let columns
export let properties export let properties
export let componentInstance export let componentInstance
@ -25,31 +25,27 @@
</script> </script>
<DetailSummary collapsible={false} name={`${name}${changed ? " *" : ""}`}> <DetailSummary collapsible={false} name={`${name}${changed ? " *" : ""}`}>
<div class="group-content" class:inline> <div class="group-content" style="grid-template-columns: {columns || '1fr'}">
{#each properties as prop (`${componentInstance._id}-${prop.key}-${prop.label}`)} {#each properties as prop (`${componentInstance._id}-${prop.key}-${prop.label}`)}
<PropertyControl <div style="grid-column: {prop.column || 'auto'}">
bindable={false} <PropertyControl
label={`${prop.label}${hasPropChanged(style, prop) ? " *" : ""}`} bindable={false}
control={prop.control} label={`${prop.label}${hasPropChanged(style, prop) ? " *" : ""}`}
key={prop.key} control={prop.control}
value={style[prop.key]} key={prop.key}
onChange={val => store.actions.components.updateStyle(prop.key, val)} value={style[prop.key]}
props={getControlProps(prop)} onChange={val => store.actions.components.updateStyle(prop.key, val)}
/> props={getControlProps(prop)}
/>
</div>
{/each} {/each}
</div> </div>
</DetailSummary> </DetailSummary>
<style> <style>
.group-content { .group-content {
display: flex; display: grid;
flex-direction: column;
justify-content: flex-start;
align-items: stretch; align-items: stretch;
gap: var(--spacing-l); gap: var(--spacing-l);
} }
.inline {
display: grid;
grid-template-columns: 1fr 1fr;
}
</style> </style>

View file

@ -83,7 +83,7 @@ export const layout = [
export const margin = { export const margin = {
label: "Margin", label: "Margin",
inline: true, columns: "1fr 1fr",
settings: [ settings: [
{ {
label: "Top", label: "Top",
@ -170,7 +170,7 @@ export const margin = {
export const padding = { export const padding = {
label: "Padding", label: "Padding",
inline: true, columns: "1fr 1fr",
settings: [ settings: [
{ {
label: "Top", label: "Top",
@ -257,19 +257,19 @@ export const padding = {
export const size = { export const size = {
label: "Size", label: "Size",
inline: true, columns: "1fr 1fr",
settings: [ settings: [
{ {
label: "Width", label: "Width",
key: "width", key: "width",
control: Input, control: Input,
placeholder: "px", placeholder: "Auto",
}, },
{ {
label: "Height", label: "Height",
key: "height", key: "height",
control: Input, control: Input,
placeholder: "px", placeholder: "Auto",
}, },
], ],
} }
@ -386,6 +386,8 @@ export const typography = [
export const background = { export const background = {
label: "Background", label: "Background",
inline: true,
columns: "auto 1fr",
settings: [ settings: [
{ {
label: "Color", label: "Color",
@ -474,23 +476,13 @@ export const background = {
export const border = { export const border = {
label: "Border", label: "Border",
columns: "auto 1fr",
settings: [ settings: [
{ {
label: "Color", label: "Color",
key: "border-color", key: "border-color",
control: ColorPicker, control: ColorPicker,
}, },
{
label: "Radius",
key: "border-radius",
control: Select,
options: [
{ label: "Small", value: "0.25rem" },
{ label: "Medium", value: "0.5rem" },
{ label: "Large", value: "1rem" },
{ label: "Round", value: "100%" },
],
},
{ {
label: "Width", label: "Width",
key: "border-width", key: "border-width",
@ -501,10 +493,23 @@ export const border = {
{ label: "Large", value: "4px" }, { label: "Large", value: "4px" },
], ],
}, },
{
label: "Radius",
key: "border-radius",
control: Select,
column: "1 / 3",
options: [
{ label: "Small", value: "0.25rem" },
{ label: "Medium", value: "0.5rem" },
{ label: "Large", value: "1rem" },
{ label: "Round", value: "100%" },
],
},
{ {
label: "Shadow", label: "Shadow",
key: "box-shadow", key: "box-shadow",
control: Select, control: Select,
column: "1 / 3",
options: [ options: [
{ {
label: "Small", label: "Small",

View file

@ -14,6 +14,7 @@ exports.save = async function (ctx) {
...EMPTY_LAYOUT, ...EMPTY_LAYOUT,
...layout, ...layout,
} }
layout.props._instanceName = layout.name
} }
layout._id = layout._id || generateLayoutID() layout._id = layout._id || generateLayoutID()

View file

@ -57,6 +57,7 @@ const BASE_LAYOUTS = [
name: "Navigation Layout", name: "Navigation Layout",
props: { props: {
_id: "4f569166-a4f3-47ea-a09e-6d218c75586f", _id: "4f569166-a4f3-47ea-a09e-6d218c75586f",
_instanceName: "Navigation Layout",
_component: "@budibase/standard-components/layout", _component: "@budibase/standard-components/layout",
_children: [ _children: [
{ {
@ -102,6 +103,7 @@ const BASE_LAYOUTS = [
name: "Empty Layout", name: "Empty Layout",
props: { props: {
_id: "3723ffa1-f9e0-4c05-8013-98195c788ed6", _id: "3723ffa1-f9e0-4c05-8013-98195c788ed6",
_instanceName: "Empty Layout",
_component: "@budibase/standard-components/layout", _component: "@budibase/standard-components/layout",
_children: [ _children: [
{ {

View file

@ -5,7 +5,7 @@
"icon": "Sandbox", "icon": "Sandbox",
"hasChildren": true, "hasChildren": true,
"styleable": true, "styleable": true,
"illegalChildren": [], "styles": ["padding", "background"],
"settings": [ "settings": [
{ {
"type": "text", "type": "text",
@ -62,6 +62,7 @@
"icon": "Sandbox", "icon": "Sandbox",
"hasChildren": true, "hasChildren": true,
"showSettingsBar": true, "showSettingsBar": true,
"styles": ["padding", "size", "background", "border", "shadow"],
"settings": [ "settings": [
{ {
"type": "select", "type": "select",
@ -171,8 +172,7 @@
], ],
"defaultValue": "shrink" "defaultValue": "shrink"
} }
], ]
"styles": ["padding", "size", "background", "border", "shadow"]
}, },
"section": { "section": {
"name": "Section", "name": "Section",
@ -679,7 +679,6 @@
"name": "Bar Chart", "name": "Bar Chart",
"description": "Bar chart", "description": "Bar chart",
"icon": "GraphBarVertical", "icon": "GraphBarVertical",
"styleable": true,
"illegalChildren": ["section"], "illegalChildren": ["section"],
"settings": [ "settings": [
{ {
@ -780,7 +779,6 @@
"name": "Line Chart", "name": "Line Chart",
"description": "Line chart", "description": "Line chart",
"icon": "GraphTrend", "icon": "GraphTrend",
"styleable": true,
"illegalChildren": ["section"], "illegalChildren": ["section"],
"settings": [ "settings": [
{ {
@ -882,7 +880,6 @@
"name": "Area Chart", "name": "Area Chart",
"description": "Line chart", "description": "Line chart",
"icon": "GraphAreaStacked", "icon": "GraphAreaStacked",
"styleable": true,
"illegalChildren": ["section"], "illegalChildren": ["section"],
"settings": [ "settings": [
{ {
@ -996,7 +993,6 @@
"name": "Pie Chart", "name": "Pie Chart",
"description": "Pie chart", "description": "Pie chart",
"icon": "GraphPie", "icon": "GraphPie",
"styleable": true,
"illegalChildren": ["section"], "illegalChildren": ["section"],
"settings": [ "settings": [
{ {
@ -1074,7 +1070,6 @@
"name": "Donut Chart", "name": "Donut Chart",
"description": "Donut chart", "description": "Donut chart",
"icon": "GraphDonut", "icon": "GraphDonut",
"styleable": true,
"illegalChildren": ["section"], "illegalChildren": ["section"],
"settings": [ "settings": [
{ {
@ -1152,7 +1147,6 @@
"name": "Candlestick Chart", "name": "Candlestick Chart",
"description": "Candlestick chart", "description": "Candlestick chart",
"icon": "GraphBarVerticalStacked", "icon": "GraphBarVerticalStacked",
"styleable": true,
"illegalChildren": ["section"], "illegalChildren": ["section"],
"settings": [ "settings": [
{ {
@ -1665,7 +1659,6 @@
"table": { "table": {
"name": "Table", "name": "Table",
"icon": "Table", "icon": "Table",
"styleable": true,
"illegalChildren": ["section"], "illegalChildren": ["section"],
"hasChildren": true, "hasChildren": true,
"showEmptyState": false, "showEmptyState": false,
@ -1721,11 +1714,6 @@
} }
] ]
}, },
{
"type": "boolean",
"label": "Quiet",
"key": "quiet"
},
{ {
"type": "multifield", "type": "multifield",
"label": "Columns", "label": "Columns",
@ -1735,7 +1723,12 @@
}, },
{ {
"type": "boolean", "type": "boolean",
"label": "Auto Cols.", "label": "Quiet",
"key": "quiet"
},
{
"type": "boolean",
"label": "Auto Columns",
"key": "showAutoColumns", "key": "showAutoColumns",
"defaultValue": false "defaultValue": false
} }