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

Table #559

Merged
merged 16 commits into from
Jan 24, 2018
Merged

Table #559

merged 16 commits into from
Jan 24, 2018

Conversation

benjamincharity
Copy link
Contributor

@benjamincharity benjamincharity commented Jan 24, 2018

TODO: Generate docs before merge.

PR Overview

  • Create table component
  • Create data source class for table
  • Create sort directive for column sorting
  • Refactor Pagination to Paginator
  • Add docs for
    • table
    • sort
    • minWidth
    • noWrap
  • Update ts-lint fix with correct glob
  • Added more testing utilities (could not import from @angular/cdk/testing)
  • A refactor commit can now trigger a breaking change

⚠️ ⚠️ ⚠️

This release will include BREAKING CHANGES

  • TsPagination (rename)
  • TsSelect (event emitters changed).

⚠️ ⚠️ ⚠️

WIP: table working after renaming `mat` to `ts`
WIP: working after adding directive/component suffix’
WIP: sorting working with MatSort
WIP: copy/paste sort module working
WIP: comments update, file names update, basic styles in place
WIP: table usage docs
WIP: clean up more, add TsSort docs
WIP: setting up demo for fetching real data
Material removed the open/close event emitters in favor of a single \`openedChanged\` emitter.

BREAKING CHANGE:
1. \`open\` and \`closed\` event emitters removed 2. \`change\` emitter renamed to match \`selectionChange\`
to match the material API
BREAKING CHANGE:
\`TsPaginationComponent\` has been renamed to \`TsPaginatorComponent\`
@benjamincharity benjamincharity self-assigned this Jan 24, 2018
@codecov
Copy link

codecov bot commented Jan 24, 2018

Codecov Report

Merging #559 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #559    +/-   ##
======================================
  Coverage     100%   100%            
======================================
  Files          37     45     +8     
  Lines         758    895   +137     
  Branches      143    158    +15     
======================================
+ Hits          758    895   +137
Impacted Files Coverage Δ
src/lib/src/card/card.component.ts 100% <ø> (ø) ⬆️
...s/validation-message/validation-message.service.ts 100% <ø> (ø) ⬆️
src/lib/src/search/search.component.ts 100% <ø> (ø) ⬆️
src/lib/src/datepicker/datepicker.component.ts 100% <ø> (ø) ⬆️
src/lib/src/menu/menu.component.ts 100% <ø> (ø) ⬆️
src/lib/src/copy/copy.component.ts 100% <ø> (ø) ⬆️
src/lib/src/login-form/login-form.component.ts 100% <ø> (ø) ⬆️
src/lib/src/select/select.component.ts 100% <ø> (ø) ⬆️
src/lib/src/link/link.component.ts 100% <ø> (ø) ⬆️
src/lib/src/sort/sort-animations.ts 100% <100%> (ø)
... and 20 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10c6c24...0f09837. Read the comment docs.

@benjamincharity benjamincharity added the DO NOT MERGE PRs that are not ready to be merged. label Jan 24, 2018
@benjamincharity
Copy link
Contributor Author

@coreyterminator @atlwendy I'd love some extra eyes on this prior to merge. Especially on the markdown file denoting how to use the table. I want to make sure the table makes sense and is usable for you guys.

NOTE: I do expect to create a higher-level component that the core team can use. This would have the table/paginator/sorting/etc all hooked up by default. I just would like to get v1 out first so I can move on some other high-priority items.

@benjamincharity
Copy link
Contributor Author

@coreyterminator @atlwendy I'm going ahead with this merge as it's got some items I need back in master. I would still love a review on the usage docs post-merge when you get time 🙏

@benjamincharity benjamincharity removed the DO NOT MERGE PRs that are not ready to be merged. label Jan 24, 2018
@benjamincharity benjamincharity merged commit 9c6d109 into master Jan 24, 2018
Copy link
Contributor

@atlwendy atlwendy left a comment

Choose a reason for hiding this comment

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

A lot here to digest/understand still... first patch of questions :)

(change)="isChanged($event)"
[formControl]="myForm.get('myChoices1')"
(openedChange)="openStateChange($event)"
(selectionChange)="isChanged($event)"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is (close) removed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Material removed/changed a few of their event emitters to make their API consistent back during their 2.0.0 stable push. We just never picked up those changes until now.

Part of angular/components#6677

});

// Fetch new data anytime the sort is changed, the page is changed, or the records shown per
// page is changed
Copy link
Contributor

Choose a reason for hiding this comment

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

You refetch new data even when page is changed? Would that be confusing to users if new data come in and mess with the page number?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't fetch new data, then there is no page change at all. We aren't paging through tons of rows locally; we are getting exactly the page we request from the server. So if the user clicks the pagination to go to the next page, we pass that 'next page' index to the server and ask for those records.

import { TsTableModule } from './table/table.module';
import { TsToggleModule } from './toggle/toggle.module';
import { TsTooltipModule } from './tooltip/tooltip.module';
import { TsValidationMessagesModule } from './validation-messages/validation-messages.module';
Copy link
Contributor

Choose a reason for hiding this comment

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

The linter also reorder for you, alphabetically!

host: {
class: 'ts-paginator',
},
changeDetection: ChangeDetectionStrategy.OnPush,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is here .OnPush - CheckOnce not CheckAlways?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This basically tells Angular to only run change detection when an @Input value changes. You are in essence promising to not do anything to mutate the state internally. This is much more performant since the change detection cycle doesn't have to check everything each time.

The few times where we need to do something internally in a component that uses this changeDetection strategy we manually tell the change detector to check for changes using changeDetectorRef.markForCheck().

export type TsSortDirection
= 'asc'
| 'desc'
| ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Does '' mean no sorting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep!

@benjamincharity benjamincharity deleted the 262-table-take2 branch February 19, 2018 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants