Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add disabled prop to v-form #2033

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/VCheckbox/VCheckbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default {

const data = {
attrs: {
tabindex: this.disabled
tabindex: this.isDisabled
? -1
: this.internalTabIndex || this.tabindex,
role: 'checkbox',
Expand Down
12 changes: 10 additions & 2 deletions src/components/VForm/VForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ export default {
},

props: {
value: Boolean,
lazyValidation: Boolean
disabled: Boolean,
lazyValidation: Boolean,
value: Boolean
},

watch: {
disabled (disabled) {
for (const input of this.inputs) {
input.formDisabled = disabled
}
},
errorBag: {
handler () {
const errors = Object.values(this.errorBag).includes(true)
Expand Down Expand Up @@ -62,6 +68,8 @@ export default {
}, { immediate: true })
}

child.formDisabled = this.disabled

if (!this.lazyValidation) return watcher(child)

// Only start watching inputs if we need to
Expand Down
4 changes: 2 additions & 2 deletions src/components/VRadioGroup/VRadio.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default {
return this.addColorClassChecks({
'input-group': true,
'input-group--active': this.isActive,
'input-group--disabled': this.disabled,
'input-group--disabled': this.isDisabled,
'input-group--selection-controls': true,
'input-group--tab-focused': this.tabFocused,
'radio': true,
Expand Down Expand Up @@ -113,7 +113,7 @@ export default {
const mandatory = this.isMandatory &&
this.isMandatory() || false

if (!this.disabled && (!this.isActive || !mandatory)) {
if (!this.isDisabled && (!this.isActive || !mandatory)) {
this.$refs.input.checked = true
this.isActive = true
this.$emit('change', this.value)
Expand Down
2 changes: 1 addition & 1 deletion src/components/VRadioGroup/VRadioGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default {
.filter((child) => child.$el.classList.contains('radio'))
},
toggleRadio (value) {
if (this.disabled) {
if (this.isDisabled) {
return
}

Expand Down
8 changes: 4 additions & 4 deletions src/components/VSelect/VSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,12 +436,12 @@ export default {
return {
...listeners,
click: () => {
if (this.disabled || this.readonly) return
if (this.isDisabled || this.readonly) return
this.showMenuItems()
this.selectedIndex = -1
},
focus: () => {
if (this.disabled || this.readonly) return
if (this.isDisabled || this.readonly) return

!this.isFocused && this.focus()
},
Expand Down Expand Up @@ -583,7 +583,7 @@ export default {
render (h) {
const data = {
attrs: {
tabindex: this.isAutocomplete || this.disabled ? -1 : this.tabindex,
tabindex: this.isAutocomplete || this.isDisabled ? -1 : this.tabindex,
...(this.isAutocomplete ? null : this.$attrs),
role: this.isAutocomplete ? null : 'combobox'
}
Expand All @@ -595,7 +595,7 @@ export default {
} else {
data.on = {
click: () => {
if (this.disabled || this.readonly) return
if (this.isDisabled || this.readonly) return

// Workaround for clicking select
// when using autocomplete
Expand Down
10 changes: 5 additions & 5 deletions src/components/VSelect/mixins/select-generators.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default {
closeOnClick: false,
closeOnContentClick: !this.isMultiple,
contentClass: this.computedContentClass,
disabled: this.disabled,
disabled: this.isDisabled,
maxHeight: this.maxHeight,
nudgeTop,
offsetY,
Expand Down Expand Up @@ -63,9 +63,9 @@ export default {
},
attrs: {
...this.$attrs,
disabled: this.disabled || !this.isAutocomplete,
disabled: this.isDisabled || !this.isAutocomplete,
readonly: this.readonly,
tabindex: this.disabled || !this.isAutocomplete ? -1 : this.tabindex
tabindex: this.isDisabled || !this.isAutocomplete ? -1 : this.tabindex
},
domProps: {
value: this.maskText(this.lazySearch || '')
Expand Down Expand Up @@ -149,11 +149,11 @@ export default {
item,
index,
selected: index === this.selectedIndex,
disabled: this.disabled || this.readonly
disabled: this.isDisabled || this.readonly
})
},
genChipSelection (item, index) {
const isDisabled = this.disabled || this.readonly
const isDisabled = this.isDisabled || this.readonly
const click = e => {
if (isDisabled) return

Expand Down
6 changes: 3 additions & 3 deletions src/components/VSlider/VSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export default {
'input-group--slider': true,
'input-group--active': this.isActive,
'input-group--dirty': this.inputWidth > 0,
'input-group--disabled': this.disabled,
'input-group--ticks': !this.disabled && this.step
'input-group--disabled': this.isDisabled,
'input-group--ticks': !this.isDisabled && this.step
}
},
inputValue: {
Expand Down Expand Up @@ -162,7 +162,7 @@ export default {

methods: {
calculateScale (scale) {
return this.disabled ? scale - 0.015 : scale
return this.isDisabled ? scale - 0.015 : scale
},
onMouseDown (e) {
this.keyPressed = 2
Expand Down
2 changes: 1 addition & 1 deletion src/components/VSwitch/VSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default {
return {
'input-group--selection-controls__container': true,
'input-group--selection-controls__container--light': this.light,
'input-group--selection-controls__container--disabled': this.disabled
'input-group--selection-controls__container--disabled': this.isDisabled
}
},
toggleClasses () {
Expand Down
2 changes: 1 addition & 1 deletion src/components/VTextField/VTextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default {
style: {},
domProps: {
autofocus: this.autofocus,
disabled: this.disabled,
disabled: this.isDisabled,
required: this.required,
value: this.maskText(this.lazyValue || '')
},
Expand Down
10 changes: 7 additions & 3 deletions src/mixins/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {

data () {
return {
formDisabled: false,
isFocused: false,
tabFocused: false,
internalTabIndex: null,
Expand Down Expand Up @@ -45,14 +46,17 @@ export default {
},

computed: {
isDisabled () {
return this.disabled || this.formDisabled
},
inputGroupClasses () {
return Object.assign({
'input-group': true,
'input-group--async-loading': this.loading !== false,
'input-group--focused': this.isFocused,
'input-group--dirty': this.isDirty,
'input-group--tab-focused': this.tabFocused,
'input-group--disabled': this.disabled,
'input-group--disabled': this.isDisabled,
'input-group--error': this.hasError,
'input-group--append-icon': this.appendIcon,
'input-group--prepend-icon': this.prependIcon,
Expand Down Expand Up @@ -136,7 +140,7 @@ export default {
'input-group__icon-clearable': shouldClear
},
props: {
disabled: this.disabled
disabled: this.isDisabled
},
on: {
click: e => {
Expand All @@ -156,7 +160,7 @@ export default {
data = Object.assign({}, {
'class': this.inputGroupClasses,
attrs: {
tabindex: this.disabled
tabindex: this.isDisabled
? -1
: this.internalTabIndex || this.tabindex
},
Expand Down