Skip to content

docs(sort): add initial sorting docs #5513

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

Merged
merged 5 commits into from
Jul 5, 2017

Conversation

andrewseguin
Copy link
Contributor

No description provided.

@andrewseguin andrewseguin requested a review from jelbourn July 5, 2017 17:00
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 5, 2017
@andrewseguin andrewseguin added pr: needs review and removed cla: yes PR author has agreed to Google's Contributor License Agreement labels Jul 5, 2017
@@ -0,0 +1,19 @@
To add sorting behavior and styling to a set of table headers, add the `<md-sort-header>` component
Copy link
Member

Choose a reason for hiding this comment

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

The overview should be structured like

  1. Single sentence that summarizes the components, e.g.: "The mdSort and md-sort-header are used, respectively, to add sorting state and display to tabular data."
  2. overview example
  3. Basic use
  4. Additional sections on configuration, alternate behaviors, etc.
  5. Accessibility notes for this component

@@ -0,0 +1,3 @@
.mat-sort-header-container {
Copy link
Member

Choose a reason for hiding this comment

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

There should be an additional example of the sort directives being applied to an md-table.
(we can re-use the same example for both the table and sortable pages)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some message about it; can add example when table-docs PR is merged

let valueA = isNaN(+propertyA) ? propertyA : +propertyA;
let valueB = isNaN(+propertyB) ? propertyB : +propertyB;

return (valueA < valueB ? -1 : 1) * (sort.direction == 'asc' ? 1 : -1);
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this sort function is more complicated than needed for this example. Instead of baking all of the columns into the comparator, just have a compareNumber and compareString function and use the appropriate one based on the selected column?

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jul 5, 2017
@@ -0,0 +1,31 @@
The `mdSort` and `md-sort-header` are used, respectively, to add sorting behavior, state, and display
to tabular data.
Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't say "behavior", since the components don't actually do any sorting. The directives only capture the state and the display.

To reverse the sort order for all headers, set the `mdSortStart` to `desc` on the `mdSort` directive.
To reverse the order only for a specific header, set the `start` input only on the header instead.

To prevent the user from removing sort altogether after it is applied, set `mdSortDisableClear` to
Copy link
Member

Choose a reason for hiding this comment

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

"To prevent the user from clearing the sort state from an already sorted column"


<!-- example(sort-overview) -->

# Adding sort to table headers
Copy link
Member

Choose a reason for hiding this comment

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

Start with h3 (###) and go from there

@andrewseguin
Copy link
Contributor Author

Changes made, ready for another review

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Jul 5, 2017
@mmalerba mmalerba merged commit 38b4265 into angular:master Jul 5, 2017
amcdnl pushed a commit to amcdnl/material2 that referenced this pull request Jul 8, 2017
* docs(sort): add initial sorting docs

* add newlines

* update

* minor

* rebase, add table example
@andrewseguin andrewseguin deleted the sorting-docs branch November 28, 2017 20:37
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants