Tooltips & disableds
This commit is contained in:
parent
31c1fa8b7a
commit
6413d89cf1
|
@ -48,46 +48,53 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
$: displayColumns = columns.map(c => {
|
$: displayColumns = columns.map(c => {
|
||||||
const isRequired = helpers.schema.isRequired(c.schema.constraints)
|
const isRequired =
|
||||||
const requiredTooltip = isRequired && "Required columns must be writable"
|
c.primaryDisplay || helpers.schema.isRequired(c.schema.constraints)
|
||||||
const editEnabled =
|
|
||||||
!isRequired || columnToPermissionOptions(c) !== FieldPermissions.WRITABLE
|
const requiredTooltips = {
|
||||||
|
[FieldPermissions.WRITABLE]:
|
||||||
|
(c.primaryDisplay && "Display column must be writable") ||
|
||||||
|
(isRequired && "Required columns must be writable"),
|
||||||
|
[FieldPermissions.READONLY]:
|
||||||
|
(c.primaryDisplay && "Display column cannot be read-only") ||
|
||||||
|
(isRequired && "Required columns cannot be read-only"),
|
||||||
|
[FieldPermissions.HIDDEN]:
|
||||||
|
(c.primaryDisplay && "Display column cannot be hidden") ||
|
||||||
|
(isRequired && "Required columns cannot be hidden"),
|
||||||
|
}
|
||||||
|
|
||||||
const options = []
|
const options = []
|
||||||
|
|
||||||
if (permissionsObj[FieldPermissions.WRITABLE]) {
|
let permission
|
||||||
|
if ((permission = permissionsObj[FieldPermissions.WRITABLE])) {
|
||||||
|
const tooltip = requiredTooltips[FieldPermissions.WRITABLE] || "Writable"
|
||||||
options.push({
|
options.push({
|
||||||
icon: "Edit",
|
icon: "Edit",
|
||||||
value: FieldPermissions.WRITABLE,
|
value: FieldPermissions.WRITABLE,
|
||||||
tooltip: (!editEnabled && requiredTooltip) || "Writable",
|
tooltip,
|
||||||
disabled:
|
disabled: isRequired || permission.disabled,
|
||||||
!editEnabled || permissionsObj[FieldPermissions.WRITABLE].disabled,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permissionsObj[FieldPermissions.READONLY]) {
|
if ((permission = permissionsObj[FieldPermissions.READONLY])) {
|
||||||
|
const tooltip =
|
||||||
|
(requiredTooltips[FieldPermissions.READONLY] || "Read-only") +
|
||||||
|
(permission.disabled && " (premium feature)")
|
||||||
options.push({
|
options.push({
|
||||||
icon: "Visibility",
|
icon: "Visibility",
|
||||||
value: FieldPermissions.READONLY,
|
value: FieldPermissions.READONLY,
|
||||||
tooltip: !permissionsObj[FieldPermissions.READONLY].disabled
|
tooltip,
|
||||||
? requiredTooltip || "Read only"
|
disabled: permission.disabled || isRequired,
|
||||||
: "Read only (premium feature)",
|
|
||||||
disabled:
|
|
||||||
permissionsObj[FieldPermissions.READONLY].disabled || isRequired,
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permissionsObj[FieldPermissions.HIDDEN]) {
|
if ((permission = permissionsObj[FieldPermissions.HIDDEN])) {
|
||||||
|
const tooltip = requiredTooltips[FieldPermissions.HIDDEN] || "Hidden"
|
||||||
options.push({
|
options.push({
|
||||||
icon: "VisibilityOff",
|
icon: "VisibilityOff",
|
||||||
value: FieldPermissions.HIDDEN,
|
value: FieldPermissions.HIDDEN,
|
||||||
disabled:
|
disabled: permission.disabled || isRequired,
|
||||||
c.primaryDisplay ||
|
tooltip,
|
||||||
isRequired ||
|
|
||||||
permissionsObj[FieldPermissions.HIDDEN].disabled,
|
|
||||||
tooltip:
|
|
||||||
(c.primaryDisplay && "Display column cannot be hidden") ||
|
|
||||||
requiredTooltip ||
|
|
||||||
"Hidden",
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue