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

fix(module:*): patch all components with setDisabledState #188

Merged
merged 11 commits into from
Sep 4, 2017
10 changes: 10 additions & 0 deletions src/components/cascader/nz-cascader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,16 @@ export class NzCascaderComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
if (isDisabled) {
this._closeMenu();
this._addHostClass(`${this._prefixCls}-picker-disabled`);
} else {
this._removeHostClass(`${this._prefixCls}-picker-disabled`);
}
this.nzDisabled = isDisabled;
}

ngOnInit() {
// 设置第一列
if (this.nzOptions && this.nzOptions.length) {
Expand Down
4 changes: 4 additions & 0 deletions src/components/checkbox/nz-checkbox-group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export class NzCheckboxGroupComponent implements OnInit, AfterContentInit, Contr
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
this.nzDisabled = isDisabled;
}

ngOnInit() {
}
}
4 changes: 4 additions & 0 deletions src/components/checkbox/nz-checkbox.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ export class NzCheckboxComponent implements OnInit, ControlValueAccessor {
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
this.nzDisabled = isDisabled;
}

ngOnInit() {
this._render.addClass(this._el, `${this._prefixCls}-wrapper`);
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/datepicker/nz-datepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,4 +400,9 @@ export class NzDatePickerComponent implements ControlValueAccessor, OnInit {
registerOnTouched(fn: () => {}): void {
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
this._closeCalendar();
this.nzDisabled = isDisabled;
}
}
4 changes: 4 additions & 0 deletions src/components/input-number/nz-input-number.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,8 @@ export class NzInputNumberComponent implements ControlValueAccessor {
registerOnTouched(fn: () => {}): void {
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
this.nzDisabled = isDisabled;
}
}
4 changes: 4 additions & 0 deletions src/components/input/nz-input.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,8 @@ export class NzInputComponent implements AfterContentInit, ControlValueAccessor
registerOnTouched(fn: () => {}): void {
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
this.nzDisabled = isDisabled;
}
}
7 changes: 6 additions & 1 deletion src/components/radio/nz-radio-group.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ export class NzRadioGroupComponent implements OnInit, AfterContentInit, ControlV
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
this.radios.forEach((radio) => {
radio.nzDisabled = isDisabled;
});
}

ngOnInit() {
this._render.setElementClass(this._el, `${this._prefixCls}`, true);

}
}
4 changes: 4 additions & 0 deletions src/components/rate/nz-rate.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export class NzRateComponent implements OnInit, ControlValueAccessor {
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
this.nzDisabled = isDisabled;
}

ngOnInit() {
this.setClassMap();
this.setChildrenClassMap();
Expand Down
4 changes: 4 additions & 0 deletions src/components/select/nz-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,10 @@ export class NzSelectComponent implements OnInit, AfterContentInit, AfterContent
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
this.nzDisabled = isDisabled;
}

constructor(private _elementRef: ElementRef, private _renderer: Renderer2) {
this._el = this._elementRef.nativeElement;
}
Expand Down
6 changes: 6 additions & 0 deletions src/components/slider/nz-slider.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ export class NzSliderComponent implements ControlValueAccessor, OnInit, OnChange
registerOnTouched(fn) {
}

setDisabledState(isDisabled: boolean): void {
this.nzDisabled = isDisabled;
this.toggleDragDisabled(isDisabled);
this.setClassMap();
}

// |--------------------------------------------------------------------------------------------
// | Lifecycle hooks
// |--------------------------------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions src/components/switch/nz-switch.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ export class NzSwitchComponent implements OnInit, ControlValueAccessor {
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
this.nzDisabled = isDisabled;
}

ngOnInit() {
this.setClassMap();
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/time-picker/nz-timepicker-inner.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ export class NzTimePickerInnerComponent implements OnInit, ControlValueAccessor
this.onTouched = fn;
}

setDisabledState(isDisabled: boolean): void {
this.nzDisabled = isDisabled;
}

constructor(public _cdr: ChangeDetectorRef) {
}

Expand Down
5 changes: 5 additions & 0 deletions src/components/time-picker/nz-timepicker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,9 @@ export class NzTimePickerComponent extends NzTimePickerInnerComponent {
}
this._open = false;
}

setDisabledState(isDisabled: boolean): void {
this._closeCalendar();
this.nzDisabled = isDisabled;
}
}