Implement search in application credentials table (#21219)

Implement search functions
This commit is contained in:
Simon Lamon 2024-06-28 21:10:24 +02:00 committed by GitHub
parent 18a6f8d64d
commit 9beb4c39ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -68,6 +68,14 @@ export class HaConfigApplicationCredentials extends LitElement {
}) })
private _activeHiddenColumns?: string[]; private _activeHiddenColumns?: string[];
@storage({
storage: "sessionStorage",
key: "application-credentials-table-search",
state: true,
subscribe: false,
})
private _filter = "";
private _columns = memoizeOne( private _columns = memoizeOne(
(narrow: boolean, localize: LocalizeFunc): DataTableColumnContainer => { (narrow: boolean, localize: LocalizeFunc): DataTableColumnContainer => {
const columns: DataTableColumnContainer<ApplicationCredential> = { const columns: DataTableColumnContainer<ApplicationCredential> = {
@ -76,6 +84,7 @@ export class HaConfigApplicationCredentials extends LitElement {
"ui.panel.config.application_credentials.picker.headers.name" "ui.panel.config.application_credentials.picker.headers.name"
), ),
sortable: true, sortable: true,
filterable: true,
direction: "asc", direction: "asc",
grows: true, grows: true,
}, },
@ -83,6 +92,7 @@ export class HaConfigApplicationCredentials extends LitElement {
title: localize( title: localize(
"ui.panel.config.application_credentials.picker.headers.client_id" "ui.panel.config.application_credentials.picker.headers.client_id"
), ),
filterable: true,
width: "30%", width: "30%",
hidden: narrow, hidden: narrow,
}, },
@ -91,6 +101,7 @@ export class HaConfigApplicationCredentials extends LitElement {
"ui.panel.config.application_credentials.picker.headers.application" "ui.panel.config.application_credentials.picker.headers.application"
), ),
sortable: true, sortable: true,
filterable: true,
width: "30%", width: "30%",
direction: "asc", direction: "asc",
}, },
@ -156,6 +167,8 @@ export class HaConfigApplicationCredentials extends LitElement {
.hiddenColumns=${this._activeHiddenColumns} .hiddenColumns=${this._activeHiddenColumns}
@columns-changed=${this._handleColumnsChanged} @columns-changed=${this._handleColumnsChanged}
@sorting-changed=${this._handleSortingChanged} @sorting-changed=${this._handleSortingChanged}
.filter=${this._filter}
@search-changed=${this._handleSearchChange}
> >
<div class="header-btns" slot="selection-bar"> <div class="header-btns" slot="selection-bar">
${!this.narrow ${!this.narrow
@ -290,6 +303,10 @@ export class HaConfigApplicationCredentials extends LitElement {
this._activeHiddenColumns = ev.detail.hiddenColumns; this._activeHiddenColumns = ev.detail.hiddenColumns;
} }
private _handleSearchChange(ev: CustomEvent) {
this._filter = ev.detail.value;
}
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {
return css` return css`
.table-header { .table-header {