1
mirror of https://github.com/home-assistant/frontend synced 2024-10-05 22:05:30 +02:00

ha-form-integer to only show slider if < 256 steps (#10430)

This commit is contained in:
Paulus Schoutsen 2021-10-28 04:44:25 -07:00 committed by GitHub
parent 8b5b21ae69
commit 4b44e197ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -222,6 +222,30 @@ const SCHEMAS: {
},
],
},
{
title: "OctoPrint",
translations: {
username: "Username",
host: "Host",
port: "Port Number",
path: "Application Path",
ssl: "Use SSL",
},
schema: [
{ type: "string", name: "username", required: true, default: "" },
{ type: "string", name: "host", required: true, default: "" },
{
type: "integer",
valueMin: 1,
valueMax: 65535,
name: "port",
optional: true,
default: 80,
},
{ type: "string", name: "path", optional: true, default: "/" },
{ type: "boolean", name: "ssl", optional: true, default: false },
],
},
];
@customElement("demo-ha-form")

View File

@ -36,7 +36,11 @@ export class HaFormInteger extends LitElement implements HaFormElement {
}
protected render(): TemplateResult {
if ("valueMin" in this.schema && "valueMax" in this.schema) {
if (
this.schema.valueMin !== undefined &&
this.schema.valueMax !== undefined &&
this.schema.valueMax - this.schema.valueMin < 256
) {
return html`
<div>
${this.label}