-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(stark-ui): initial implementation of Stark Table component (supporting nested data, sorting and filtering) #501
feat(stark-ui): initial implementation of Stark Table component (supporting nested data, sorting and filtering) #501
Conversation
I've added some interfaces related to the Action bar but those should be removed once the PR about the Action Bar component is merged. So please don't merge this PR yet, I have to rebase it as soon as the other PR is merged. |
I've updated #406 to include the list of features that should be supported. |
58367b6
to
d2ad745
Compare
fd73d6a
to
ee07179
Compare
I've rebased this PR so the action bar interfaces are removed from the Table folder ;) |
* Whether the column is sortable or not. Default: true | ||
*/ | ||
@Input() public sortable: boolean = false; | ||
@Input() public sortPriority: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add some documentation for the bindings ? 😊
<th mat-header-cell *matHeaderCellDef [ngClass]="{'sortable': sortable, 'filtering': filterValue}"> | ||
<div class="header-cell-content"> | ||
<div [ngSwitch]="sortDirection" class="sort-header" (click)="onSortChange()"> | ||
<span>{{ headerLabel || name }}</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be translated as it was the case in the old Stark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for now, translation is not part of this PR, as I mentioned in the description, this is only about nested data, sorting and filtering, otherwise this PR will be huge.
Translation and other features will be part of another PR 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. That means we'll have to be really careful to not forget anything in the next PR which will contain translations
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed
(keyup)="onFilterChange()"> | ||
</mat-form-field> | ||
<button mat-icon-button (click)="onClearFilter()"> | ||
<mat-icon svgIcon="close"></mat-icon> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a tooltip here ?
<span *ngIf="sortPriority < 1000 && sortDirection" class="priority">{{ sortPriority }}</span> | ||
</div> | ||
<button *ngIf="filterable" class="button-filter" [matMenuTriggerFor]="filterMenu" mat-icon-button> | ||
<mat-icon svgIcon="filter"></mat-icon> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a tooltip ?
* Name of the property that will be the source of the column. | ||
*/ | ||
@Input() | ||
public get name(): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this implementation replaces ngOnChanges(simplesChanges: SimpleChanges).
Is it working in the same way ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it has the same functionality. It is done like this for the moment because this is just the initial implementation of the table, we will see if we need to refactor this when we implement the rest of functionalities..
<table #matTable mat-table [dataSource]="dataSource" [ngClass]="{'multi-sorting': isMultiSorting}"> | ||
<ng-container *ngIf="multiselect" matColumnDef="select"> | ||
<th mat-header-cell *matHeaderCellDef> | ||
<mat-checkbox (change)="$event ? masterToggle() : null" [checked]="selection.hasValue() && isAllSelected()" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a tooltip ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?? where exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the th or, ideally, on the mat-checkbox element. But I'm not sure we can add tooltip directly on mat-checkbox component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, ok, I'll add it 😉
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr> | ||
</table> | ||
|
||
<mat-paginator [pageSizeOptions]="[5, 10, 20]" showFirstLastButtons></mat-paginator> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, it was possible to customize pagination options as those ones. Could you please put this back ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nop, pagination is not part of this PR, as I mentioned in the description, this is only about nested data, sorting and filtering. Pagination and other features will be part of another PR 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okido
import { FormsModule } from "@angular/forms"; | ||
import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; | ||
import { MatButtonModule } from "@angular/material/button"; | ||
import { MatCheckboxModule } from "@angular/material/checkbox"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why import every Angular Material elements separately instead of together as this:
import {
MatCheckboxModule,
MatButtonModule,
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, in fact I am not sure whether there are still some issues regarding the "tree-shaking" of the material components. See angular/components#4137 and angular/components#6210.
I think we can do some checks to verify it, but I would prefer to do it in another PR...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okido. My question is there because we didn't split the imports in other UI modules. But I guess we can merge them 😊 But let's do in another PR if you prefer
@Input() public filter: StarkTableFilter; | ||
|
||
/** | ||
* FIXME: should be "true" by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it should be true
, what are we waiting for setting it as true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, wrong FIXME, I'll remove it 😉
} | ||
} | ||
|
||
if (changes["filter"]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move this in the @Input
declaration as it is the case in column component (with get/set) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? In this ngOnChanges we handle the updates of 3 inputs: data, orderProperties and filter. Whereas in the ColumnComponent we only handle 1 input: name. In any case, as I said in the other comment of the ColumnComponent, we might refactor the getter/setter in case we need it. But this ngOnChanges block should not change in my opinion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okido. Let's keep it as this so 😊
packages/stark-ui/package.json
Outdated
@@ -39,6 +39,7 @@ | |||
"@angular/common": "6.x", | |||
"@angular/compiler": "6.x", | |||
"@angular/core": "6.x", | |||
"@angular/flex-layout": "6.x", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flex Layout should not be used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it is not yet used. I'll remove it so we will add it in another PR once we really need it 😉
* @param obj2 - Second object in the comparison | ||
*/ | ||
@Input() public compareFn?: ((obj1: any, obj2: any) => number); | ||
@Input() public dataAccessor?: ((data: any, name: string) => string); // TODO: really needed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing JSDoc
* @param columnName - The column that the cell belongs to | ||
*/ | ||
@Input() public cellFormatter?: ((value: any, row?: any, columnName?: string) => string); | ||
@Input() public sortDirection: StarkTableColumnSortingDirection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing JSDoc
* Use "\*" and "\?" to match exactly the characters "*" and "?" | ||
*/ | ||
@Input() public filterValue: string; | ||
@Input() public headerLabel: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing JSDoc
* Whether the column is sortable or not. Default: true | ||
*/ | ||
@Input() public sortable: boolean = false; | ||
@Input() public sortPriority: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing JSDoc
*/ | ||
@Input() public sortable: boolean = false; | ||
@Input() public sortPriority: number; | ||
@Input() public visibility: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing JSDoc
@Input() public sortPriority: number; | ||
@Input() public visibility: number; | ||
|
||
@Output() public filterChanged: EventEmitter<StarkTableColumnComponent> = new EventEmitter<StarkTableColumnComponent>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing JSDoc
@Input() public visibility: number; | ||
|
||
@Output() public filterChanged: EventEmitter<StarkTableColumnComponent> = new EventEmitter<StarkTableColumnComponent>(); | ||
@Output() public sortChanged: EventEmitter<StarkTableColumnComponent> = new EventEmitter<StarkTableColumnComponent>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing JSDoc
.stark-table table { | ||
border-radius: map-get($theme, border-radius); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think those styles can be removed. As we discussed, we will only provided styles related to the color and font of the component in the theme SCSS.
For other styles, code should be placed in the _table.component.scss
In this specific case, we won't provide any border radius theme variable. If we want to change the angular material default radius, we should then put our style in the _table.component.scss. The end user can then either use it or not by importing this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll remove them 😉
StarkTableMultisortDialogComponent, | ||
StarkTableMultisortDialogData | ||
>(StarkTableMultisortDialogComponent, { | ||
width: "500px", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should try to set this width through the SCSS, shall we create a ticket for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. A ticket is not necessary, I'll fix it 😉
ee07179
to
173a36b
Compare
…orting nested data, sorting and filtering)
173a36b
to
80e86c3
Compare
@catlabs @SuperITMan I've updated this PR. Apart from the changes for yout remarks, I've added a demo page in the showcase for the Table component ;) Could you please have a look and re-review this PR? |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #406
What is the new behavior?
New stark-table component integrated in stark-ui package.
Does this PR introduce a breaking change?