Skip to content

Commit

Permalink
Add disabled function resolver
Browse files Browse the repository at this point in the history
Enable callack based disabled property value
  • Loading branch information
Denis Peters committed Mar 3, 2022
1 parent 832d732 commit ecc3fe1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/ui/AssociationSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ const AssociationSelector = fnObserver(props => {
}

const effectiveMode = modeFromProps || formConfig.options.mode;
const isDisabled = typeof disabled === "function" ? disabled() : disabled;

return (
<React.Fragment>
Expand Down Expand Up @@ -383,7 +384,7 @@ const AssociationSelector = fnObserver(props => {
onClick={
() => removeLink(formConfig.root, selected, link, name, value)
}
disabled={disabled}
disabled={isDisabled}
>
<Icon className="fa-times"/>
</button>
Expand All @@ -397,7 +398,7 @@ const AssociationSelector = fnObserver(props => {
type="Button"
className="btn btn-light"
onClick={ openModal }
disabled={disabled}
disabled={isDisabled}
>
<Icon className="fa-clipboard-check mr-1"/>
Select
Expand Down Expand Up @@ -490,7 +491,17 @@ AssociationSelector.propTypes = {
* properties on that new link. ( link => ... )
*
*/
onNew: PropTypes.func
onNew: PropTypes.func,


/**
* Disables the AssociationSelector.
* Can be defined as callback function.
*/
disabled: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.func
]),

};

Expand Down

0 comments on commit ecc3fe1

Please sign in to comment.