Skip to content

Commit

Permalink
Added host bindings and changed delegation logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwshinjwshin committed Jun 27, 2017
1 parent c2e0ecb commit fce4e69
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 1 addition & 3 deletions src/lib/datepicker/datepicker-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const MD_DATEPICKER_VALIDATORS: any = {
'[attr.aria-owns]': '_datepicker?.id',
'[attr.min]': 'min ? _dateAdapter.getISODateString(min) : null',
'[attr.max]': 'max ? _dateAdapter.getISODateString(max) : null',
'[disabled]': 'disabled',
'(input)': '_onInput($event.target.value)',
'(blur)': '_onTouched()',
'(keydown)': '_onKeydown($event)',
Expand Down Expand Up @@ -130,9 +131,6 @@ export class MdDatepickerInput<D> implements AfterContentInit, ControlValueAcces
get disabled() { return this._disabled; }
set disabled(value: any) {
this._disabled = coerceBooleanProperty(value);
if (this._datepicker.disabled === undefined) {
this._datepicker.disabled = this._disabled;
}
}
private _disabled: boolean;

Expand Down
14 changes: 13 additions & 1 deletion src/lib/datepicker/datepicker-toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import {ChangeDetectionStrategy, Component, Input, ViewEncapsulation} from '@angular/core';
import {MdDatepicker} from './datepicker';
import {MdDatepickerIntl} from './datepicker-intl';
import {coerceBooleanProperty} from '@angular/cdk';


@Component({
Expand All @@ -20,6 +21,7 @@ import {MdDatepickerIntl} from './datepicker-intl';
'type': 'button',
'class': 'mat-datepicker-toggle',
'[attr.aria-label]': '_intl.openCalendarLabel',
'[disabled]': 'disabled',
'(click)': '_open($event)',
},
encapsulation: ViewEncapsulation.None,
Expand All @@ -33,10 +35,20 @@ export class MdDatepickerToggle<D> {
get _datepicker() { return this.datepicker; }
set _datepicker(v: MdDatepicker<D>) { this.datepicker = v; }

/** Whether the toggle button is disabled. */
@Input()
get disabled() {
return this._disabled === undefined ? this.datepicker.disabled : this._disabled;
}
set disabled(value) {
this._disabled = coerceBooleanProperty(value);
}
private _disabled: boolean;

constructor(public _intl: MdDatepickerIntl) {}

_open(event: Event): void {
if (this.datepicker && !this.datepicker.disabled) {
if (this.datepicker && !this._disabled) {
this.datepicker.open();
event.stopPropagation();
}
Expand Down
7 changes: 3 additions & 4 deletions src/lib/datepicker/datepicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,11 @@ export class MdDatepicker<D> implements OnDestroy {

/** Whether the datepicker pop-up should be disabled. */
@Input()
get disabled() { return this._disabled; }
get disabled() {
return this._disabled === undefined ? this._datepickerInput.disabled : this._disabled;
}
set disabled(value: any) {
this._disabled = coerceBooleanProperty(value);
if (this._disabled === undefined) {
this._disabled = this._datepickerInput.disabled;
}
}
private _disabled: boolean;

Expand Down

0 comments on commit fce4e69

Please sign in to comment.