Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

Commit

Permalink
fix(tag component): parameterized row selection event
Browse files Browse the repository at this point in the history
re #6
  • Loading branch information
Klimonov committed Oct 1, 2020
1 parent 17419f7 commit eb91e73
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/components/beta/gux-table-beta/gux-table-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ export interface ISortState {
columnName: string;
sortDirection: string;
}

export interface ISelectedState {
rowIds: string[];
actionType: 'selected' | 'unselected';
}
14 changes: 9 additions & 5 deletions src/components/beta/gux-table-beta/gux-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import {
} from '@stencil/core';
import { buildI18nForComponent, GetI18nValue } from '../../../i18n';
import tableResources from './i18n/en.json';
import { IColumnResizeState, ISortState } from './gux-table-constants';
import {
IColumnResizeState,
ISortState,
ISelectedState
} from './gux-table-constants';
import { whenEventIsFrom } from '../../../common-utils';

const COL_RESIZE_HANDLE_WIDTH = 3;
Expand Down Expand Up @@ -82,7 +86,7 @@ export class GuxTable {
/**
* Triggers when table row was selected/unselected
*/
@Event() selectionChanged: EventEmitter;
@Event() selectionChanged: EventEmitter<ISelectedState>;

/**
* Triggers when the sorting of the table column is changed.
Expand Down Expand Up @@ -442,13 +446,13 @@ export class GuxTable {
if (checkbox.checked) {
currentRow.setAttribute('data-selected-row', '');
this.selectionChanged.emit({
rowsIds: [currentRow.getAttribute('data-row-id')],
rowIds: [currentRow.getAttribute('data-row-id')],
actionType: 'selected'
});
} else {
currentRow.removeAttribute('data-selected-row');
this.selectionChanged.emit({
rowsIds: [currentRow.getAttribute('data-row-id')],
rowIds: [currentRow.getAttribute('data-row-id')],
actionType: 'unselected'
});
}
Expand All @@ -473,7 +477,7 @@ export class GuxTable {
}
});
this.selectionChanged.emit({
rowsIds: allAttributes,
rowIds: allAttributes,
actionType: mainCheckbox.checked ? 'selected' : 'unselected'
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/beta/gux-table-beta/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

## Events

| Event | Description | Type |
| ------------------ | --------------------------------------------------------- | ------------------------- |
| `selectionChanged` | Triggers when table row was selected/unselected | `CustomEvent<any>` |
| `sortChanged` | Triggers when the sorting of the table column is changed. | `CustomEvent<ISortState>` |
| Event | Description | Type |
| ------------------ | --------------------------------------------------------- | ----------------------------- |
| `selectionChanged` | Triggers when table row was selected/unselected | `CustomEvent<ISelectedState>` |
| `sortChanged` | Triggers when the sorting of the table column is changed. | `CustomEvent<ISortState>` |


## Dependencies
Expand Down

0 comments on commit eb91e73

Please sign in to comment.