Skip to content

Commit

Permalink
Cleanup QItemWrapper intrusion, disable options everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
pdanpdan committed Nov 2, 2017
1 parent 43deb29 commit 4bd1cb7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/components/list/QItemMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export default {
tag: {
type: String,
default: 'div'
},
disable: Boolean
}
},
render (h, ctx) {
const
Expand All @@ -39,7 +38,7 @@ export default {
}

child.push(ctx.children)
data.staticClass = `q-item-main q-item-section${prop.inset ? ' q-item-main-inset' : ''}${prop.disable ? ' text-faded' : ''}${classes ? ` ${classes}` : ''}`
data.staticClass = `q-item-main q-item-section${prop.inset ? ' q-item-main-inset' : ''}${classes ? ` ${classes}` : ''}`

return h(prop.tag, data, child)
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/list/QItemWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ export default {
sublabel: cfg.sublabel,
labelLines: cfg.labelLines,
sublabelLines: cfg.sublabelLines,
inset: cfg.inset,
disable: cfg.disable
inset: cfg.inset
})

push(child, h, QItemSide, slot.right, replace, {
Expand Down
6 changes: 3 additions & 3 deletions src/components/select/QDialogSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
:class="alignClass"
>
<q-chip
v-for="{label, value} in selectedOptions"
v-for="{label, value, disable: optDisable} in selectedOptions"
:key="label"
small
:closable="!disable"
:closable="!disable && !optDisable"
:color="color"
@click.native.stop
@close="__toggle(value)"
@close="__toggleMultiple(value, disable || optDisable)"
>
{{ label }}
</q-chip>
Expand Down
7 changes: 5 additions & 2 deletions src/components/select/QSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
</q-field-reset>

<q-list
link
:separator="separator"
class="no-border scroll"
>
Expand All @@ -93,6 +92,8 @@
v-for="opt in visibleOptions"
:key="JSON.stringify(opt)"
:cfg="opt"
:link="!opt.disable"
:class="{'text-faded': opt.disable}"
slot-replace
@click.capture="__toggleMultiple(opt.value, opt.disable)"
>
Expand All @@ -117,6 +118,8 @@
v-for="opt in visibleOptions"
:key="JSON.stringify(opt)"
:cfg="opt"
:link="!opt.disable"
:class="{'text-faded': opt.disable}"
slot-replace
:active="value === opt.value"
@click.capture="__singleSelect(opt.value, opt.disable)"
Expand Down Expand Up @@ -179,7 +182,7 @@ export default {
optModel () {
if (this.multiple) {
return this.value.length > 0
? this.options.map(opt => this.value.includes(opt.value))
? this.options.map(opt => !opt.disable && this.value.includes(opt.value))
: this.options.map(opt => false)
}
},
Expand Down
5 changes: 3 additions & 2 deletions src/mixins/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default {
return this.displayValue
}
if (!this.multiple) {
const opt = this.options.find(opt => opt.value === this.value)
const opt = this.options.find(opt => (!opt.disable && opt.value === this.value))
return opt ? opt.label : ''
}

Expand All @@ -48,7 +48,7 @@ export default {
selectedOptions () {
if (this.multiple) {
return this.length > 0
? this.options.filter(opt => this.value.includes(opt.value))
? this.options.filter(opt => (!opt.disable && this.value.includes(opt.value)))
: []
}
},
Expand Down Expand Up @@ -80,6 +80,7 @@ export default {
model.push(value)
}

this.$emit('input', model)
this.$emit('change', model)
},
__emit (val) {
Expand Down

0 comments on commit 4bd1cb7

Please sign in to comment.