Optional options in UI property control become dropdown
This commit is contained in:
parent
89c5ea6886
commit
ae81520494
4 changed files with 37 additions and 0 deletions
|
|
@ -83,6 +83,13 @@ class PropertyControl(BaseModel):
|
||||||
read_back_delay: int = 1000
|
read_back_delay: int = 1000
|
||||||
"""The delay in ms before reading back the property."""
|
"""The delay in ms before reading back the property."""
|
||||||
|
|
||||||
|
options: list[str] = []
|
||||||
|
"""A list of options to pass to the UI for a dropdown.
|
||||||
|
|
||||||
|
These options aren't validated in the UI in any way, and invalid
|
||||||
|
settings will only be rejected when selected.
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
def property_control_for(
|
def property_control_for(
|
||||||
thing: lt.Thing, property_name: str, **kwargs: Any
|
thing: lt.Thing, property_name: str, **kwargs: Any
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,20 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<label v-if="dataType === 'dropdown'" class="uk-form-label">
|
||||||
|
{{ label }}
|
||||||
|
<div class="input-and-buttons-container">
|
||||||
|
<select
|
||||||
|
v-model="internalValue"
|
||||||
|
class="uk-form-small numeric-setting-line-input"
|
||||||
|
@change="sendValue"
|
||||||
|
>
|
||||||
|
<option v-for="(opt, idx) in options" :key="idx" :value="opt">
|
||||||
|
{{ opt }}
|
||||||
|
</option>
|
||||||
|
</select>
|
||||||
|
<sync-property-button @click="requestUpdate" />
|
||||||
|
</div>
|
||||||
|
</label>
|
||||||
<label v-if="dataType == 'number'" class="uk-form-label"
|
<label v-if="dataType == 'number'" class="uk-form-label"
|
||||||
>{{ label }}
|
>{{ label }}
|
||||||
<div class="input-and-buttons-container">
|
<div class="input-and-buttons-container">
|
||||||
|
|
@ -128,6 +143,11 @@ export default {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
|
options: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: ["requestUpdate", "sendValue", "animationShown"],
|
emits: ["requestUpdate", "sendValue", "animationShown"],
|
||||||
|
|
@ -182,6 +202,9 @@ export default {
|
||||||
return "undefined";
|
return "undefined";
|
||||||
}
|
}
|
||||||
const num_types = ["integer", "float", "number"];
|
const num_types = ["integer", "float", "number"];
|
||||||
|
if (this.options && this.options.length > 1) {
|
||||||
|
return "dropdown";
|
||||||
|
}
|
||||||
if (num_types.includes(prop.type)) {
|
if (num_types.includes(prop.type)) {
|
||||||
return "number";
|
return "number";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
:data-schema="propertyDescription"
|
:data-schema="propertyDescription"
|
||||||
:label="label"
|
:label="label"
|
||||||
:animate="animate"
|
:animate="animate"
|
||||||
|
:options="options"
|
||||||
@request-update="readProperty"
|
@request-update="readProperty"
|
||||||
@send-value="writeProperty"
|
@send-value="writeProperty"
|
||||||
@animation-shown="resetAnimate"
|
@animation-shown="resetAnimate"
|
||||||
|
|
@ -44,6 +45,11 @@ export default {
|
||||||
default: 1000,
|
default: 1000,
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
|
options: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
:label="propertyData.label"
|
:label="propertyData.label"
|
||||||
:read-back="propertyData.read_back"
|
:read-back="propertyData.read_back"
|
||||||
:read-back-delay="propertyData.read_back_delay"
|
:read-back-delay="propertyData.read_back_delay"
|
||||||
|
:options="propertyData.options"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue