diff --git a/src/views/project_view.ts b/src/views/project_view.ts index bde8c41..7bd2b4d 100644 --- a/src/views/project_view.ts +++ b/src/views/project_view.ts @@ -1,18 +1,16 @@ -import { mdiFilterVariant, mdiPlus } from "@mdi/js"; +import { mdiFilterVariant } from "@mdi/js"; import { LitElement, TemplateResult, html, css, nothing } from "lit"; import { customElement, property, state } from "lit/decorators"; import memoize from "memoize-one"; import { HASSDomEvent } from "@ha/common/dom/fire_event"; -import { navigate } from "@ha/common/navigate"; import "@ha/layouts/hass-loading-screen"; import "@ha/layouts/hass-tabs-subpage"; import type { PageNavigation } from "@ha/layouts/hass-tabs-subpage"; import "@ha/components/ha-card"; import "@ha/components/ha-icon-button"; import "@ha/components/ha-icon-overflow-menu"; -import type { IconOverflowMenuItem } from "@ha/components/ha-icon-overflow-menu"; import "@ha/components/data-table/ha-data-table"; import type { DataTableColumnContainer } from "@ha/components/data-table/ha-data-table"; @@ -70,26 +68,27 @@ export class KNXProjectView extends LitElement { private _columns = memoize((_narrow, _language): DataTableColumnContainer => { const addressWidth = "100px"; const dptWidth = "82px"; - const overflowMenuWidth = "72px"; return { address: { filterable: true, sortable: true, title: this.knx.localize("project_view_table_address"), - width: addressWidth, + flex: 1, + minWidth: addressWidth, }, name: { filterable: true, sortable: true, title: this.knx.localize("project_view_table_name"), - width: `calc(100% - ${dptWidth} - ${addressWidth} - ${overflowMenuWidth})`, + flex: 3, }, dpt: { sortable: true, filterable: true, title: this.knx.localize("project_view_table_dpt"), - width: dptWidth, + flex: 1, + minWidth: dptWidth, template: (ga: GroupAddress) => ga.dpt ? html`${ga.dpt.sub ? "." + ga.dpt.sub.toString().padStart(3, "0") : ""} ` : "", }, - actions: { - title: "", - width: overflowMenuWidth, - type: "overflow-menu", - template: (ga: GroupAddress) => this._groupAddressMenu(ga), - }, }; }); - private _groupAddressMenu(groupAddress: GroupAddress): TemplateResult | typeof nothing { - const items: IconOverflowMenuItem[] = []; - if (groupAddress.dpt?.main === 1) { - items.push({ - path: mdiPlus, - label: this.knx.localize("project_view_add_switch"), - action: () => { - navigate("/knx/entities/create?ga=" + groupAddress.address); - }, - }); - // items.push({ - // path: mdiPlus, - // label: "Add binary sensor", - // action: () => logger.warn(groupAddress.address), - // }); - } - - return items.length - ? html` - - ` - : nothing; - } - private _getRows(visibleGroupAddresses: string[]): GroupAddress[] { if (!visibleGroupAddresses.length) // if none is set, default to show all