mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-21 00:06:35 +00:00
Little clean up in data table (#7352)
This commit is contained in:
parent
c1dba462e8
commit
ce07dfd8ac
@ -329,7 +329,7 @@ export class HaDataTable extends LitElement {
|
|||||||
<div
|
<div
|
||||||
aria-rowindex=${index}
|
aria-rowindex=${index}
|
||||||
role="row"
|
role="row"
|
||||||
.rowId="${row[this.id]}"
|
.rowId=${row[this.id]}
|
||||||
@click=${this._handleRowClick}
|
@click=${this._handleRowClick}
|
||||||
class="mdc-data-table__row ${classMap({
|
class="mdc-data-table__row ${classMap({
|
||||||
"mdc-data-table__row--selected": this._checkedRows.includes(
|
"mdc-data-table__row--selected": this._checkedRows.includes(
|
||||||
@ -353,6 +353,7 @@ export class HaDataTable extends LitElement {
|
|||||||
<ha-checkbox
|
<ha-checkbox
|
||||||
class="mdc-data-table__row-checkbox"
|
class="mdc-data-table__row-checkbox"
|
||||||
@change=${this._handleRowCheckboxClick}
|
@change=${this._handleRowCheckboxClick}
|
||||||
|
.rowId=${row[this.id]}
|
||||||
.disabled=${row.selectable === false}
|
.disabled=${row.selectable === false}
|
||||||
.checked=${this._checkedRows.includes(
|
.checked=${this._checkedRows.includes(
|
||||||
String(row[this.id])
|
String(row[this.id])
|
||||||
@ -460,9 +461,7 @@ export class HaDataTable extends LitElement {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private _handleHeaderClick(ev: Event) {
|
private _handleHeaderClick(ev: Event) {
|
||||||
const columnId = ((ev.target as HTMLElement).closest(
|
const columnId = (ev.currentTarget as any).columnId;
|
||||||
".mdc-data-table__header-cell"
|
|
||||||
) as any).columnId;
|
|
||||||
if (!this.columns[columnId].sortable) {
|
if (!this.columns[columnId].sortable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -496,8 +495,8 @@ export class HaDataTable extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _handleRowCheckboxClick(ev: Event) {
|
private _handleRowCheckboxClick(ev: Event) {
|
||||||
const checkbox = ev.target as HaCheckbox;
|
const checkbox = ev.currentTarget as HaCheckbox;
|
||||||
const rowId = (checkbox.closest(".mdc-data-table__row") as any).rowId;
|
const rowId = (checkbox as any).rowId;
|
||||||
|
|
||||||
if (checkbox.checked) {
|
if (checkbox.checked) {
|
||||||
if (this._checkedRows.includes(rowId)) {
|
if (this._checkedRows.includes(rowId)) {
|
||||||
@ -515,7 +514,7 @@ export class HaDataTable extends LitElement {
|
|||||||
if (target.tagName === "HA-CHECKBOX") {
|
if (target.tagName === "HA-CHECKBOX") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const rowId = (target.closest(".mdc-data-table__row") as any).rowId;
|
const rowId = (ev.currentTarget as any).rowId;
|
||||||
fireEvent(this, "row-click", { id: rowId }, { bubbles: false });
|
fireEvent(this, "row-click", { id: rowId }, { bubbles: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user