Skip to content

Commit

Permalink
fix(module:*): patch all components with setDisabledState (#188)
Browse files Browse the repository at this point in the history
* fix(module:input): fix disable bug in reactive form (#134)

* fix(module:switch): fix disable bug in reactive form

* fix(module:slider): fix disable bug in reactive form

* fix(module:select): fix disable bug in reactive form

* fix(module:input-number): fix disable bug in reactive form

* fix(module:timepicker): fix disable bug in reactive form

* fix(module:datepicker): fix disable bug in reactive form

* fix(module:rate): fix disable bug in reactive form

* fix(module:radio): fix radio-group disable bug in reactive form

* fix(module:checkbox): fix checkbox & checkbox-group disable bug in reactive form

* fix(module:cascader): fix cascader disable bug in reactive form
  • Loading branch information
Zhaoming Li authored and vthinkxie committed Sep 4, 2017
1 parent 23bdc08 commit 69b8979
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 1 deletion.
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 @@ -191,4 +191,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;
}
}

0 comments on commit 69b8979

Please sign in to comment.