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): wire up selected value propagation #3330

Merged
merged 8 commits into from
Mar 3, 2017

Conversation

mmalerba
Copy link
Contributor

as of this PR we have a bare minimum working datepicker \o/

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Feb 27, 2017
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, but needs tests for using with form directives like ngModel or formControl.

private _value: SimpleDate;

// Implemented as part of ControlValueAccessor
writeValue(value: SimpleDate) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Return types

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess... I don't see much value in the : void

}
set value(value: any) {
this._value = this._locale.parseDate(value);
let stringValue = this._value == null ? '' : this._locale.formatDate(this._value);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: const?

],
exports: [
MdCalendar,
MdCalendarTable,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you intend for the CalendarTable, MonthView, etc. to be used externally? Seems like you can remove them from the exports list.

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

}

@Input()
get value() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: return type?

@mmalerba
Copy link
Contributor Author

addressed comments, PTAL

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.

Requesting a few more tests


ngAfterContentInit() {
if (this._datepicker) {
this._datepicker.selectedChanged.subscribe((selected: SimpleDate) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you unsubscribe from this anywhere?


@Component({
template: `
<input [mdDatepicker]="d" [value]="'1/1/2020'">
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: might be easier to scan if it's just value="1/1/2020"


expect(testComponent.selected).toEqual(selected);
expect(testComponent.datepickerInput.value).toEqual(selected);
}));
Copy link
Contributor

Choose a reason for hiding this comment

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

We should add tests that ensure that touched, disabled, and dirty still work, given that we're re-implementing them in the value accessor

@mmalerba
Copy link
Contributor Author

mmalerba commented Mar 2, 2017

comments addressed

testComponent.datepicker.selected = new SimpleDate(2017, 0, 1);
detectModelChanges(fixture);

expect(inputEl.classList).toContain('ng-dirty');
Copy link
Contributor

Choose a reason for hiding this comment

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

It should actually not mark the control dirty based on programmatic changes. Dirtiness is a reflection of UI changes only (what the user does). We're probably calling the change callback somewhere we shouldn't be.

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 property isn't really intended to be set programmatically, it's set when the user clicks a calendar cell. Made it internal so people don't try to call it, though...

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.

LGTM

@kara kara added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Mar 3, 2017
@mmalerba mmalerba merged commit 9c4299a into angular:datepicker Mar 3, 2017
mmalerba added a commit to mmalerba/components that referenced this pull request Mar 6, 2017
* enable value propagation through various components & directives

* add tests

* fix lint

* addressed comments

* addressed feedback

* fix lint

* make datepicker selected property internal

* add test for pristine after ngModel change
mmalerba added a commit that referenced this pull request Mar 17, 2017
* enable value propagation through various components & directives

* add tests

* fix lint

* addressed comments

* addressed feedback

* fix lint

* make datepicker selected property internal

* add test for pristine after ngModel change
mmalerba added a commit to mmalerba/components that referenced this pull request Mar 28, 2017
* enable value propagation through various components & directives

* add tests

* fix lint

* addressed comments

* addressed feedback

* fix lint

* make datepicker selected property internal

* add test for pristine after ngModel change
mmalerba added a commit that referenced this pull request Apr 14, 2017
* enable value propagation through various components & directives

* add tests

* fix lint

* addressed comments

* addressed feedback

* fix lint

* make datepicker selected property internal

* add test for pristine after ngModel change
mmalerba added a commit that referenced this pull request Apr 20, 2017
* enable value propagation through various components & directives

* add tests

* fix lint

* addressed comments

* addressed feedback

* fix lint

* make datepicker selected property internal

* add test for pristine after ngModel change
mmalerba added a commit that referenced this pull request Apr 29, 2017
* enable value propagation through various components & directives

* add tests

* fix lint

* addressed comments

* addressed feedback

* fix lint

* make datepicker selected property internal

* add test for pristine after ngModel change
mmalerba added a commit that referenced this pull request May 5, 2017
* enable value propagation through various components & directives

* add tests

* fix lint

* addressed comments

* addressed feedback

* fix lint

* make datepicker selected property internal

* add test for pristine after ngModel change
mmalerba added a commit that referenced this pull request May 9, 2017
* enable value propagation through various components & directives

* add tests

* fix lint

* addressed comments

* addressed feedback

* fix lint

* make datepicker selected property internal

* add test for pristine after ngModel change
@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
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