Options for server specified property control allow different values and display names
This commit is contained in:
parent
5ae0f903d8
commit
88c087b8dd
3 changed files with 21 additions and 10 deletions
|
|
@ -83,11 +83,11 @@ 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: Optional[list[str]] = None
|
options: Optional[dict[str, str | int | float | bool]] = None
|
||||||
"""A list of options to pass to the UI for a dropdown.
|
"""A mapping of UI display name to value use for creating a dropdown.
|
||||||
|
|
||||||
These options aren't validated in the UI in any way, and invalid
|
These options aren't validated here in any way. Any invalid values will be rejected
|
||||||
settings will only be rejected when selected.
|
when selected.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,11 @@
|
||||||
<div class="input-and-buttons-container">
|
<div class="input-and-buttons-container">
|
||||||
<select
|
<select
|
||||||
v-model="internalValue"
|
v-model="internalValue"
|
||||||
class="uk-form-small numeric-setting-line-input"
|
class="uk-form-small numeric-setting-line-input dropdown"
|
||||||
@change="sendValue"
|
@change="sendValue"
|
||||||
>
|
>
|
||||||
<option v-for="(opt, idx) in options" :key="idx" :value="opt">
|
<option v-for="(value, display) in options" :key="value" :value="value">
|
||||||
{{ opt }}
|
{{ display }}
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<sync-property-button @click="requestUpdate" />
|
<sync-property-button @click="requestUpdate" />
|
||||||
|
|
@ -145,7 +145,8 @@ export default {
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: undefined,
|
// Default is Null as None is passed from the server.
|
||||||
|
default: null,
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -197,7 +198,12 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
useDropdown: function () {
|
useDropdown: function () {
|
||||||
return Array.isArray(this.options) && this.options.length > 1;
|
if (this.options === null) return false;
|
||||||
|
if (["number", "string", "boolean"].includes(this.dataType)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
console.warn(`Cannot support dropdown for datatype of ${this.dataType}`);
|
||||||
|
return false;
|
||||||
},
|
},
|
||||||
dataType: function () {
|
dataType: function () {
|
||||||
let prop = this.dataSchema;
|
let prop = this.dataSchema;
|
||||||
|
|
@ -351,6 +357,11 @@ export default {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
width: 6em;
|
width: 6em;
|
||||||
}
|
}
|
||||||
|
.dropdown {
|
||||||
|
background-color: #fff;
|
||||||
|
border: 1px solid #ccc;
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
.edited {
|
.edited {
|
||||||
background-color: #fff3cd;
|
background-color: #fff3cd;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ export default {
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
type: Array,
|
type: Object,
|
||||||
default: undefined,
|
default: undefined,
|
||||||
required: false,
|
required: false,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue