1
- import { mdiFilterVariant } from "@mdi/js" ;
1
+ import { mdiFilterVariant , mdiPlus } from "@mdi/js" ;
2
2
import type { TemplateResult } from "lit" ;
3
3
import { LitElement , html , css , nothing } from "lit" ;
4
4
import { customElement , property , state } from "lit/decorators" ;
5
5
6
6
import memoize from "memoize-one" ;
7
7
8
8
import type { HASSDomEvent } from "@ha/common/dom/fire_event" ;
9
+ import { navigate } from "@ha/common/navigate" ;
9
10
import "@ha/layouts/hass-loading-screen" ;
10
11
import "@ha/layouts/hass-tabs-subpage" ;
11
12
import type { PageNavigation } from "@ha/layouts/hass-tabs-subpage" ;
@@ -14,8 +15,8 @@ import "@ha/components/ha-icon-button";
14
15
import "@ha/components/ha-icon-overflow-menu" ;
15
16
import "@ha/components/data-table/ha-data-table" ;
16
17
import type { DataTableColumnContainer } from "@ha/components/data-table/ha-data-table" ;
18
+ import type { IconOverflowMenuItem } from "@ha/components/ha-icon-overflow-menu" ;
17
19
import { relativeTime } from "@ha/common/datetime/relative_time" ;
18
- import { navigate } from "@ha/common/navigate" ;
19
20
20
21
import "../components/knx-project-tree-view" ;
21
22
@@ -104,6 +105,7 @@ export class KNXProjectView extends LitElement {
104
105
private _columns = memoize ( ( _narrow , _language ) : DataTableColumnContainer < GroupAddress > => {
105
106
const addressWidth = "100px" ;
106
107
const dptWidth = "82px" ;
108
+ const overflowMenuWidth = "72px" ;
107
109
108
110
return {
109
111
address : {
@@ -159,9 +161,36 @@ export class KNXProjectView extends LitElement {
159
161
</ div> ` ;
160
162
} ,
161
163
} ,
164
+ actions : {
165
+ title : "" ,
166
+ minWidth : overflowMenuWidth ,
167
+ type : "overflow-menu" ,
168
+ template : ( ga : GroupAddress ) => this . _groupAddressMenu ( ga ) ,
169
+ } ,
162
170
} ;
163
171
} ) ;
164
172
173
+ private _groupAddressMenu ( groupAddress : GroupAddress ) : TemplateResult | typeof nothing {
174
+ const items : IconOverflowMenuItem [ ] = [ ] ;
175
+ if ( groupAddress . dpt ?. main === 1 ) {
176
+ items . push ( {
177
+ path : mdiPlus ,
178
+ label : "Create binary sensor" ,
179
+ action : ( ) => {
180
+ navigate (
181
+ "/knx/entities/create/binary_sensor?knx.ga_sensor.state=" + groupAddress . address ,
182
+ ) ;
183
+ } ,
184
+ } ) ;
185
+ }
186
+
187
+ return items . length
188
+ ? html `
189
+ <ha- icon- overflow- menu .hass = ${ this . hass } narrow .items = ${ items } > </ ha- icon- overflow- menu>
190
+ `
191
+ : nothing ;
192
+ }
193
+
165
194
private _getRows ( visibleGroupAddresses : string [ ] ) : GroupAddress [ ] {
166
195
if ( ! visibleGroupAddresses . length )
167
196
// if none is set, default to show all
0 commit comments