Skip to content

Commit

Permalink
fix(ui): show custom values in select too
Browse files Browse the repository at this point in the history
Fixes #844
  • Loading branch information
robertsLando committed Mar 9, 2021
1 parent 42b2826 commit b4485c9
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/components/ValueId.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<div v-if="!value.writeable">
<v-text-field
readonly
class="no-border"
:suffix="value.unit"
:hint="help"
persistent-hint
Expand Down Expand Up @@ -106,7 +107,7 @@

<v-select
v-if="value.list && !value.allowManualEntry"
:items="value.states"
:items="items"
:style="{
'max-width': $vuetify.breakpoint.smAndDown
? '280px'
Expand All @@ -122,11 +123,17 @@
:append-outer-icon="!disable_send ? 'send' : null"
v-model="value.newValue"
@click:append-outer="updateValue(value)"
></v-select>
>
<template v-slot:selection="{ item }">
<span>
{{ itemText(selectedItem || item) }}
</span>
</template>
</v-select>

<v-combobox
v-if="value.list && value.allowManualEntry"
:items="value.states"
:items="items"
:style="{
'max-width': $vuetify.breakpoint.smAndDown
? '280px'
Expand Down Expand Up @@ -213,6 +220,12 @@
}
</style>

<style>
.no-border > .v-input__control > .v-input__slot:before {
content: none;
}
</style>

<script>
export default {
props: {
Expand All @@ -239,6 +252,16 @@ export default {
if (!this.value.states) return null
else return this.value.states.find(s => s.value === value)
},
items () {
if (this.selectedItem) {
return this.value.states
} else {
return [
{ value: this.value.newValue, text: 'Custom' },
...this.value.states
]
}
},
label () {
return '[' + this.value.id + '] ' + this.value.label
},
Expand Down

0 comments on commit b4485c9

Please sign in to comment.