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

fix(ui): allow manual entry on config values with states #781

Merged
merged 2 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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