Merge pull request #5829 from Budibase/feature/clickable-container

Containers support onClick
This commit is contained in:
melohagan 2022-08-17 16:34:41 +01:00 committed by GitHub
commit b2ae542869
4 changed files with 28 additions and 5 deletions

View File

@ -36,7 +36,12 @@
} }
} }
const canRenderControl = setting => { const canRenderControl = (setting, isScreen) => {
// Prevent rendering on click setting for screens
if (setting?.type === "event" && isScreen) {
return false
}
const control = getComponentForSetting(setting) const control = getComponentForSetting(setting)
if (!control) { if (!control) {
return false return false
@ -87,7 +92,7 @@
/> />
{/if} {/if}
{#each section.settings as setting (setting.key)} {#each section.settings as setting (setting.key)}
{#if canRenderControl(setting)} {#if canRenderControl(setting, isScreen)}
<PropertyControl <PropertyControl
type={setting.type} type={setting.type}
control={getComponentForSetting(setting)} control={getComponentForSetting(setting)}

View File

@ -237,6 +237,11 @@
"showInBar": true, "showInBar": true,
"barIcon": "ModernGridView", "barIcon": "ModernGridView",
"barTitle": "Wrap" "barTitle": "Wrap"
},
{
"type": "event",
"label": "On Click",
"key": "onClick"
} }
] ]
}, },

View File

@ -10,6 +10,7 @@
export let size export let size
export let gap export let gap
export let wrap export let wrap
export let onClick
$: directionClass = direction ? `valid-container direction-${direction}` : "" $: directionClass = direction ? `valid-container direction-${direction}` : ""
$: hAlignClass = hAlign ? `hAlign-${hAlign}` : "" $: hAlignClass = hAlign ? `hAlign-${hAlign}` : ""
@ -25,7 +26,13 @@
].join(" ") ].join(" ")
</script> </script>
<div class={classNames} use:styleable={$component.styles} class:wrap> <div
class={classNames}
class:clickable={!!onClick}
use:styleable={$component.styles}
class:wrap
on:click={onClick}
>
<slot /> <slot />
</div> </div>
@ -104,4 +111,10 @@
.wrap { .wrap {
flex-wrap: wrap; flex-wrap: wrap;
} }
.clickable {
cursor: pointer;
}
.clickable :global(*) {
pointer-events: none;
}
</style> </style>

View File

@ -334,8 +334,8 @@ const confirmTextMap = {
*/ */
export const enrichButtonActions = (actions, context) => { export const enrichButtonActions = (actions, context) => {
// Prevent button actions in the builder preview // Prevent button actions in the builder preview
if (!actions || get(builderStore).inBuilder) { if (!actions?.length || get(builderStore).inBuilder) {
return () => {} return null
} }
// If this is a function then it has already been enriched // If this is a function then it has already been enriched