mirror of
https://github.com/GeorgeSG/lovelace-time-picker-card.git
synced 2026-09-07 10:48:44 +00:00
Add seconds config to visual editor
This commit is contained in:
+29
-2
@@ -15,12 +15,18 @@ import {
|
|||||||
ENTITY_DOMAIN,
|
ENTITY_DOMAIN,
|
||||||
DEFAULT_LAYOUT_ALIGN_CONTROLS,
|
DEFAULT_LAYOUT_ALIGN_CONTROLS,
|
||||||
DEFAULT_LAYOUT_NAME,
|
DEFAULT_LAYOUT_NAME,
|
||||||
|
DEFAULT_SECOND_STEP,
|
||||||
} from './const';
|
} from './const';
|
||||||
import { TimePickerCardConfig, Layout, HourMode } from './types';
|
import { TimePickerCardConfig, Layout, HourMode } from './types';
|
||||||
|
|
||||||
@customElement('time-picker-card-editor')
|
@customElement('time-picker-card-editor')
|
||||||
export class TimePickerCardEditor extends LitElement implements LovelaceCardEditor {
|
export class TimePickerCardEditor extends LitElement implements LovelaceCardEditor {
|
||||||
private static readonly NUMBER_PROPERTIES = ['hour_step', 'minute_step', 'hour_mode'];
|
private static readonly NUMBER_PROPERTIES = [
|
||||||
|
'hour_step',
|
||||||
|
'minute_step',
|
||||||
|
'second_step',
|
||||||
|
'hour_mode',
|
||||||
|
];
|
||||||
private static readonly CONFIG_CHANGED_EVENT = 'config-changed';
|
private static readonly CONFIG_CHANGED_EVENT = 'config-changed';
|
||||||
|
|
||||||
@property({ type: Object }) hass!: HomeAssistant;
|
@property({ type: Object }) hass!: HomeAssistant;
|
||||||
@@ -65,7 +71,6 @@ export class TimePickerCardEditor extends LitElement implements LovelaceCardEdit
|
|||||||
<ha-switch
|
<ha-switch
|
||||||
style="margin-left: 10px"
|
style="margin-left: 10px"
|
||||||
.checked="${!Boolean(this.config.hide?.name)}"
|
.checked="${!Boolean(this.config.hide?.name)}"
|
||||||
.configValue="${'hide_name'}"
|
|
||||||
@change="${this.onHideNameChange}"
|
@change="${this.onHideNameChange}"
|
||||||
></ha-switch>
|
></ha-switch>
|
||||||
Show name?
|
Show name?
|
||||||
@@ -101,6 +106,23 @@ export class TimePickerCardEditor extends LitElement implements LovelaceCardEdit
|
|||||||
@value-changed=${this.onValueChange}
|
@value-changed=${this.onValueChange}
|
||||||
></paper-input>
|
></paper-input>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="side-by-side">
|
||||||
|
<div>
|
||||||
|
<ha-switch
|
||||||
|
style="margin-left: 10px"
|
||||||
|
.checked="${this.config.hide?.seconds === false}"
|
||||||
|
@change="${this.onHideSecondsChange}"
|
||||||
|
></ha-switch>
|
||||||
|
Show seconds?
|
||||||
|
</div>
|
||||||
|
<paper-input
|
||||||
|
type="number"
|
||||||
|
label="Second Step (Optional)"
|
||||||
|
.configValue=${'second_step'}
|
||||||
|
.value=${this.config.second_step || DEFAULT_SECOND_STEP}
|
||||||
|
@value-changed=${this.onValueChange}
|
||||||
|
></paper-input>
|
||||||
|
</div>
|
||||||
<div class="side-by-side">
|
<div class="side-by-side">
|
||||||
<div>
|
<div>
|
||||||
<ha-switch
|
<ha-switch
|
||||||
@@ -164,6 +186,11 @@ export class TimePickerCardEditor extends LitElement implements LovelaceCardEdit
|
|||||||
this.dispatch(newConfig);
|
this.dispatch(newConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private onHideSecondsChange({ target: { checked } }): void {
|
||||||
|
const newConfig = { ...this.config, hide: { seconds: !checked } };
|
||||||
|
this.dispatch(newConfig);
|
||||||
|
}
|
||||||
|
|
||||||
private onLayoutAlignChange({ detail: { value } }: CustomEvent): void {
|
private onLayoutAlignChange({ detail: { value } }: CustomEvent): void {
|
||||||
const layout = { ...this.config.layout, align_controls: value };
|
const layout = { ...this.config.layout, align_controls: value };
|
||||||
const newConfig = { ...this.config, layout };
|
const newConfig = { ...this.config, layout };
|
||||||
|
|||||||
Reference in New Issue
Block a user