Hide field layout settings for normal field components, and only show them when editing from within a form block
This commit is contained in:
parent
e2c2f5e2a6
commit
b1f2337849
|
@ -134,6 +134,7 @@
|
||||||
<span>{field.field}</span>
|
<span>{field.field}</span>
|
||||||
</div>
|
</div>
|
||||||
<ComponentSettingsSection
|
<ComponentSettingsSection
|
||||||
|
includeHidden
|
||||||
componentInstance={pseudoComponentInstance}
|
componentInstance={pseudoComponentInstance}
|
||||||
componentDefinition={parsedComponentDef}
|
componentDefinition={parsedComponentDef}
|
||||||
isScreen={false}
|
isScreen={false}
|
||||||
|
|
|
@ -16,10 +16,16 @@
|
||||||
export let isScreen = false
|
export let isScreen = false
|
||||||
export let onUpdateSetting
|
export let onUpdateSetting
|
||||||
export let showSectionTitle = true
|
export let showSectionTitle = true
|
||||||
|
export let includeHidden = false
|
||||||
|
|
||||||
$: sections = getSections(componentInstance, componentDefinition, isScreen)
|
$: sections = getSections(
|
||||||
|
componentInstance,
|
||||||
|
componentDefinition,
|
||||||
|
isScreen,
|
||||||
|
includeHidden
|
||||||
|
)
|
||||||
|
|
||||||
const getSections = (instance, definition, isScreen) => {
|
const getSections = (instance, definition, isScreen, includeHidden) => {
|
||||||
const settings = definition?.settings ?? []
|
const settings = definition?.settings ?? []
|
||||||
const generalSettings = settings.filter(setting => !setting.section)
|
const generalSettings = settings.filter(setting => !setting.section)
|
||||||
const customSections = settings.filter(setting => setting.section)
|
const customSections = settings.filter(setting => setting.section)
|
||||||
|
@ -38,7 +44,12 @@
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
section.settings.forEach(setting => {
|
section.settings.forEach(setting => {
|
||||||
setting.visible = canRenderControl(instance, setting, isScreen)
|
setting.visible = canRenderControl(
|
||||||
|
instance,
|
||||||
|
setting,
|
||||||
|
isScreen,
|
||||||
|
includeHidden
|
||||||
|
)
|
||||||
})
|
})
|
||||||
section.visible =
|
section.visible =
|
||||||
section.name === "General" ||
|
section.name === "General" ||
|
||||||
|
@ -108,16 +119,20 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const canRenderControl = (instance, setting, isScreen) => {
|
const canRenderControl = (instance, setting, isScreen, includeHidden) => {
|
||||||
// Prevent rendering on click setting for screens
|
// Prevent rendering on click setting for screens
|
||||||
if (setting?.type === "event" && isScreen) {
|
if (setting?.type === "event" && isScreen) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// Check we have a component to render for this setting
|
||||||
const control = getComponentForSetting(setting)
|
const control = getComponentForSetting(setting)
|
||||||
if (!control) {
|
if (!control) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// Check if setting is hidden
|
||||||
|
if (setting.hidden && !includeHidden) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return shouldDisplay(instance, setting)
|
return shouldDisplay(instance, setting)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -2603,6 +2603,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -2688,6 +2689,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -2768,6 +2770,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -2853,6 +2856,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -3049,6 +3053,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -3239,6 +3244,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -3347,6 +3353,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -3454,6 +3461,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -3563,6 +3571,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -3692,6 +3701,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -3896,6 +3906,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -3992,6 +4003,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -4072,6 +4084,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
@ -6094,6 +6107,7 @@
|
||||||
"label": "Layout",
|
"label": "Layout",
|
||||||
"key": "span",
|
"key": "span",
|
||||||
"defaultValue": 6,
|
"defaultValue": 6,
|
||||||
|
"hidden": true,
|
||||||
"showInBar": true,
|
"showInBar": true,
|
||||||
"barStyle": "buttons",
|
"barStyle": "buttons",
|
||||||
"options": [
|
"options": [
|
||||||
|
|
Loading…
Reference in New Issue