Skip to content

Commit

Permalink
add isLimitDisabled to make the isDisabled judgment under max/min props
Browse files Browse the repository at this point in the history
  • Loading branch information
masongzhi committed May 28, 2019
1 parent 878c1c1 commit 6c7cb66
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion packages/checkbox/src/checkbox-button.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,17 @@
return this._checkboxGroup.checkboxGroupSize || this._elFormItemSize || (this.$ELEMENT || {}).size;
},
/* used to make the isDisabled judgment under max/min props */
isLimitDisabled() {
const { max, min } = this._checkboxGroup;
return !!(max || min) &&
(this.model.length >= max && !this.isChecked) ||
(this.model.length <= min && this.isChecked);
},
isDisabled() {
return this._checkboxGroup
? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || (this.model.length >= this._checkboxGroup.max && !this.isChecked) || (this.model.length <= this._checkboxGroup.min && this.isChecked)
? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled
: this.disabled || (this.elForm || {}).disabled;
}
},
Expand Down
10 changes: 9 additions & 1 deletion packages/checkbox/src/checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,17 @@
return this._checkboxGroup ? this._checkboxGroup.value : this.value;
},
/* used to make the isDisabled judgment under max/min props */
isLimitDisabled() {
const { max, min } = this._checkboxGroup;
return !!(max || min) &&
(this.model.length >= max && !this.isChecked) ||
(this.model.length <= min && this.isChecked);
},
isDisabled() {
return this.isGroup
? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || (this.model.length >= this._checkboxGroup.max && !this.isChecked) || (this.model.length <= this._checkboxGroup.min && this.isChecked)
? this._checkboxGroup.disabled || this.disabled || (this.elForm || {}).disabled || this.isLimitDisabled
: this.disabled || (this.elForm || {}).disabled;
},
Expand Down

0 comments on commit 6c7cb66

Please sign in to comment.