Skip to content

Commit

Permalink
fix(stark-demo): update usage examples of stark table
Browse files Browse the repository at this point in the history
  - added tests

ISSUE CLOSED: #1012
  • Loading branch information
carlo-nomes committed Mar 8, 2019
1 parent 3c3a4ca commit fd06086
Show file tree
Hide file tree
Showing 25 changed files with 31 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
[data]="data"
[columnProperties]="columns"
[filter]="filter"
[paginationConfig]="pagination"
[customTableActions]="tableActions"
customTableActionsType="alt"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Inject, OnInit } from "@angular/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core";
import { StarkAction, StarkPaginationConfig, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";
import { StarkAction, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";

const DUMMY_DATA: object[] = [
{ id: 1, title: { label: "first title (value: 1)", value: 1 }, description: "number one" },
Expand Down Expand Up @@ -28,8 +28,6 @@ export class TableWithCustomActionsComponent implements OnInit {

public filter: StarkTableFilter;

public pagination: StarkPaginationConfig;

public tableActions: StarkAction[];

public constructor(@Inject(STARK_LOGGING_SERVICE) private logger: StarkLoggingService) {}
Expand All @@ -49,8 +47,6 @@ export class TableWithCustomActionsComponent implements OnInit {

this.filter = { globalFilterPresent: false, columns: [] };

this.pagination = { totalItems: DUMMY_DATA.length, page: 1, itemsPerPage: 10 };

this.tableActions = [
{
id: "edit-item",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<stark-table
[data]="data"
[columnProperties]="columns"
[filter]="filter"
[paginationConfig]="pagination"
[rowClassNameFn]="getRowClassName"
>
<stark-table [data]="data" [columnProperties]="columns" [filter]="filter" [rowClassNameFn]="getRowClassName">
<header><h1 class="mb0" translate>SHOWCASE.DEMO.TABLE.WITH_CUSTOM_STYLING</h1></header>
</stark-table>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, ViewEncapsulation } from "@angular/core";
import { StarkPaginationConfig, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";
import { StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";

const DUMMY_DATA: object[] = [
{ id: 1, title: { label: "first title (value: 1)", value: 1 }, description: "number one" },
Expand Down Expand Up @@ -29,8 +29,6 @@ export class TableWithCustomStylingComponent implements OnInit {

public filter: StarkTableFilter;

public pagination: StarkPaginationConfig;

public getRowClassName: (_row: object, index: number) => string;

public ngOnInit(): void {
Expand All @@ -49,8 +47,6 @@ export class TableWithCustomStylingComponent implements OnInit {

this.filter = { globalFilterPresent: false, columns: [] };

this.pagination = { totalItems: DUMMY_DATA.length, page: 1, itemsPerPage: 10 };

this.getRowClassName = (_row: object, index: number) => (index % 2 === 0 ? "even" : "odd");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
[data]="data"
[columnProperties]="columns"
[filter]="filter"
[paginationConfig]="pagination"
[tableRowActions]="tableRowActions"
customTableActionsType="alt"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Inject, OnInit } from "@angular/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core";
import { StarkPaginationConfig, StarkTableColumnProperties, StarkTableFilter, StarkTableRowActions } from "@nationalbankbelgium/stark-ui";
import { StarkTableColumnProperties, StarkTableFilter, StarkTableRowActions } from "@nationalbankbelgium/stark-ui";

// tslint:disable:no-duplicate-string
const DUMMY_DATA: object[] = [
Expand Down Expand Up @@ -115,8 +115,6 @@ export class TableWithFixedActionsComponent implements OnInit {

public filter: StarkTableFilter;

public pagination: StarkPaginationConfig;

public tableRowActions: StarkTableRowActions;

public constructor(@Inject(STARK_LOGGING_SERVICE) private logger: StarkLoggingService) {}
Expand All @@ -141,8 +139,6 @@ export class TableWithFixedActionsComponent implements OnInit {

this.filter = { globalFilterPresent: false, columns: [] };

this.pagination = { totalItems: DUMMY_DATA.length, page: 1, itemsPerPage: 10 };

this.tableRowActions = {
actions: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<stark-table [data]="data" [columnProperties]="columns" [filter]="filter" [paginationConfig]="pagination" fixedHeader>
<stark-table [data]="data" [columnProperties]="columns" [filter]="filter" fixedHeader>
<header><h1 class="mb0" translate>SHOWCASE.DEMO.TABLE.WITH_FIXED_HEADER</h1></header>
</stark-table>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { StarkPaginationConfig, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";
import { StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";

const DUMMY_DATA: object[] = [
{ id: 1, title: { label: "first title (value: 1)", value: 1 }, description: "number one" },
Expand Down Expand Up @@ -27,8 +27,6 @@ export class TableWithFixedHeaderComponent implements OnInit {

public filter: StarkTableFilter;

public pagination: StarkPaginationConfig;

public ngOnInit(): void {
this.data = DUMMY_DATA;

Expand All @@ -43,7 +41,5 @@ export class TableWithFixedHeaderComponent implements OnInit {
];

this.filter = { globalFilterPresent: false, columns: [] };

this.pagination = { totalItems: DUMMY_DATA.length, page: 1, itemsPerPage: DUMMY_DATA.length };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
[data]="data"
[columnProperties]="columns"
[filter]="filter"
[paginationConfig]="pagination"
[rowsSelectable]="true"
(selectChanged)="handleRowSelected($event)"
multiSelect
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Inject, OnInit } from "@angular/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core";
import { StarkPaginationConfig, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";
import { StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";

const DUMMY_DATA: object[] = [
{ id: 1, title: { label: "first title (value: 1)", value: 1 }, description: "number one" },
Expand Down Expand Up @@ -28,8 +28,6 @@ export class TableWithSelectionComponent implements OnInit {

public filter: StarkTableFilter;

public pagination: StarkPaginationConfig;

public constructor(@Inject(STARK_LOGGING_SERVICE) private logger: StarkLoggingService) {}

public ngOnInit(): void {
Expand All @@ -46,8 +44,6 @@ export class TableWithSelectionComponent implements OnInit {
];

this.filter = { globalFilterPresent: false, columns: [] };

this.pagination = { totalItems: DUMMY_DATA.length, page: 1, itemsPerPage: 10 };
}

public handleRowSelected(data: object[]): void {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<stark-table [data]="data" [columnProperties]="columns" [filter]="filter" [paginationConfig]="pagination">
<stark-table [data]="data" [columnProperties]="columns" [filter]="filter">
<header>
<div class="example-transcluded">
<h1 class="mb0" translate>SHOWCASE.DEMO.TABLE.WITH_TRANSCLUDED_ACTION_BAR</h1>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Inject, OnInit } from "@angular/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core";
import { StarkAction, StarkPaginationConfig, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";
import { StarkAction, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";

const DUMMY_DATA: object[] = [
{ id: 1, title: { label: "first title (value: 1)", value: 1 }, description: "number one" },
Expand Down Expand Up @@ -29,8 +29,6 @@ export class TableWithTranscludedActionBarComponent implements OnInit {

public filter: StarkTableFilter;

public pagination: StarkPaginationConfig;

public tableActions: StarkAction[];

public constructor(@Inject(STARK_LOGGING_SERVICE) private logger: StarkLoggingService) {}
Expand All @@ -46,8 +44,6 @@ export class TableWithTranscludedActionBarComponent implements OnInit {

this.filter = { globalFilterPresent: false, columns: [] };

this.pagination = { totalItems: DUMMY_DATA.length, page: 1, itemsPerPage: 10 };

this.tableActions = [
{
id: "edit-item",
Expand Down
1 change: 0 additions & 1 deletion showcase/src/assets/examples/table/regular/table.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@import "~@angular/material/theming";

// todo review after #509 (https://github.com/NationalBankBelgium/stark/issues/509)
.shadowed {
.header {
padding: 10px 15px;
Expand Down
4 changes: 2 additions & 2 deletions showcase/src/assets/examples/table/regular/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ export class TableRegularComponent implements OnInit {
actions: [
{
id: "edit-item",
label: "STARK.ICONS.EDIT_ITEM",
label: "Edit",
icon: "pencil",
actionCall: ($event: Event, data: object) => this.logger.debug("EDIT", $event, data),
isEnabled: true
},
{
id: "delete-item",
label: "STARK.ICONS.DELETE_ITEM",
label: "Delete",
icon: "delete",
actionCall: ($event: Event, data: object) => this.logger.debug("DELETE", $event, data),
isEnabled: false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<stark-table
[data]="data"
[columnProperties]="columns"
[filter]="filter"
[paginationConfig]="pagination"
[customTableActions]="tableActions"
customTableActionsType="alt"
>
<stark-table [data]="data" [columnProperties]="columns" [filter]="filter" [customTableActions]="tableActions" customTableActionsType="alt">
<header><h1 class="mb0">Table with custom actions</h1></header>
</stark-table>
27 changes: 9 additions & 18 deletions showcase/src/assets/examples/table/with-custom-actions/table.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import { Component, Inject, OnInit } from "@angular/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core";
import { StarkAction, StarkPaginationConfig, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";
import { StarkAction, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";

const DUMMY_DATA: object[] = [
{ id: 1, title: { label: "first title (value: 1)", value: 1 }, description: "number one" },
{ id: 10, title: { label: "second title (value: 2)", value: 2 }, description: "second description" },
{ id: 12, title: { label: "third title (value: 3)", value: 3 }, description: "the third description" },
{ id: 2, title: { label: "fourth title (value: 4)", value: 4 }, description: "description number four" },
{ id: 23, title: { label: "fifth title (value: 5)", value: 5 }, description: "fifth description" },
{ id: 222, title: { label: "sixth title (value: 6)", value: 6 }, description: "the sixth description" },
{ id: 112, title: { label: "seventh title (value: 7)", value: 7 }, description: "seventh description" },
{ id: 232, title: { label: "eighth title (value: 8)", value: 8 }, description: "description number eight" },
{ id: 154, title: { label: "ninth title (value: 9)", value: 9 }, description: "the ninth description" },
{ id: 27, title: { label: "tenth title (value: 10)", value: 10 }, description: "description number ten" },
{ id: 86, title: { label: "eleventh title (value: 11)", value: 11 }, description: "eleventh description" },
/* ... */
{ id: 44, title: { label: "twelfth title (value: 12)", value: 12 }, description: "the twelfth description" }
];

Expand All @@ -28,8 +19,6 @@ export class TableWithCustomActionsComponent implements OnInit {

public filter: StarkTableFilter;

public pagination: StarkPaginationConfig;

public tableActions: StarkAction[];

public constructor(@Inject(STARK_LOGGING_SERVICE) private logger: StarkLoggingService) {}
Expand All @@ -39,25 +28,27 @@ export class TableWithCustomActionsComponent implements OnInit {

this.columns = [
{ name: "id", label: "Id" },
{ name: "title", label: "Title", cellFormatter: (value: { label: string }): string => "~" + value.label },
{
name: "title",
label: "Title",
cellFormatter: (value: { label: string }): string => "~" + value.label
},
{ name: "description", label: "Description" }
];

this.filter = { globalFilterPresent: false, columns: [] };

this.pagination = { totalItems: DUMMY_DATA.length, page: 1, itemsPerPage: 10 };

this.tableActions = [
{
id: "edit-item",
label: "STARK.ICONS.EDIT_ITEM",
label: "Edit",
icon: "pencil",
actionCall: ($event: Event, data: object) => this.logger.debug("EDIT:", $event, data),
isEnabled: false
},
{
id: "reload",
label: "STARK.ICONS.RELOAD_PAGE",
label: "Reload page",
icon: "autorenew",
actionCall: ($event: Event, data: object) => this.logger.debug("RELOAD:", $event, data),
isEnabled: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<stark-table
[data]="data"
[columnProperties]="columns"
[filter]="filter"
[paginationConfig]="pagination"
[rowClassNameFn]="getRowClassName"
>
<stark-table [data]="data" [columnProperties]="columns" [filter]="filter" [rowClassNameFn]="getRowClassName">
<header><h1 class="mb0">Table with custom styling</h1></header>
</stark-table>
17 changes: 2 additions & 15 deletions showcase/src/assets/examples/table/with-custom-styling/table.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
import { Component, OnInit, ViewEncapsulation } from "@angular/core";
import { StarkPaginationConfig, StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";
import { StarkTableColumnProperties, StarkTableFilter } from "@nationalbankbelgium/stark-ui";

const DUMMY_DATA: object[] = [
{ id: 1, title: { label: "first title (value: 1)", value: 1 }, description: "number one" },
{ id: 10, title: { label: "second title (value: 2)", value: 2 }, description: "second description" },
{ id: 12, title: { label: "third title (value: 3)", value: 3 }, description: "the third description" },
{ id: 2, title: { label: "fourth title (value: 4)", value: 4 }, description: "description number four" },
{ id: 23, title: { label: "fifth title (value: 5)", value: 5 }, description: "fifth description" },
{ id: 222, title: { label: "sixth title (value: 6)", value: 6 }, description: "the sixth description" },
{ id: 112, title: { label: "seventh title (value: 7)", value: 7 }, description: "seventh description" },
{ id: 232, title: { label: "eighth title (value: 8)", value: 8 }, description: "description number eight" },
{ id: 154, title: { label: "ninth title (value: 9)", value: 9 }, description: "the ninth description" },
{ id: 27, title: { label: "tenth title (value: 10)", value: 10 }, description: "description number ten" },
{ id: 86, title: { label: "eleventh title (value: 11)", value: 11 }, description: "eleventh description" },
/* ... */
{ id: 44, title: { label: "twelfth title (value: 12)", value: 12 }, description: "the twelfth description" }
];

Expand All @@ -29,8 +20,6 @@ export class TableWithCustomStylingComponent implements OnInit {

public filter: StarkTableFilter;

public pagination: StarkPaginationConfig;

public getRowClassName: (_row: object, index: number) => string;

public ngOnInit(): void {
Expand All @@ -49,8 +38,6 @@ export class TableWithCustomStylingComponent implements OnInit {

this.filter = { globalFilterPresent: false, columns: [] };

this.pagination = { totalItems: DUMMY_DATA.length, page: 1, itemsPerPage: 10 };

this.getRowClassName = (_row: object, index: number) => (index % 2 === 0 ? "even" : "odd");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
[data]="data"
[columnProperties]="columns"
[filter]="filter"
[paginationConfig]="pagination"
[tableRowActions]="tableRowActions"
customTableActionsType="alt"
>
Expand Down
11 changes: 1 addition & 10 deletions showcase/src/assets/examples/table/with-fixed-actions/table.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { Component, Inject, OnInit } from "@angular/core";
import { STARK_LOGGING_SERVICE, StarkLoggingService } from "@nationalbankbelgium/stark-core";
import {
StarkPaginationConfig,
StarkTableColumnProperties,
StarkTableFilter,
StarkTableRowActions
} from "@nationalbankbelgium/stark-ui";
import { StarkTableColumnProperties, StarkTableFilter, StarkTableRowActions } from "@nationalbankbelgium/stark-ui";

const DUMMY_DATA: object[] = [
{
Expand Down Expand Up @@ -39,8 +34,6 @@ export class TableWithFixedActionsComponent implements OnInit {

public filter: StarkTableFilter;

public pagination: StarkPaginationConfig;

public tableRowActions: StarkTableRowActions;

public constructor(@Inject(STARK_LOGGING_SERVICE) private logger: StarkLoggingService) {}
Expand All @@ -63,8 +56,6 @@ export class TableWithFixedActionsComponent implements OnInit {

this.filter = { globalFilterPresent: false, columns: [] };

this.pagination = { totalItems: DUMMY_DATA.length, page: 1, itemsPerPage: 10 };

this.tableRowActions = {
actions: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<stark-table [data]="data" [columnProperties]="columns" [filter]="filter" [paginationConfig]="pagination" fixedHeader>
<stark-table [data]="data" [columnProperties]="columns" [filter]="filter" fixedHeader>
<header><h1 class="mb0">Table with fixed header</h1></header>
</stark-table>

0 comments on commit fd06086

Please sign in to comment.