Skip to content

Commit

Permalink
Revert: feat(module:empty): add empty component
Browse files Browse the repository at this point in the history
  • Loading branch information
Wendell committed Jan 7, 2019
1 parent 7b14982 commit e4177d7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
21 changes: 19 additions & 2 deletions components/transfer/nz-transfer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
EventEmitter,
Input,
OnChanges,
OnDestroy,
OnInit,
Output,
QueryList,
SimpleChanges,
Expand All @@ -14,8 +16,10 @@ import {
} from '@angular/core';

import { of, Observable, Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

import { InputBoolean } from '../core/util/convert';
import { NzI18nService } from '../i18n/nz-i18n.service';

import { TransferCanMove, TransferChange, TransferItem, TransferSearchChange, TransferSelectChange } from './interface';
import { NzTransferListComponent } from './nz-transfer-list.component';
Expand All @@ -31,7 +35,8 @@ import { NzTransferListComponent } from './nz-transfer-list.component';
encapsulation : ViewEncapsulation.None,
changeDetection : ChangeDetectionStrategy.OnPush
})
export class NzTransferComponent implements OnChanges {
export class NzTransferComponent implements OnInit, OnChanges, OnDestroy {
private unsubscribe$ = new Subject<void>();
@ViewChildren(NzTransferListComponent)
private lists !: QueryList<NzTransferListComponent>;

Expand Down Expand Up @@ -148,7 +153,7 @@ export class NzTransferComponent implements OnChanges {

// #endregion

constructor(private cdr: ChangeDetectorRef) {
constructor(private cdr: ChangeDetectorRef, private i18n: NzI18nService) {
}

private markForCheckAllList(): void {
Expand All @@ -158,6 +163,13 @@ export class NzTransferComponent implements OnChanges {
this.lists.forEach(i => i.markForCheck());
}

ngOnInit(): void {
this.i18n.localeChange.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
this.locale = this.i18n.getLocaleData('Transfer');
this.markForCheckAllList();
});
}

ngOnChanges(changes: SimpleChanges): void {
if ('nzDataSource' in changes) {
this.splitDataSource();
Expand All @@ -167,4 +179,9 @@ export class NzTransferComponent implements OnChanges {
this.markForCheckAllList();
}
}

ngOnDestroy(): void {
this.unsubscribe$.next();
this.unsubscribe$.complete();
}
}
18 changes: 3 additions & 15 deletions components/transfer/nz-transfer.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { FormsModule } from '@angular/forms';

import { NzButtonModule } from '../button/nz-button.module';
import { NzCheckboxModule } from '../checkbox/nz-checkbox.module';
import { NzEmptyModule } from '../empty/nz-empty.module';
import { NzI18nModule } from '../i18n/nz-i18n.module';
import { NzIconModule } from '../icon/nz-icon.module';
import { NzInputModule } from '../input/nz-input.module';

Expand All @@ -13,20 +13,8 @@ import { NzTransferSearchComponent } from './nz-transfer-search.component';
import { NzTransferComponent } from './nz-transfer.component';

@NgModule({
imports : [
CommonModule,
FormsModule,
NzCheckboxModule,
NzButtonModule,
NzInputModule,
NzIconModule,
NzEmptyModule
],
declarations: [
NzTransferComponent,
NzTransferListComponent,
NzTransferSearchComponent
],
imports : [ CommonModule, FormsModule, NzCheckboxModule, NzButtonModule, NzInputModule, NzI18nModule, NzIconModule ],
declarations: [ NzTransferComponent, NzTransferListComponent, NzTransferSearchComponent ],
exports : [ NzTransferComponent ]
})
export class NzTransferModule {
Expand Down
13 changes: 12 additions & 1 deletion components/transfer/transfer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { fakeAsync, tick, ComponentFixture, TestBed } from '@angular/core/testin
import { By } from '@angular/platform-browser';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { of, Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { delay, map } from 'rxjs/operators';

import en_US from '../i18n/languages/en_US';
import { NzI18nService } from '../i18n/nz-i18n.service';
import { NzIconModule } from '../icon/nz-icon.module';
import { NzTransferComponent, NzTransferModule } from './index';
import { TransferCanMove, TransferItem } from './interface';
Expand Down Expand Up @@ -201,6 +203,15 @@ describe('transfer', () => {
it('should be custom footer', () => {
expect(pageObject.leftList.querySelector('#transfer-footer') != null).toBe(true);
});

it('#i18n', () => {
const tempFixture = TestBed.createComponent(TestTransferCustomRenderComponent);
tempFixture.detectChanges();
injector.get(NzI18nService).setLocale(en_US);
tempFixture.detectChanges();
const searchPhText = (tempFixture.debugElement.query(By.css('.ant-transfer-list-search')).nativeElement as HTMLElement).attributes.getNamedItem('placeholder').textContent;
expect(searchPhText).toBe(en_US.Transfer.searchPlaceholder);
});
});

describe('#canMove', () => {
Expand Down

0 comments on commit e4177d7

Please sign in to comment.