From c133f16371f1f3b9d9f76d9fc0f331ad19dd8636 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sat, 10 Apr 2021 20:13:11 +0200 Subject: [PATCH] web/elements: move table search to table Signed-off-by: Jens Langhammer --- web/src/elements/forms/Form.ts | 3 ++- .../elements/forms/HorizontalFormElement.ts | 1 + web/src/elements/table/Table.ts | 18 ++++++++++++++++++ web/src/elements/table/TablePage.ts | 13 ------------- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/web/src/elements/forms/Form.ts b/web/src/elements/forms/Form.ts index c58422bb0..57297f1f5 100644 --- a/web/src/elements/forms/Form.ts +++ b/web/src/elements/forms/Form.ts @@ -10,6 +10,7 @@ import AKGlobal from "../../authentik.css"; import PFForm from "@patternfly/patternfly/components/Form/form.css"; import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css"; import PFAlert from "@patternfly/patternfly/components/Alert/alert.css"; +import PFInputGroup from "@patternfly/patternfly/components/InputGroup/input-group.css"; import { MessageLevel } from "../messages/Message"; import { IronFormElement } from "@polymer/iron-form/iron-form"; import { camelToSnake, convertToSlug } from "../../utils"; @@ -36,7 +37,7 @@ export class Form extends LitElement { nonFieldErrors?: string[]; static get styles(): CSSResult[] { - return [PFBase, PFCard, PFButton, PFForm, PFAlert, PFFormControl, AKGlobal, css` + return [PFBase, PFCard, PFButton, PFForm, PFAlert, PFInputGroup, PFFormControl, AKGlobal, css` select[multiple] { height: 15em; } diff --git a/web/src/elements/forms/HorizontalFormElement.ts b/web/src/elements/forms/HorizontalFormElement.ts index ef3af1d0e..d7242f540 100644 --- a/web/src/elements/forms/HorizontalFormElement.ts +++ b/web/src/elements/forms/HorizontalFormElement.ts @@ -52,6 +52,7 @@ export class HorizontalFormElement extends LitElement { case "textarea": case "select": case "ak-codemirror": + case "ak-chip-group": (input as HTMLInputElement).name = this.name; break; default: diff --git a/web/src/elements/table/Table.ts b/web/src/elements/table/Table.ts index 89761e78c..44a5e78b4 100644 --- a/web/src/elements/table/Table.ts +++ b/web/src/elements/table/Table.ts @@ -12,10 +12,12 @@ import PFPagination from "@patternfly/patternfly/components/Pagination/paginatio import AKGlobal from "../../authentik.css"; import "./TablePagination"; +import "./TableSearch"; import "../EmptyState"; import "../chips/Chip"; import "../chips/ChipGroup"; import { EVENT_REFRESH } from "../../constants"; +import { ifDefined } from "lit-html/directives/if-defined"; export class TableColumn { @@ -85,6 +87,10 @@ export abstract class Table extends LitElement { private isLoading = false; + searchEnabled(): boolean { + return false; + } + // eslint-disable-next-line @typescript-eslint/no-unused-vars renderExpanded(item: T): TemplateResult { if (this.expandable) { @@ -194,6 +200,7 @@ export abstract class Table extends LitElement { if (index <= -1) return; this.selectedElements.splice(index, 1); } + this.requestUpdate(); }} /> ` : html``} ${this.expandable ? html` @@ -229,6 +236,17 @@ export abstract class Table extends LitElement { } renderSearch(): TemplateResult { + if (!this.searchEnabled()) { + return html``; + } + return html` { + this.search = value; + this.fetch(); + }}> +  `; + } + + renderSelectedChip(item: T): TemplateResult { return html``; } diff --git a/web/src/elements/table/TablePage.ts b/web/src/elements/table/TablePage.ts index 02885b5bb..15813b766 100644 --- a/web/src/elements/table/TablePage.ts +++ b/web/src/elements/table/TablePage.ts @@ -2,7 +2,6 @@ import { CSSResult } from "lit-element"; import { html, TemplateResult } from "lit-html"; import { ifDefined } from "lit-html/directives/if-defined"; import { Table } from "./Table"; -import "./TableSearch"; import "../../elements/PageHeader"; import PFPage from "@patternfly/patternfly/components/Page/page.css"; import PFContent from "@patternfly/patternfly/components/Content/content.css"; @@ -11,23 +10,11 @@ export abstract class TablePage extends Table { abstract pageTitle(): string; abstract pageDescription(): string | undefined; abstract pageIcon(): string; - abstract searchEnabled(): boolean; static get styles(): CSSResult[] { return super.styles.concat(PFPage, PFContent); } - renderSearch(): TemplateResult { - if (!this.searchEnabled()) { - return super.renderSearch(); - } - return html` { - this.search = value; - this.fetch(); - }}> -  `; - } - render(): TemplateResult { return html`