New "clickable" property for <ha-data-table> (#7351)

This commit is contained in:
Philip Allgaier 2020-10-15 15:57:05 +02:00 committed by GitHub
parent ce80285f8d
commit 47f0d74812
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 22 additions and 0 deletions

View File

@ -94,6 +94,8 @@ export class HaDataTable extends LitElement {
@property({ type: Boolean }) public selectable = false; @property({ type: Boolean }) public selectable = false;
@property({ type: Boolean }) public clickable = false;
@property({ type: Boolean }) public hasFab = false; @property({ type: Boolean }) public hasFab = false;
@property({ type: Boolean, attribute: "auto-height" }) @property({ type: Boolean, attribute: "auto-height" })
@ -333,6 +335,7 @@ export class HaDataTable extends LitElement {
"mdc-data-table__row--selected": this._checkedRows.includes( "mdc-data-table__row--selected": this._checkedRows.includes(
String(row[this.id]) String(row[this.id])
), ),
clickable: this.clickable,
})}" })}"
aria-selected=${ifDefined( aria-selected=${ifDefined(
this._checkedRows.includes(String(row[this.id])) this._checkedRows.includes(String(row[this.id]))
@ -886,6 +889,9 @@ export class HaDataTable extends LitElement {
.forceLTR { .forceLTR {
direction: ltr; direction: ltr;
} }
.clickable {
cursor: pointer;
}
`; `;
} }
} }

View File

@ -48,6 +48,12 @@ export class HaTabsSubpageDataTable extends LitElement {
*/ */
@property({ type: Boolean }) public selectable = false; @property({ type: Boolean }) public selectable = false;
/**
* Should rows be clickable.
* @type {Boolean}
*/
@property({ type: Boolean }) public clickable = false;
/** /**
* Do we need to add padding for a fab. * Do we need to add padding for a fab.
* @type {Boolean} * @type {Boolean}
@ -164,6 +170,7 @@ export class HaTabsSubpageDataTable extends LitElement {
.id=${this.id} .id=${this.id}
.noDataText=${this.noDataText} .noDataText=${this.noDataText}
.dir=${computeRTLDirection(this.hass)} .dir=${computeRTLDirection(this.hass)}
.clickable=${this.clickable}
> >
${!this.narrow ${!this.narrow
? html` ? html`

View File

@ -117,6 +117,7 @@ export class HaConfigAreasDashboard extends LitElement {
)} )}
id="area_id" id="area_id"
hasFab hasFab
clickable
> >
<ha-icon-button <ha-icon-button
slot="toolbar-icon" slot="toolbar-icon"

View File

@ -310,6 +310,7 @@ export class HaConfigDeviceDashboard extends LitElement {
this.hass.localize this.hass.localize
)} )}
@row-click=${this._handleRowClicked} @row-click=${this._handleRowClicked}
clickable
> >
</hass-tabs-subpage-data-table> </hass-tabs-subpage-data-table>
`; `;

View File

@ -594,6 +594,7 @@ export class HaConfigEntities extends SubscribeMixin(LitElement) {
.data=${entityData} .data=${entityData}
.filter=${this._filter} .filter=${this._filter}
selectable selectable
clickable
@selection-changed=${this._handleSelectionChanged} @selection-changed=${this._handleSelectionChanged}
@row-click=${this._openEditEntry} @row-click=${this._openEditEntry}
id="entity_id" id="entity_id"

View File

@ -153,6 +153,7 @@ export class HaConfigHelpers extends LitElement {
.data=${this._getItems(this._stateItems)} .data=${this._getItems(this._stateItems)}
@row-click=${this._openEditDialog} @row-click=${this._openEditDialog}
hasFab hasFab
clickable
.noDataText=${this.hass.localize( .noDataText=${this.hass.localize(
"ui.panel.config.helpers.picker.no_helpers" "ui.panel.config.helpers.picker.no_helpers"
)} )}

View File

@ -117,6 +117,7 @@ class OZWNetworkNodes extends LitElement {
.data=${this._nodes} .data=${this._nodes}
id="node_id" id="node_id"
@row-click=${this._handleRowClicked} @row-click=${this._handleRowClicked}
clickable
> >
</hass-tabs-subpage-data-table> </hass-tabs-subpage-data-table>
`; `;

View File

@ -124,6 +124,7 @@ export class ZHAGroupsDashboard extends LitElement {
.columns=${this._columns(this.narrow)} .columns=${this._columns(this.narrow)}
.data=${this._formattedGroups(this._groups)} .data=${this._formattedGroups(this._groups)}
@row-click=${this._handleRowClicked} @row-click=${this._handleRowClicked}
clickable
> >
<a href="/config/zha/group-add" slot="fab"> <a href="/config/zha/group-add" slot="fab">
<mwc-fab <mwc-fab

View File

@ -221,6 +221,7 @@ export class HaConfigLovelaceDashboards extends LitElement {
@row-click=${this._editDashboard} @row-click=${this._editDashboard}
id="url_path" id="url_path"
hasFab hasFab
clickable
> >
<mwc-fab <mwc-fab
slot="fab" slot="fab"

View File

@ -101,6 +101,7 @@ export class HaConfigLovelaceRescources extends LitElement {
)} )}
@row-click=${this._editResource} @row-click=${this._editResource}
hasFab hasFab
clickable
> >
<mwc-fab <mwc-fab
slot="fab" slot="fab"

View File

@ -96,6 +96,7 @@ export class HaConfigUsers extends LitElement {
.data=${this._users} .data=${this._users}
@row-click=${this._editUser} @row-click=${this._editUser}
hasFab hasFab
clickable
> >
<mwc-fab <mwc-fab
slot="fab" slot="fab"