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(datepicker): add month & year view #2904

Merged
merged 19 commits into from
Feb 7, 2017
Merged

Conversation

mmalerba
Copy link
Contributor

@mmalerba mmalerba commented Feb 2, 2017

No description provided.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 2, 2017
});

it('handles month and date underflow', () => {
expect(new SimpleDate(2017, -1, 0)).toEqual(new SimpleDate(2016, 10, 30));
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it (2016, 10, 31)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The months are 0-indexed to match native JS Dates, so 10 = November. I considered using 1-indexed because it make more sense, but I thought it was better to just stay consistent with what people already know. I'll add a note about the 0-indexing to the SimpleDate docs.

});

it('highlights selected', () => {
let todayCell = calendarTableNativeElement.querySelector('.mat-calendar-table-selected');
Copy link
Contributor

Choose a reason for hiding this comment

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

very nit: selectedCell?

TestBed.compileComponents();
}));

describe('standard year view', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: standard month view

* The date of the month that the currently selected Date falls on.
* Null if the currently selected Date is in another month.
*/
_selectedDate = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to set default value to null?
Add type for this variable?


constructor(private _locale: CalendarLocale) {
// First row of months only contains 5 elements so we can fit the year label on the same row.
this._months = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9, 10, 11]].map(row => row.map(
Copy link
Contributor

Choose a reason for hiding this comment

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

months value should start from 0 or 1? could you please add some docs?

Copy link
Contributor

@tinayuangao tinayuangao left a comment

Choose a reason for hiding this comment

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

LGTM

return this._date.getMonth();
}

/** The date component of this date. */
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Also add doc about date index?

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

Nits

static fromNativeDate(nativeDate: Date) {
return new SimpleDate(nativeDate.getFullYear(), nativeDate.getMonth(), nativeDate.getDate());
}

constructor(public year: number, public month: number, public date: number) {}
/** Creates a SimpleDate object representing today. */
static today() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Return type? Same for methods below.


.mat-calendar-table-label {
height: $mat-calendar-table-cell-content-size;
padding: 0 0 0 10px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Sass variable for 10px? Seems like the only one missing.

expect(labelEls.length).toBe(1);
expect(cellEls.length).toBe(11);
expect(rowEls[0].firstElementChild.classList.contains('mat-calendar-table-label')).toBe(
true, 'first cell should be the label');
Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a bit more readable if you use toContain() assertion

 expect(rowEls[0].firstElementChild.classList)
    .toContain('mat-calendar-table-label', 'First cell should be the label.');

this._date = this._locale.parseDate(value) || SimpleDate.today();
this._init();
}
private _date = SimpleDate.today();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you stack all the private properties at the top of the class? That's typically the format we use in other components so it's easy to find them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When it's acting as backing for a public property with a getter/setter isn't it nicer to have it next to its getter/setter?

@mmalerba mmalerba merged commit 3e88d46 into angular:datepicker Feb 7, 2017
mmalerba added a commit to mmalerba/components that referenced this pull request Feb 8, 2017
mmalerba added a commit that referenced this pull request Feb 8, 2017
mmalerba added a commit to mmalerba/components that referenced this pull request Feb 9, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit to mmalerba/components that referenced this pull request Feb 9, 2017
mmalerba added a commit that referenced this pull request Feb 9, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit that referenced this pull request Feb 9, 2017
mmalerba added a commit that referenced this pull request Feb 27, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit that referenced this pull request Feb 27, 2017
mmalerba added a commit that referenced this pull request Mar 2, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit that referenced this pull request Mar 2, 2017
mmalerba added a commit to mmalerba/components that referenced this pull request Mar 6, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit to mmalerba/components that referenced this pull request Mar 6, 2017
mmalerba added a commit that referenced this pull request Mar 17, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit that referenced this pull request Mar 17, 2017
mmalerba added a commit to mmalerba/components that referenced this pull request Mar 28, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit to mmalerba/components that referenced this pull request Mar 28, 2017
mmalerba added a commit that referenced this pull request Apr 14, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit that referenced this pull request Apr 14, 2017
mmalerba added a commit that referenced this pull request Apr 20, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit that referenced this pull request Apr 20, 2017
mmalerba added a commit that referenced this pull request Apr 29, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit that referenced this pull request Apr 29, 2017
mmalerba added a commit that referenced this pull request May 5, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit that referenced this pull request May 5, 2017
mmalerba added a commit that referenced this pull request May 9, 2017
* date picker initial commit

* month view

* added month view functionality

* more month view tweaking

* started extracting common stuff to calendar-table.

* base month view on calendar table

* added year view

* add disclaimers

* addressed comments

* fix lint

* fixed aot and added comment

* started on tests

* calendar table tests

* tests for month and year view

* rebase on top of CalendarLocale & SimpleDate

* add some additional functionality to SimpleDate

* fix lint

* addressed comments

* add comment
mmalerba added a commit that referenced this pull request May 9, 2017
@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 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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