Skip to content
Permalink
Browse files

fix(MdSelect): make options in disabled groups un-selectable (#1293)

* fix(MdSelect): make options in disabled groups un-selectable

fix #1286

* fix(MdSelect): make multiple selection checkboxes effective

* style(MdOption): remove empty lines
  • Loading branch information...
VdustR authored and marcosmoura committed Dec 22, 2017
1 parent c9a2b9f commit 89138ebddd49097e1cb07f7dec3ae6647294909f
Showing with 23 additions and 13 deletions.
  1. +21 −9 src/components/MdField/MdSelect/MdOption.vue
  2. +2 −4 src/components/MdField/MdSelect/MdSelect.vue
@@ -1,6 +1,6 @@
<template>
<md-menu-item :class="optionClasses" :disabled="isDisabled" @click="setSelection">
<md-checkbox class="md-primary" v-model="isChecked" v-if="MdSelect.multiple" />
<md-checkbox class="md-primary" v-model="isChecked" v-if="MdSelect.multiple" :disabled="isDisabled" />

<span class="md-list-item-text" ref="text">
<slot />
@@ -52,8 +52,17 @@
}
},
watch: {
inputLabel () {
selectValue () {
this.setIsSelected()
},
isChecked (val) {
if (val === this.isSelected) {
return
}
this.setSelection()
},
isSelected (val) {
this.isChecked = val
}
},
methods: {
@@ -67,17 +76,24 @@
return slot ? slot[0].text.trim() : ''
},
setIsSelected () {
this.isSelected = this.inputLabel === this.getTextContent()
if (!this.isMultiple) {
this.isSelected = this.selectValue === this.value
return
}
if (this.selectValue === undefined) {
this.isSelected = false
return
}
this.isSelected = this.selectValue.includes(this.value)
},
setSingleSelection () {
this.MdSelect.setValue(this.value)
},
setMultipleSelection () {
this.isChecked = !this.isChecked
this.MdSelect.setMultipleValue(this.value)
},
setSelection () {
if (!this.disabled) {
if (!this.isDisabled) {
if (this.isMultiple) {
this.setMultipleSelection()
} else {
@@ -95,10 +111,6 @@
created () {
this.setItem()
this.setIsSelected()
if (this.isMultiple && this.selectValue && this.selectValue.length) {
this.isChecked = this.selectValue.includes(this.value)
}
}
}
</script>
@@ -89,7 +89,7 @@
items: {},
label: null,
multiple: false,
modelValue: this.model,
modelValue: this.localValue,
setValue: this.setValue,
setContent: this.setContent,
setMultipleValue: this.setMultipleValue,
@@ -115,6 +115,7 @@
immediate: true,
handler (val) {
this.setFieldContent()
this.MdSelect.modelValue = this.localValue
this.emitSelected(val)
}
},
@@ -124,9 +125,6 @@
this.MdSelect.multiple = isMultiple
this.$nextTick(() => this.initialLocalValueByDefault())
}
},
model () {
this.MdSelect.modelValue = this.model
}
},
methods: {

0 comments on commit 89138eb

Please sign in to comment.
You can’t perform that action at this time.