Skip to content
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): add stark-action-bar into stark-table #525

Merged

Conversation

catlabs
Copy link
Contributor

@catlabs catlabs commented Jul 18, 2018

ISSUES CLOSED: #512

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Add the stark-action-bar to the stark-table

Issue Number: #512

Copy link
Collaborator

@christophercr christophercr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from integrating the action bar component in the row action bar, we should also integrate it in the table action bar.

@catlabs catlabs force-pushed the feature/table-action-bar branch 3 times, most recently from eeb1f68 to 44b2e2b Compare July 19, 2018 08:20
@catlabs
Copy link
Contributor Author

catlabs commented Jul 19, 2018

Now we also have the main action bar on the table.
I also cleaned up a bit the SCSS import of the table to be inline with the other components.
Action bar has a new Input, buttonColor which set the default color for all buttons.
I added 3 examples on the demo but we still need to add the example viewer (#514)


.actions {
align-items: center;
display: flex;
justify-content: flex-end;
&.actions-alt{
Copy link
Member

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 space before the bracket ?
(Prettier should do it automatically normally 😕)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strange cause I ran prettier-check before pushing... Maybe we should have a ticket about it?

.stark-table {
.header {
align-items: center;
display: flex;
justify-content: space-between;
margin-bottom: 20px;

.transcluded{
Copy link
Member

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 space before the bracket ?
(Prettier should do it automatically normally 😕)

@@ -4,10 +4,10 @@
<div *ngFor="let action of actionBarConfig.actions; trackBy: trackAction" [id]="actionBarId + '-' + action.id"
(click)="onClick(action, $event)" class="stark-action-bar--action">
<ng-container *ngIf="action.isVisible !== false">
<button [color]="action.buttonColor ? action.buttonColor:'primary'" [ngClass]="action.className" [matTooltip]="action.labelSwitchFunction ? action.labelActivated : action.label" [disabled]="!action.isEnabled" mat-icon-button>
<button [color]="action.buttonColor ? action.buttonColor:buttonColor" [ngClass]="action.className" [matTooltip]="action.labelSwitchFunction ? action.labelActivated : action.label" [disabled]="!action.isEnabled" mat-icon-button>
Copy link
Member

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 space before and after the : for having (action.buttonColor ? action.buttonColor : buttonColor) ?
(Prettier should do it automatically normally 😕)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, in fact Prettier doesn't support HTML yet 😩
https://prettier.io/docs/en/language-support.html
prettier/prettier#1882

<mat-icon starkSvgViewBox [svgIcon]="action.iconSwitchFunction ? action.iconActivated : action.icon" class="stark-small-icon"></mat-icon>
</button>
<label [class]="'action-label '+ (action.buttonColor?action.buttonColor:'primary')" [ngClass]="{'disabled': !action.isEnabled}" *ngIf="isExtended"> <span translate>{{ action.label }}</span></label>
<label [class]="'action-label '+ (action.buttonColor ? action.buttonColor:buttonColor)" [ngClass]="{'disabled': !action.isEnabled}" *ngIf="isExtended"> <span translate>{{ action.label }}</span></label>
Copy link
Member

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 space before and after the : for having (action.buttonColor ? action.buttonColor : buttonColor) ?
(Prettier should do it automatically normally 😕)

<div class="actions">
<button *ngIf="isMultiSortEnabled" (click)="openMultiSortDialog()" mat-icon-button>
<mat-icon svgIcon="sort" matTooltip="Multi-Column Sorting"></mat-icon>
<div class="header mat-el">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is mat-el class ?

/**
* Type of StarkAction objects
*/
@Input() public customTableActionsType: 'regular' | 'alt' | string = 'regular';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please replace ' by " ?
(Prettier should do it automatically normally 😕)

<ng-content select="header"></ng-content>
</div>
<div class="actions" [ngClass]="{'actions-alt': customTableActionsType === 'alt'}">
<stark-action-bar [actionBarConfig]="customTableActionsType === 'regular' ?{actions: customTableActions}:{}" [alternativeActions]="customTableActionsType === 'alt' ?customTableActions:null" buttonColor="alt" mode="compact"></stark-action-bar>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid adding to much logic in the templates and do all manipulations in the component class instead.

Moreover, in this particular case we are creating new objects which should implement a certain interface, but this is easy to overlook and we might forget to change this whenever we change the interface. This will be much easier to detect in the component class.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark as below:
Well yeah we could have a more flexible approach but this one is the one that cost the less effort regarding the old API.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand the reason of this code, but the point here is that this code should be in the component class instead of the template. It is safer there and more difficult to overlook potential issues related to the interface that should be implemented.

<span>{{ context.displayedValue }}</span>
</ng-template>
</stark-table-column>
<mat-card-content>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we use a <mat-card-content> here? I would suggest to use all the minimal MatCard elements or none of them but not just one of them which might cause some weird behavior if used alone.

Maybe a simple <div> with some styling will be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't matter as we will implement the example-viewer #514

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so I think we should just remove the <mat-card-content> and keep the code clean (so we don't need to import the MatCardModule).

@@ -24,6 +27,7 @@ import { StarkTableMultisortDialogComponent } from "./components/dialogs/multiso
BrowserAnimationsModule,
FormsModule,
MatButtonModule,
MatCardModule,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we replace the <mat-card-content> in the template, then this will not be needed anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't matter as we will implement the example-viewer #514

/**
* Type of StarkAction objects
*/
@Input() public customTableActionsType: "regular" | "alt" | string = "regular";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why there is the "string" type? Normally, there are only 2 possible values: "regular" and "alt" right?

And for the type "alt", it stands for "alternative" right? Then I think we should use the full name so it is clear the intention. The more descriptive our API is the better.

templateUrl: "./table.component.html"
styleUrls: ["./table.component.scss"],
templateUrl: "./table.component.html",
encapsulation: ViewEncapsulation.None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a comment indicating why you use ViewEncapsulation.None?

@@ -5,7 +5,8 @@
@import "~@nationalbankbelgium/stark-ui/assets/themes/button-theme";
@import "~@nationalbankbelgium/stark-ui/assets/themes/card-theme";
@import "~@nationalbankbelgium/stark-ui/assets/themes/menu-theme";
@import "~@nationalbankbelgium/stark-ui/assets/themes/table-theme";
@import "~@nationalbankbelgium/stark-ui/src/modules/table/components/table.component";
@import "~@nationalbankbelgium/stark-ui/src/modules/table/components/dialogs/multisort.component";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these 2 files are imported here? Normally only the "theme" files should be imported here and not the "component" files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I don't agree, all the other theme files are imported here (see action bar and slider) and I think it is the right place to put them. Here the enduser can decide either he wants to import them or not.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah indeed, I overlooked that ;)

@@ -3,6 +3,3 @@
@import "~basscss/css/basscss.css";
@import "~normalize.css/normalize.css";
@import "~prismjs/themes/prism-okaidia.css";

@import "~@nationalbankbelgium/stark-ui/src/modules/table/components/table.component";
@import "~@nationalbankbelgium/stark-ui/src/modules/table/components/dialogs/multisort.component";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these should not be removed from here, see my previous comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark as above

<div class="transcluded">
<ng-content select="header"></ng-content>
</div>
<div class="actions" [ngClass]="{'actions-alt': customTableActionsType === 'alt'}">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if this approach (defining the "customTableActionsType" in the table) is flexible enough.

Wouldn't it be more flexible to define it in the Action instead of in the table? Then the developer can decide for every action if they should be "alternative" or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well yeah we could have a more flexible approach but this one is the one that cost the less effort regarding the old API. The idea behind is to either have a full bar or an alt action bar. It won't make sense for now to use both of them in the main table action bar.
For now it is a matter of showing to the end user what we could do and how the interface could be improved, I think we should first propose this option and then see what we do according to their feedbacks.

@catlabs catlabs force-pushed the feature/table-action-bar branch 2 times, most recently from f972578 to 6612d19 Compare July 19, 2018 12:54
@catlabs
Copy link
Contributor Author

catlabs commented Jul 19, 2018

Re-pushed

@SuperITMan
Copy link
Member

@catlabs could you rebase your PR ? 😊

@catlabs
Copy link
Contributor Author

catlabs commented Jul 24, 2018

Yep it is rebased :-)

@SuperITMan SuperITMan merged commit bd2e5f5 into NationalBankBelgium:master Jul 24, 2018
@SuperITMan SuperITMan added this to Done in 10.0.0-alpha.4 Jul 30, 2018
@catlabs catlabs deleted the feature/table-action-bar branch July 30, 2018 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

ui: table - implement table and row action bars
4 participants