Skip to content

Commit

Permalink
fix tslint
Browse files Browse the repository at this point in the history
fix titles i18n
  • Loading branch information
cipchk committed Mar 2, 2018
1 parent ae323b3 commit 1f3e0c3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 25 deletions.
1 change: 0 additions & 1 deletion components/transfer/demo/can-move.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { TransferCanMove, TransferItem, NzMessageService } from 'ng-zorro-antd';
template: `
<nz-transfer
[nzDataSource]="list"
[nzTitles]="['Source', 'Target']"
[canMove]="canMove"
(nzSelectChange)="select($event)"
(nzChange)="change($event)">
Expand Down
12 changes: 8 additions & 4 deletions components/transfer/nz-transfer-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import {
SimpleChanges,
TemplateRef
} from '@angular/core';

import { NzUpdateHostClassService } from '../core/services/update-host-class.service';
import { toBoolean } from '../core/util/convert';

import { TransferItem } from './interface';

@Component({
Expand All @@ -23,10 +25,12 @@ import { TransferItem } from './interface';
template : `
<div class="ant-transfer-list-header">
<label nz-checkbox [(ngModel)]="stat.checkAll" (ngModelChange)="onHandleSelectAll($event)"
[nzIndeterminate]="stat.checkHalf"></label><span class="ant-transfer-list-header-selected">
<span>{{ (stat.checkCount > 0 ? stat.checkCount + '/' : '') + stat.shownCount }} {{ dataSource.length > 1 ? itemsUnit : itemUnit }}</span>
<span *ngIf="titleText" class="ant-transfer-list-header-title">{{ titleText }}</span>
</span>
[nzIndeterminate]="stat.checkHalf">
<span class="ant-transfer-list-header-selected">
<span>{{ (stat.checkCount > 0 ? stat.checkCount + '/' : '') + stat.shownCount }} {{ dataSource.length > 1 ? itemsUnit : itemUnit }}</span>
<span *ngIf="titleText" class="ant-transfer-list-header-title">{{ titleText }}</span>
</span>
</label>
</div>
<div class="{{showSearch ? 'ant-transfer-list-body ant-transfer-list-body-with-search' : 'ant-transfer-list-body'}}"
[ngClass]="{'ant-transfer__nodata': stat.shownCount === 0}">
Expand Down
5 changes: 3 additions & 2 deletions components/transfer/nz-transfer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { of } from 'rxjs/observable/of';

import { toBoolean } from '../core/util/convert';
import { NzI18nService } from '../i18n/nz-i18n.service';
import { TransferItem, TransferCanMove, TransferChange, TransferItem, TransferSearchChange, TransferSelectChange } from './interface';

import { TransferCanMove, TransferChange, TransferItem, TransferSearchChange, TransferSelectChange } from './interface';

@Component({
selector : 'nz-transfer',
Expand Down Expand Up @@ -75,7 +76,7 @@ export class NzTransferComponent implements OnChanges {
// region: fields

@Input() nzDataSource: TransferItem[] = [];
@Input() nzTitles: string[] = this.i18n.translate('Transfer.titles').split(',');
@Input() nzTitles: string[] = ['', ''];
@Input() nzOperations: string[] = [];
@Input() nzListStyle: object;
@Input() nzItemUnit = this.i18n.translate('Transfer.itemUnit');
Expand Down
1 change: 1 addition & 0 deletions components/transfer/nz-transfer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { NzButtonModule } from '../button/nz-button.module';
import { NzCheckboxModule } from '../checkbox/nz-checkbox.module';
import { NzI18nModule } from '../i18n';
import { NzInputModule } from '../input/nz-input.module';

import { NzTransferListComponent } from './nz-transfer-list.component';
import { NzTransferSearchComponent } from './nz-transfer-search.component';
import { NzTransferComponent } from './nz-transfer.component';
Expand Down
47 changes: 29 additions & 18 deletions components/transfer/transfer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { Observable } from 'rxjs/Observable';
import { of } from 'rxjs/observable/of';
import { delay, map } from 'rxjs/operators';
import { NzTransferComponent, NzTransferModule } from '.';

import { NzTransferComponent, NzTransferModule } from './index';
import { TransferCanMove, TransferItem } from './interface';

const COUNT = 20;
const LEFTCOUNT = 2;

describe('transfer', () => {
let injector: Injector;
let fixture: ComponentFixture<TestTransferComponent>;
let fixture: ComponentFixture<TestTransferComponent | TestTransferCustomRenderComponent>;
let dl: DebugElement;
let instance: TestTransferComponent;
let pageObject: TransferPageObject;
Expand Down Expand Up @@ -81,18 +82,6 @@ describe('transfer', () => {
expect(pageObject.leftList.querySelectorAll('.ant-transfer-list-content-item').length).toBe(LEFTCOUNT);
});

it('should be from left to right when two verification', () => {
instance.canMove = (arg: TransferCanMove): Observable<TransferItem[]> => {
if (arg.direction === 'right' && arg.list.length > 0) arg.list.splice(0, 1);
return of(arg.list);
};
fixture.detectChanges();
pageObject.expectLeft(LEFTCOUNT)
.transfer('right', [ 0, 1 ])
.expectLeft(LEFTCOUNT - 1)
.expectRight(COUNT - LEFTCOUNT + 1);
});

it('should be checkbox is toggle select', () => {
expect(instance.comp.leftDataSource.filter(w => w.checked).length).toBe(0);
pageObject.checkItem('left', 0);
Expand Down Expand Up @@ -154,7 +143,32 @@ describe('transfer', () => {
});
});

describe('#issues', () => {
describe('#canMove', () => {
it('default', () => {
fixture = TestBed.createComponent(TestTransferCustomRenderComponent);
dl = fixture.debugElement;
instance = dl.componentInstance;
pageObject = new TransferPageObject();
fixture.detectChanges();
pageObject.expectLeft(LEFTCOUNT)
.transfer('right', 0)
.expectLeft(LEFTCOUNT - 1)
.expectRight(COUNT - LEFTCOUNT + 1);
});
it('should be from left to right when two verification', () => {
instance.canMove = (arg: TransferCanMove): Observable<TransferItem[]> => {
if (arg.direction === 'right' && arg.list.length > 0) arg.list.splice(0, 1);
return of(arg.list);
};
fixture.detectChanges();
pageObject.expectLeft(LEFTCOUNT)
.transfer('right', [ 0, 1 ])
.expectLeft(LEFTCOUNT - 1)
.expectRight(COUNT - LEFTCOUNT + 1);
});
});

xdescribe('#issues', () => {
xit('#996', () => {
const tempFixture = TestBed.createComponent(TestTransferCustomRenderComponent);
tempFixture.detectChanges();
Expand Down Expand Up @@ -269,15 +283,12 @@ class TestTransferComponent implements OnInit {
}

search(ret: {}): void {
console.log('nzSearchChange', ret);
}

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

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

Expand Down

0 comments on commit 1f3e0c3

Please sign in to comment.