Skip to content

Commit

Permalink
fix(module:transfer): 1.fix the "checkAll" status not updated 2.chang…
Browse files Browse the repository at this point in the history
…e "ArrayObservable.of" to "of" (#834)
  • Loading branch information
wilsoncook authored Jan 1, 2018
1 parent 29318db commit 9c023fa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/components/transfer/nz-transfer-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ export class NzTransferListComponent implements OnChanges, OnInit, DoCheck {
}
});

// ngModelChange 事件内对状态的变更会无效,因此使用延迟改变执行顺序
setTimeout(() => this.updateCheckStatus());

// // ngModelChange 事件内对状态的变更会无效,因此使用延迟改变执行顺序
// setTimeout(() => this.updateCheckStatus());
this.updateCheckStatus();
this.handleSelectAll.emit(status);
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/transfer/nz-transfer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
ViewEncapsulation
} from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { ArrayObservable } from 'rxjs/observable/ArrayObservable';
import { of } from 'rxjs/observable/of';
import { NzLocaleService } from '../locale/index';
import { toBoolean } from '../util/convert';
import { TransferItem } from './item';
Expand Down Expand Up @@ -109,7 +109,7 @@ export class NzTransferComponent implements OnChanges {
@Input() nzListStyle: object;
@Input() nzItemUnit = this._locale.translate('Transfer.itemUnit');
@Input() nzItemsUnit = this._locale.translate('Transfer.itemsUnit');
@Input() canMove: (arg: TransferCanMove) => Observable<TransferItem[]> = (arg: TransferCanMove) => ArrayObservable.of(arg.list);
@Input() canMove: (arg: TransferCanMove) => Observable<TransferItem[]> = (arg: TransferCanMove) => of(arg.list);
@ContentChild('render') render: TemplateRef<void>;
@ContentChild('footer') footer: TemplateRef<void>;

Expand Down
10 changes: 5 additions & 5 deletions src/components/transfer/nz-transfer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// tslint:disable:
import { Component, DebugElement, ViewChild } from '@angular/core';
import { async, fakeAsync, tick, ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { ArrayObservable } from 'rxjs/observable/ArrayObservable';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { NzButtonModule } from '../button/nz-button.module';
import { NzTransferModule } from '../ng-zorro-antd.module';
import { TransferItem } from './item';
import { NzTransferComponent } from './nz-transfer.component';
import { NzTransferComponent, TransferCanMove } from './nz-transfer.component';

const DEFAULT = `
<nz-transfer
Expand Down Expand Up @@ -223,10 +223,10 @@ class TestTransferComponent {
change(): void { }
search(): void { }
reload(): void { }
canMove(arg: any) {
canMove(arg: TransferCanMove): Observable<TransferItem[]> {
if (arg.direction === 'right' && arg.list.length > 0) arg.list.splice(0, 1);
// or
// if (arg.direction === 'right' && arg.list.length > 0) delete arg.list[0];
return ArrayObservable.of(arg.list);
return of(arg.list);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { ArrayObservable } from 'rxjs/observable/ArrayObservable';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { delay } from 'rxjs/operators';
import { NzMessageService } from '../../../index.showcase';
import { TransferItem } from '../../components/transfer/item';
import { TransferCanMove } from '../../components/transfer/nz-transfer.component';

@Component({
selector: 'nz-demo-transfer-can-move',
Expand All @@ -16,8 +19,9 @@ import { NzMessageService } from '../../../index.showcase';
`
})
export class NzDemoTransferCanMoveComponent implements OnInit {
list: any[] = [];
ngOnInit() {
list: TransferItem[] = [];

ngOnInit(): void {
for (let i = 0; i < 20; i++) {
this.list.push({
key: i.toString(),
Expand All @@ -29,18 +33,18 @@ export class NzDemoTransferCanMoveComponent implements OnInit {
[ 2, 3 ].forEach(idx => this.list[idx].direction = 'right');
}

canMove(arg: any) {
canMove(arg: TransferCanMove): Observable<TransferItem[]> {
if (arg.direction === 'right' && arg.list.length > 0) arg.list.splice(0, 1);
// or
// if (arg.direction === 'right' && arg.list.length > 0) delete arg.list[0];
return ArrayObservable.of(arg.list).pipe(delay(1000));
return of(arg.list).pipe(delay(1000));
}

select(ret: any) {
select(ret: {}): void {
console.log('nzSelectChange', ret);
}

change(ret: any) {
change(ret: {}): void {
console.log('nzChange', ret);
}
}

0 comments on commit 9c023fa

Please sign in to comment.