Skip to content

Commit

Permalink
fix(ui): allow manual entry on config values with states (#781)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertsLando authored Mar 1, 2021
1 parent ea960db commit a45f763
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/ZwaveClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@ function updateValueMetadata (zwaveNode, zwaveValue, zwaveValueMeta) {

if (zwaveValueMeta.states) {
valueId.list = true
valueId.allowManualEntry = zwaveValueMeta.allowManualEntry
valueId.states = []
for (const k in zwaveValueMeta.states) {
valueId.states.push({
Expand Down
35 changes: 34 additions & 1 deletion src/components/ValueId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
</v-text-field>

<v-select
v-if="value.list"
v-if="value.list && !value.allowManualEntry"
:items="items"
:style="{
'max-width': $vuetify.breakpoint.smAndDown
Expand All @@ -120,6 +120,35 @@
@click:append-outer="updateValue(value)"
></v-select>

<v-combobox
v-if="value.list && value.allowManualEntry"
:items="items"
:style="{
'max-width': $vuetify.breakpoint.smAndDown
? '280px'
: $vuetify.breakpoint.smOnly
? '400px'
: 'auto'
}"
:hint="help"
persistent-hint
chips
item-text="text"
item-value="value"
:append-outer-icon="!disable_send || value.writeable ? 'send' : null"
v-model="value.newValue"
:readonly="!value.writeable"
@click:append-outer="updateValue(value)"
>
<template v-slot:selection="{ attrs, item, selected }">
<v-chip v-bind="attrs" :input-value="selected">
<span>
{{ selectedItem ? selectedItem.text : 'Custom: ' + item }}
</span>
</v-chip>
</template>
</v-combobox>

<div v-if="value.type == 'boolean' && value.writeable && value.readable">
<v-btn-toggle class="mt-4" v-model="value.newValue" rounded>
<v-btn
Expand Down Expand Up @@ -196,6 +225,10 @@ export default {
}
},
computed: {
selectedItem () {
if (!this.items) return null
else return this.items.find(v => v.value === this.value.newValue)
},
items () {
const items = this.value.states || []
const defaultValue = this.value.default
Expand Down

0 comments on commit a45f763

Please sign in to comment.