Browse Source

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

Containers support onClick
master
melohagan 4 years ago
committed by GitHub
parent
commit
fd836c0191
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ComponentSettingsSection.svelte
  2. 5
      packages/client/manifest.json
  3. 15
      packages/client/src/components/app/Container.svelte
  4. 4
      packages/client/src/utils/buttonActions.js

9
packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ComponentSettingsSection.svelte

@ -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)
if (!control) {
return false
@ -87,7 +92,7 @@
/>
{/if}
{#each section.settings as setting (setting.key)}
{#if canRenderControl(setting)}
{#if canRenderControl(setting, isScreen)}
<PropertyControl
type={setting.type}
control={getComponentForSetting(setting)}

5
packages/client/manifest.json

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

15
packages/client/src/components/app/Container.svelte

@ -10,6 +10,7 @@
export let size
export let gap
export let wrap
export let onClick
$: directionClass = direction ? `valid-container direction-${direction}` : ""
$: hAlignClass = hAlign ? `hAlign-${hAlign}` : ""
@ -25,7 +26,13 @@
].join(" ")
</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 />
</div>
@ -104,4 +111,10 @@
.wrap {
flex-wrap: wrap;
}
.clickable {
cursor: pointer;
}
.clickable :global(*) {
pointer-events: none;
}
</style>

4
packages/client/src/utils/buttonActions.js

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

Loading…
Cancel
Save