-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stark-ui): add footer to table component
ISSUES CLOSED: #1540
- Loading branch information
Showing
18 changed files
with
189 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./table-with-footer.component"; |
3 changes: 3 additions & 0 deletions
3
showcase/src/app/demo-ui/components/table-with-footer/table-with-footer.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<stark-table [data]="data" [columnProperties]="columns" [paginationConfig]="paginationConfig" [filter]="filter"> | ||
<header><h1 class="mb0" translate>SHOWCASE.DEMO.TABLE.WITH_FOOTER</h1></header> | ||
</stark-table> |
4 changes: 4 additions & 0 deletions
4
showcase/src/app/demo-ui/components/table-with-footer/table-with-footer.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Row class | ||
tr.mat-footer-row { | ||
font-weight: bold; | ||
} |
48 changes: 48 additions & 0 deletions
48
showcase/src/app/demo-ui/components/table-with-footer/table-with-footer.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { Component, ViewEncapsulation } from "@angular/core"; | ||
import { StarkPaginationConfig, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui"; | ||
|
||
const DUMMY_DATA: object[] = [ | ||
{ id: 1, cost: 12, description: "number one" }, | ||
{ id: 10, cost: 23, description: "second description" }, | ||
{ id: 12, cost: 5, description: "the third description" }, | ||
{ id: 2, cost: 33, description: "description number four" }, | ||
{ id: 23, cost: 54, description: "fifth description" }, | ||
{ id: 222, cost: 3, description: "the sixth description" }, | ||
{ id: 112, cost: 7, description: "seventh description" }, | ||
{ id: 232, cost: 24, description: "description number eight" }, | ||
{ id: 154, cost: 35, description: "the ninth description" }, | ||
{ id: 27, cost: 10, description: "description number ten" }, | ||
{ id: 86, cost: 21, description: "eleventh description" }, | ||
{ id: 44, cost: 6, description: "the twelfth description" } | ||
]; | ||
|
||
@Component({ | ||
selector: "showcase-table-with-footer", | ||
templateUrl: "./table-with-footer.component.html", | ||
styleUrls: ["./table-with-footer.component.scss"], | ||
/* tslint:disable-next-line:use-view-encapsulation */ | ||
encapsulation: ViewEncapsulation.None // Important | ||
}) | ||
export class TableWithFooterComponent { | ||
public data: object[] = DUMMY_DATA; | ||
public paginationConfig: StarkPaginationConfig = { | ||
itemsPerPage: 10 | ||
}; | ||
|
||
public columns: StarkTableColumnProperties[] = [ | ||
{ name: "id", label: "Id", footerValue: "SHOWCASE.DEMO.TABLE.FOOTER.TOTAL" }, | ||
{ | ||
name: "cost", | ||
label: "SHOWCASE.DEMO.TABLE.LABELS.TITLE", | ||
footerValue: this.getTotal() | ||
}, | ||
{ name: "description", label: "SHOWCASE.DEMO.TABLE.LABELS.DESCRIPTION" } | ||
]; | ||
|
||
public filter: StarkTableFilter = { globalFilterPresent: false, columns: [] }; | ||
|
||
/** Gets the total cost of all products. */ | ||
private getTotal(): number { | ||
return DUMMY_DATA.map((obj: any) => obj.cost).reduce((acc: number, value: number) => acc + value, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<stark-table [data]="data" [columnProperties]="columns" [paginationConfig]="paginationConfig" [filter]="filter"> | ||
<header><h1 class="mb0">Table with footer</h1></header> | ||
</stark-table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Row class | ||
tr.mat-footer-row { | ||
font-weight: bold; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Component, ViewEncapsulation } from "@angular/core"; | ||
import { StarkPaginationConfig, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui"; | ||
|
||
const DUMMY_DATA: object[] = [ | ||
{ id: 1, cost: 12, description: "number one" }, | ||
/* ... */ | ||
{ id: 44, cost: 6, description: "the twelfth description" } | ||
]; | ||
|
||
@Component({ | ||
selector: "showcase-table-with-footer", | ||
templateUrl: "./table-with-footer.component.html", | ||
styleUrls: ["./table-with-footer.component.scss"], | ||
encapsulation: ViewEncapsulation.None // Important | ||
}) | ||
export class TableWithFooterComponent { | ||
public data: object[] = DUMMY_DATA; | ||
public paginationConfig: StarkPaginationConfig = { | ||
itemsPerPage: 10 | ||
}; | ||
|
||
public columns: StarkTableColumnProperties[] = [ | ||
{ name: "id", label: "Id", footerValue: "SHOWCASE.DEMO.TABLE.FOOTER.TOTAL" }, | ||
{ | ||
name: "cost", | ||
label: "SHOWCASE.DEMO.TABLE.LABELS.TITLE", | ||
footerValue: this.getTotal() | ||
}, | ||
{ name: "description", label: "SHOWCASE.DEMO.TABLE.LABELS.DESCRIPTION" } | ||
]; | ||
|
||
public filter: StarkTableFilter = { globalFilterPresent: false, columns: [] }; | ||
|
||
/** Gets the total cost of all products. */ | ||
private getTotal(): number { | ||
return DUMMY_DATA.map((obj: any) => obj.cost).reduce((acc: number, value: number) => acc + value, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters