web: add TablePage

This commit is contained in:
Jens Langhammer
2020-11-30 23:49:33 +01:00
parent 8e25970c01
commit a312ad2ad1
9 changed files with 90 additions and 11 deletions

View File

@ -6,7 +6,7 @@ import { COMMON_STYLES } from "../../common/styles";
export abstract class Table<T> extends LitElement {
abstract apiEndpoint(page: number): Promise<PBResponse<T>>;
abstract columns(): Array<string>;
abstract row(item: any): Array<string>;
abstract row(item: T): Array<string>;
@property()
data?: PBResponse<T>;
@ -61,7 +61,7 @@ export abstract class Table<T> extends LitElement {
});
}
render() {
renderTable() {
if (!this.data) {
this.fetch();
}
@ -103,4 +103,8 @@ export abstract class Table<T> extends LitElement {
></pb-table-pagination>
</div>`;
}
render() {
return this.renderTable();
}
}

View File

@ -0,0 +1,23 @@
import { html } from "lit-html";
import { Table } from "./Table";
export abstract class TablePage<T> extends Table<T> {
abstract pageTitle(): string;
abstract pageDescription(): string;
abstract pageIcon(): string;
render() {
return html`<section class="pf-c-page__main-section pf-m-light">
<div class="pf-c-content">
<h1>
<i class="${this.pageIcon()}"></i>
${this.pageTitle()}
</h1>
<p>${this.pageDescription()}</p>
</div>
</section>
<section class="pf-c-page__main-section pf-m-no-padding-mobile">
<div class="pf-c-card">${this.renderTable()}</div>
</section>`;
}
}