@@ -3,6 +3,11 @@ import { html, LitElement, nothing } from "lit";
33import { customElement , property , state } from "lit/decorators" ;
44import memoizeOne from "memoize-one" ;
55import { assert , assign , boolean , object , optional , string } from "superstruct" ;
6+ import { mdiGestureTap } from "@mdi/js" ;
7+ import {
8+ ITEM_TAP_ACTION_EDIT ,
9+ ITEM_TAP_ACTION_TOGGLE ,
10+ } from "../../cards/hui-todo-list-card" ;
611import { isComponentLoaded } from "../../../../common/config/is_component_loaded" ;
712import { fireEvent } from "../../../../common/dom/fire_event" ;
813import "../../../../components/ha-alert" ;
@@ -17,6 +22,8 @@ import { configElementStyle } from "./config-elements-style";
1722import { TodoListEntityFeature , TodoSortMode } from "../../../../data/todo" ;
1823import { supportsFeature } from "../../../../common/entity/supports-feature" ;
1924
25+ const ITEM_TAP_ACTIONS = [ ITEM_TAP_ACTION_EDIT , ITEM_TAP_ACTION_TOGGLE ] ;
26+
2027const cardConfigStruct = assign (
2128 baseLovelaceCardConfig ,
2229 object ( {
@@ -26,6 +33,7 @@ const cardConfigStruct = assign(
2633 hide_completed : optional ( boolean ( ) ) ,
2734 hide_create : optional ( boolean ( ) ) ,
2835 display_order : optional ( string ( ) ) ,
36+ item_tap_action : optional ( string ( ) ) ,
2937 } )
3038) ;
3139
@@ -64,11 +72,35 @@ export class HuiTodoListEditor
6472 } ,
6573 } ,
6674 } ,
75+ {
76+ name : "interactions" ,
77+ type : "expandable" ,
78+ flatten : true ,
79+ iconPath : mdiGestureTap ,
80+ schema : [
81+ {
82+ name : "item_tap_action" ,
83+ required : true ,
84+ selector : {
85+ select : {
86+ mode : "dropdown" ,
87+ options : Object . values ( ITEM_TAP_ACTIONS ) . map ( ( action ) => ( {
88+ value : action ,
89+ label : localize (
90+ `ui.panel.lovelace.editor.card.todo-list.actions.${ action } `
91+ ) ,
92+ } ) ) ,
93+ } ,
94+ } ,
95+ } ,
96+ ] ,
97+ } ,
6798 ] as const
6899 ) ;
69100
70101 private _data = memoizeOne ( ( config ) => ( {
71102 display_order : "none" ,
103+ item_tap_action : "edit" ,
72104 ...config ,
73105 } ) ) ;
74106
@@ -106,7 +138,10 @@ export class HuiTodoListEditor
106138 }
107139
108140 private _valueChanged ( ev : CustomEvent ) : void {
109- const config = ev . detail . value ;
141+ const config = { ...ev . detail . value } ;
142+ if ( config . item_tap_action === ITEM_TAP_ACTION_EDIT ) {
143+ delete config . item_tap_action ;
144+ }
110145 fireEvent ( this , "config-changed" , { config } ) ;
111146 }
112147
@@ -130,6 +165,7 @@ export class HuiTodoListEditor
130165 case "hide_completed" :
131166 case "hide_create" :
132167 case "display_order" :
168+ case "item_tap_action" :
133169 return this . hass ! . localize (
134170 `ui.panel.lovelace.editor.card.todo-list.${ schema . name } `
135171 ) ;
0 commit comments