forked from onecx/onecx-portal-ui-libs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: table row selection (onecx#82)
* feat: create DataTableComponent storybook entry * feat: basic selection feature for data-table component * feat: connect selection feature to parent components * test: add smoke tests to interactive-data-view * test: add smoke tests to data-view * test: add tests to data-table * refactor: improve data-table tests & harness * fix: use combineLatest instead of withLatestFrom * fix: fix harness loading --------- Co-authored-by: Bastian Jakobi <[email protected]>
- Loading branch information
1 parent
301273a
commit 10bd6eb
Showing
13 changed files
with
507 additions
and
5 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
114 changes: 114 additions & 0 deletions
114
...al-integration-angular/src/lib/core/components/data-table/data-table.component.stories.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,114 @@ | ||
import { Meta, moduleMetadata, applicationConfig, StoryFn } from '@storybook/angular'; | ||
import { DataTableComponent } from "./data-table.component"; | ||
import { TableModule } from 'primeng/table'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
import { ButtonModule } from 'primeng/button'; | ||
import { MultiSelectModule } from 'primeng/multiselect'; | ||
import { importProvidersFrom } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; | ||
import { ColumnType } from '../../../model/column-type.model'; | ||
type DataTableInputTypes = Pick<DataTableComponent, 'rows' | 'columns' | 'emptyResultsMessage' | 'selectedRows'> | ||
const DataTableComponentSBConfig: Meta<DataTableComponent> = { | ||
title: 'DataTableComponent', | ||
component: DataTableComponent, | ||
decorators: [ | ||
applicationConfig({ | ||
providers: [ | ||
importProvidersFrom(BrowserModule), | ||
importProvidersFrom(BrowserAnimationsModule), | ||
importProvidersFrom(TranslateModule.forRoot({})), | ||
] | ||
}), | ||
moduleMetadata({ | ||
declarations: [DataTableComponent], | ||
imports: [ | ||
TableModule, | ||
TranslateModule, | ||
ButtonModule, | ||
MultiSelectModule | ||
] | ||
}) | ||
] | ||
} | ||
const Template: StoryFn = (args) => ({ | ||
props: args, | ||
}) | ||
|
||
const defaultComponentArgs: DataTableInputTypes = { | ||
columns: [ | ||
{ | ||
id: "product", | ||
columnType: ColumnType.STRING, | ||
nameKey: "Product", | ||
sortable: false | ||
}, | ||
{ | ||
id: "amount", | ||
columnType: ColumnType.NUMBER, | ||
nameKey: "Amount", | ||
sortable: true | ||
} | ||
], | ||
rows: [ | ||
{ | ||
id: 1, | ||
product: "Apples", | ||
amount: 2 | ||
}, | ||
{ | ||
id: 2, | ||
product: "Bananas", | ||
amount: 10 | ||
}, | ||
{ | ||
id: 3, | ||
product: "Strawberries", | ||
amount: 5 | ||
} | ||
], | ||
emptyResultsMessage: "No results", | ||
selectedRows: [] | ||
} | ||
|
||
export const WithMockData = { | ||
render: Template, | ||
args: defaultComponentArgs, | ||
} | ||
|
||
export const NoData = { | ||
render: Template, | ||
args: { | ||
...defaultComponentArgs, | ||
rows: [], | ||
} | ||
} | ||
|
||
export const WithRowSelection = { | ||
argTypes: { | ||
selectionChanged: {action: 'selectionChanged'} | ||
}, | ||
render: Template, | ||
args: { | ||
...defaultComponentArgs, | ||
selectionChanged: ($event: any) => console.log("Selection changed ", $event) | ||
} | ||
} | ||
|
||
export const WithRowSelectionAndDefaultSelection = { | ||
argTypes: { | ||
selectionChanged: {action: 'selectionChanged'} | ||
}, | ||
render: Template, | ||
args: { | ||
...defaultComponentArgs, | ||
selectionChanged: ($event: any) => console.log("Selection changed ", $event), | ||
selectedRows: [ | ||
{ | ||
id: 1 | ||
} | ||
] | ||
} | ||
} | ||
|
||
export default DataTableComponentSBConfig; |
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
Oops, something went wrong.