1
0
Fork 0
mirror of synced 2024-09-08 13:41:09 +12:00

Add new disableBindings property to prevent a text field from being bindable when required

This commit is contained in:
Andrew Kingston 2023-11-09 16:20:44 +00:00
parent d92df57daa
commit bb47b91064
4 changed files with 17 additions and 7 deletions

View file

@ -21,6 +21,7 @@
export let allowHelpers = true export let allowHelpers = true
export let updateOnChange = true export let updateOnChange = true
export let drawerLeft export let drawerLeft
export let disableBindings = false
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
let bindingDrawer let bindingDrawer
@ -62,7 +63,7 @@
{placeholder} {placeholder}
{updateOnChange} {updateOnChange}
/> />
{#if !disabled} {#if !disabled && !disableBindings}
<div <div
class="icon" class="icon"
on:click={() => { on:click={() => {

View file

@ -17,18 +17,24 @@
// If this is a nested setting (for example inside a grid or form block) then // If this is a nested setting (for example inside a grid or form block) then
// we need to mark all the settings of the actual buttons as nested too, to // we need to mark all the settings of the actual buttons as nested too, to
// allow us to reference context provided by the block // allow us to reference context provided by the block.
// We will need to update this in future if the normal button component
// gets broken into multiple settings sections, as we assume a flat array.
const updatedNestedFlags = settings => { const updatedNestedFlags = settings => {
if (!nested) { if (!nested || !settings?.length) {
return settings return settings
} }
// Buttons do not currently have any sections, so this works. let newSettings = settings.map(setting => ({
// We will need to update this in future if the normal button component
// gets broken into multiple settings sections
return settings?.map(setting => ({
...setting, ...setting,
nested: true, nested: true,
})) }))
// We need to prevent bindings for the button names because of how grid
// blocks work. This is an edge case but unavoidable.
let name = newSettings.find(x => x.key === "text")
if (name) {
name.disableBindings = true
}
return newSettings
} }
</script> </script>

View file

@ -23,6 +23,7 @@
export let highlighted = false export let highlighted = false
export let propertyFocus = false export let propertyFocus = false
export let info = null export let info = null
export let disableBindings = false
$: nullishValue = value == null || value === "" $: nullishValue = value == null || value === ""
$: allBindings = getAllBindings(bindings, componentBindings, nested) $: allBindings = getAllBindings(bindings, componentBindings, nested)
@ -99,6 +100,7 @@
{nested} {nested}
{key} {key}
{type} {type}
{disableBindings}
{...props} {...props}
on:drawerHide on:drawerHide
on:drawerShow on:drawerShow

View file

@ -179,6 +179,7 @@
highlighted={$store.highlightedSettingKey === setting.key} highlighted={$store.highlightedSettingKey === setting.key}
propertyFocus={$store.propertyFocus === setting.key} propertyFocus={$store.propertyFocus === setting.key}
info={setting.info} info={setting.info}
disableBindings={setting.disableBindings}
props={{ props={{
// Generic settings // Generic settings
placeholder: setting.placeholder || null, placeholder: setting.placeholder || null,