Update conditional setting rendering to support nested paths and multiple values, and hide grid block CRUD when using non DS+
This commit is contained in:
parent
e0b748a7bc
commit
5c7bde95ab
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { isEmpty } from "lodash/fp"
|
import { helpers } from "@budibase/shared-core"
|
||||||
import { Input, DetailSummary, notifications } from "@budibase/bbui"
|
import { Input, DetailSummary, notifications } from "@budibase/bbui"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import PropertyControl from "components/design/settings/controls/PropertyControl.svelte"
|
import PropertyControl from "components/design/settings/controls/PropertyControl.svelte"
|
||||||
|
@ -73,35 +73,31 @@
|
||||||
// Parse dependant settings
|
// Parse dependant settings
|
||||||
if (setting.dependsOn) {
|
if (setting.dependsOn) {
|
||||||
let dependantSetting = setting.dependsOn
|
let dependantSetting = setting.dependsOn
|
||||||
let dependantValue = null
|
let dependantValues = null
|
||||||
let invert = !!setting.dependsOn.invert
|
let invert = !!setting.dependsOn.invert
|
||||||
if (typeof setting.dependsOn === "object") {
|
if (typeof setting.dependsOn === "object") {
|
||||||
dependantSetting = setting.dependsOn.setting
|
dependantSetting = setting.dependsOn.setting
|
||||||
dependantValue = setting.dependsOn.value
|
dependantValues = setting.dependsOn.value
|
||||||
}
|
}
|
||||||
if (!dependantSetting) {
|
if (!dependantSetting) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no specific value is depended upon, check if a value exists at all
|
// Ensure values is an array
|
||||||
// for the dependent setting
|
if (!Array.isArray(dependantValues)) {
|
||||||
if (dependantValue == null) {
|
dependantValues = [dependantValues]
|
||||||
const currentValue = instance[dependantSetting]
|
|
||||||
if (currentValue === false) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if (currentValue === true) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return !isEmpty(currentValue)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise check the value matches
|
// If inverting, we want to ensure that we don't have any matches.
|
||||||
if (invert) {
|
// If not inverting, we want to ensure that we do have any matches.
|
||||||
return instance[dependantSetting] !== dependantValue
|
const currentVal = helpers.deepGet(instance, dependantSetting)
|
||||||
} else {
|
const anyMatches = dependantValues.some(dependantVal => {
|
||||||
return instance[dependantSetting] === dependantValue
|
if (dependantVal == null) {
|
||||||
}
|
return currentVal == null || currentVal === false || currentVal === ""
|
||||||
|
}
|
||||||
|
return dependantVal === currentVal
|
||||||
|
})
|
||||||
|
return anyMatches !== invert
|
||||||
}
|
}
|
||||||
|
|
||||||
return typeof setting.visible == "boolean" ? setting.visible : true
|
return typeof setting.visible == "boolean" ? setting.visible : true
|
||||||
|
|
|
@ -5617,29 +5617,37 @@
|
||||||
"label": "Clicked row",
|
"label": "Clicked row",
|
||||||
"key": "row"
|
"key": "row"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"dependsOn": {
|
|
||||||
"setting": "allowEditRows",
|
|
||||||
"value": false
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Add rows",
|
"label": "Add rows",
|
||||||
"key": "allowAddRows",
|
"key": "allowAddRows",
|
||||||
"defaultValue": true
|
"defaultValue": true,
|
||||||
|
"dependsOn": {
|
||||||
|
"setting": "datasource.type",
|
||||||
|
"value": ["table", "viewV2"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Edit rows",
|
"label": "Edit rows",
|
||||||
"key": "allowEditRows",
|
"key": "allowEditRows",
|
||||||
"defaultValue": true
|
"defaultValue": true,
|
||||||
|
"dependsOn": {
|
||||||
|
"setting": "datasource.type",
|
||||||
|
"value": ["table", "viewV2"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"label": "Delete rows",
|
"label": "Delete rows",
|
||||||
"key": "allowDeleteRows",
|
"key": "allowDeleteRows",
|
||||||
"defaultValue": true
|
"defaultValue": true,
|
||||||
|
"dependsOn": {
|
||||||
|
"setting": "datasource.type",
|
||||||
|
"value": ["table", "viewV2"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
|
|
Loading…
Reference in New Issue