Use localize func in table settings dialog (#21335)

This commit is contained in:
Bram Kragten 2024-07-08 17:41:59 +02:00 committed by GitHub
parent e7a749ef7d
commit c85e29f2bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 5 deletions

View File

@ -78,6 +78,8 @@ export class DialogDataTableSettings extends LitElement {
return nothing; return nothing;
} }
const localize = this._params.localizeFunc || this.hass.localize;
const columns = this._sortedColumns( const columns = this._sortedColumns(
this._params.columns, this._params.columns,
this._columnOrder, this._columnOrder,
@ -90,7 +92,7 @@ export class DialogDataTableSettings extends LitElement {
@closed=${this.closeDialog} @closed=${this.closeDialog}
.heading=${createCloseHeading( .heading=${createCloseHeading(
this.hass, this.hass,
this.hass.localize("ui.components.data-table.settings.header") localize("ui.components.data-table.settings.header")
)} )}
> >
<ha-sortable <ha-sortable
@ -146,12 +148,10 @@ export class DialogDataTableSettings extends LitElement {
</mwc-list> </mwc-list>
</ha-sortable> </ha-sortable>
<ha-button slot="secondaryAction" @click=${this._reset} <ha-button slot="secondaryAction" @click=${this._reset}
>${this.hass.localize( >${localize("ui.components.data-table.settings.restore")}</ha-button
"ui.components.data-table.settings.restore"
)}</ha-button
> >
<ha-button slot="primaryAction" @click=${this.closeDialog}> <ha-button slot="primaryAction" @click=${this.closeDialog}>
${this.hass.localize("ui.components.data-table.settings.done")} ${localize("ui.components.data-table.settings.done")}
</ha-button> </ha-button>
</ha-dialog> </ha-dialog>
`; `;

View File

@ -1,4 +1,5 @@
import { fireEvent } from "../../common/dom/fire_event"; import { fireEvent } from "../../common/dom/fire_event";
import { LocalizeFunc } from "../../common/translations/localize";
import { DataTableColumnContainer } from "./ha-data-table"; import { DataTableColumnContainer } from "./ha-data-table";
export interface DataTableSettingsDialogParams { export interface DataTableSettingsDialogParams {
@ -9,6 +10,7 @@ export interface DataTableSettingsDialogParams {
) => void; ) => void;
hiddenColumns?: string[]; hiddenColumns?: string[];
columnOrder?: string[]; columnOrder?: string[];
localizeFunc?: LocalizeFunc;
} }
export const loadDataTableSettingsDialog = () => export const loadDataTableSettingsDialog = () =>

View File

@ -638,6 +638,7 @@ export class HaTabsSubpageDataTable extends LitElement {
this.hiddenColumns = hiddenColumns; this.hiddenColumns = hiddenColumns;
fireEvent(this, "columns-changed", { columnOrder, hiddenColumns }); fireEvent(this, "columns-changed", { columnOrder, hiddenColumns });
}, },
localizeFunc: this.localizeFunc,
}); });
} }