From 4b44e197aec57b1e35bc6b4072cbddc5c2e091eb Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 28 Oct 2021 04:44:25 -0700 Subject: [PATCH] ha-form-integer to only show slider if < 256 steps (#10430) --- gallery/src/demos/demo-ha-form.ts | 24 +++++++++++++++++++++++ src/components/ha-form/ha-form-integer.ts | 6 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gallery/src/demos/demo-ha-form.ts b/gallery/src/demos/demo-ha-form.ts index abc2cca571..69933af074 100644 --- a/gallery/src/demos/demo-ha-form.ts +++ b/gallery/src/demos/demo-ha-form.ts @@ -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") diff --git a/src/components/ha-form/ha-form-integer.ts b/src/components/ha-form/ha-form-integer.ts index c8668b25de..2d278fb79f 100644 --- a/src/components/ha-form/ha-form-integer.ts +++ b/src/components/ha-form/ha-form-integer.ts @@ -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`
${this.label}