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:transfer): fix only filtered data in nzRenderList #6169

Merged
merged 2 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/transfer/demo/tree-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import { NzTreeComponent } from 'ng-zorro-antd/tree';
>
<span class="ant-tree-checkbox-inner"></span>
</span>
<span (click)="checkBoxChange(node, onItemSelect)" class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open">{{
node.title
}}</span>
<span (click)="checkBoxChange(node, onItemSelect)" class="ant-tree-node-content-wrapper ant-tree-node-content-wrapper-open">
{{ node.title }}
</span>
</ng-template>
</nz-tree>
</ng-template>
Expand Down
46 changes: 24 additions & 22 deletions components/transfer/transfer-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,23 @@ import { TransferDirection, TransferItem } from './interface';
template: `
<ng-template #defaultRenderList>
<ul *ngIf="stat.shownCount > 0" class="ant-transfer-list-content">
<div class="LazyLoad" *ngFor="let item of dataSource">
<li
*ngIf="!item.hide"
(click)="onItemSelect(item)"
class="ant-transfer-list-content-item"
[ngClass]="{ 'ant-transfer-list-content-item-disabled': disabled || item.disabled }"
<li
*ngFor="let item of validData"
(click)="onItemSelect(item)"
class="ant-transfer-list-content-item"
[ngClass]="{ 'ant-transfer-list-content-item-disabled': disabled || item.disabled }"
>
<label
nz-checkbox
[nzChecked]="item.checked"
(nzCheckedChange)="onItemSelect(item)"
(click)="$event.stopPropagation()"
[nzDisabled]="disabled || item.disabled"
>
<label
nz-checkbox
[nzChecked]="item.checked"
(nzCheckedChange)="onItemSelect(item)"
(click)="$event.stopPropagation()"
[nzDisabled]="disabled || item.disabled"
>
<ng-container *ngIf="!render; else renderContainer">{{ item.title }}</ng-container>
<ng-template #renderContainer [ngTemplateOutlet]="render" [ngTemplateOutletContext]="{ $implicit: item }"></ng-template>
</label>
</li>
</div>
<ng-container *ngIf="!render; else renderContainer">{{ item.title }}</ng-container>
<ng-template #renderContainer [ngTemplateOutlet]="render" [ngTemplateOutletContext]="{ $implicit: item }"></ng-template>
</label>
</li>
</ul>
<div *ngIf="stat.shownCount === 0" class="ant-transfer-list-body-not-found">
<nz-embed-empty [nzComponentName]="'transfer'" [specificContent]="notFoundContent"></nz-embed-empty>
Expand All @@ -59,7 +57,7 @@ import { TransferDirection, TransferItem } from './interface';
></label>
<span class="ant-transfer-list-header-selected">
<span>
{{ (stat.checkCount > 0 ? stat.checkCount + '/' : '') + stat.shownCount }} {{ dataSource.length > 1 ? itemsUnit : itemUnit }}
{{ (stat.checkCount > 0 ? stat.checkCount + '/' : '') + stat.shownCount }} {{ validData.length > 1 ? itemsUnit : itemUnit }}
</span>
<span *ngIf="titleText" class="ant-transfer-list-header-title">{{ titleText }}</span>
</span>
Expand All @@ -84,7 +82,7 @@ import { TransferDirection, TransferItem } from './interface';
*ngTemplateOutlet="
renderList;
context: {
$implicit: dataSource,
$implicit: validData,
direction: direction,
disabled: disabled,
onItemSelectAll: onItemSelectAll,
Expand Down Expand Up @@ -140,6 +138,10 @@ export class NzTransferListComponent {
shownCount: 0
};

get validData(): TransferItem[] {
return this.dataSource.filter(w => !w.hide);
}

onItemSelect = (item: TransferItem) => {
if (this.disabled || item.disabled) {
return;
Expand All @@ -163,7 +165,7 @@ export class NzTransferListComponent {
private updateCheckStatus(): void {
const validCount = this.dataSource.filter(w => !w.disabled).length;
this.stat.checkCount = this.dataSource.filter(w => w.checked && !w.disabled).length;
this.stat.shownCount = this.dataSource.filter(w => !w.hide).length;
this.stat.shownCount = this.validData.length;
this.stat.checkAll = validCount > 0 && validCount === this.stat.checkCount;
this.stat.checkHalf = this.stat.checkCount > 0 && !this.stat.checkAll;
}
Expand All @@ -177,7 +179,7 @@ export class NzTransferListComponent {
this.dataSource.forEach(item => {
item.hide = value.length > 0 && !this.matchFilter(value, item);
});
this.stat.shownCount = this.dataSource.filter(w => !w.hide).length;
this.stat.shownCount = this.validData.length;
this.filterChange.emit({ direction: this.direction, value });
}

Expand Down