Skip to content

Commit

Permalink
fix(module:table): fix table no data (#4947)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yadong Xie authored Mar 30, 2020
1 parent a6ecdb9 commit 7f7989e
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

__ngcc_entry_points__.json

# compiled output
dist/
/site/
tmp/
junit/
out-tsc/
/publish/
/lib/
integration/**/lib/
integration/**/*.ngfactory.ts
integration/**/*.ngsummary.json
Expand Down
30 changes: 15 additions & 15 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,24 @@ stages:
- script: npm run lint
dependsOn: env

- stage: integration
jobs:
- job: integration_cli
steps:
- task: Npm@1
inputs:
command: 'install'
- script: npm run integration-cli
- job: integration_webpack
steps:
- task: Npm@1
inputs:
command: 'install'
- script: npm run integration-webpack
#- stage: integration
# jobs:
# - job: integration_cli
# steps:
# - task: Npm@1
# inputs:
# command: 'install'
# - script: npm run integration-cli
# - job: integration_webpack
# steps:
# - task: Npm@1
# inputs:
# command: 'install'
# - script: npm run integration-webpack
# - job: integration_rollup
# steps:
# - task: Npm@1
# inputs:
# command: 'install'
# - script: npm run integration-rollup
dependsOn: env
# dependsOn: env
1 change: 1 addition & 0 deletions build-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ module.exports = {
scriptsDir: join(__dirname, 'scripts'),
outputDir: join(__dirname, 'dist'),
publishDir: join(__dirname, 'publish'),
libDir: join(__dirname, 'lib')
};
4 changes: 2 additions & 2 deletions components/table/src/table-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { Injectable, OnDestroy } from '@angular/core';
import { BehaviorSubject, combineLatest, EMPTY, Subject } from 'rxjs';
import { BehaviorSubject, combineLatest, Subject } from 'rxjs';
import { distinctUntilChanged, filter, map, switchMap, takeUntil } from 'rxjs/operators';
import { NzFilterFn, NzFilterValue, NzSortCompareFn, NzSortOrderType, NzTableDataType } from './table.types';

Expand Down Expand Up @@ -74,7 +74,7 @@ export class NzTableDataService implements OnDestroy {
switchMap(pagination => (pagination ? this.listOfFrontEndCurrentPageData$ : this.listOfData$))
);
total$ = this.frontPagination$.pipe(
switchMap(pagination => (pagination ? this.listOfDataAfterCalc$ : EMPTY)),
switchMap(pagination => (pagination ? this.listOfDataAfterCalc$ : this.listOfData$)),
map(list => list.length),
distinctUntilChanged()
);
Expand Down
19 changes: 12 additions & 7 deletions components/table/src/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { NzSafeAny } from 'ng-zorro-antd/core/types';
import { InputBoolean, measureScrollbar } from 'ng-zorro-antd/core/util';
import { PaginationItemRenderContext } from 'ng-zorro-antd/pagination';
import { BehaviorSubject, combineLatest, Subject } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { filter, map, takeUntil } from 'rxjs/operators';
import { NzTableDataService } from '../table-data.service';
import { NzTableStyleService } from '../table-style.service';
import { NzTableDataType, NzTableLayoutType, NzTablePaginationPositionType, NzTableSizeType } from '../table.types';
Expand Down Expand Up @@ -211,12 +211,17 @@ export class NzTableComponent implements OnInit, OnDestroy, OnChanges, AfterView
this.nzPageSizeChange.next(pageSize);
}
});
total$.pipe(takeUntil(this.destroy$)).subscribe(total => {
if (total !== this.nzTotal) {
this.nzTotal = total;
this.cdr.markForCheck();
}
});
total$
.pipe(
takeUntil(this.destroy$),
filter(() => this.nzFrontPagination)
)
.subscribe(total => {
if (total !== this.nzTotal) {
this.nzTotal = total;
this.cdr.markForCheck();
}
});
listOfCurrentPageData$.pipe(takeUntil(this.destroy$)).subscribe(data => {
this.data = data;
this.nzCurrentPageDataChange.next(data);
Expand Down
2 changes: 1 addition & 1 deletion integration/angular-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"lint": "echo \"Error: no lint... minimal project\" && exit 1",
"e2e": "echo \"Error: no e2e... minimal project\" && exit 1",
"preintegration": "npm run setup && npm install --ignore-scripts",
"integration": "ng build --prod --build-optimizer"
"integration": "ng build --prod"
},
"private": true,
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions integration/angular-cli/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { NzButtonModule } from 'ng-zorro-antd/button';

import { AppComponent } from './app.component';

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule.withServerTransition({ appId: 'zorroApp' }), NgZorroAntdModule],
imports: [BrowserModule.withServerTransition({ appId: 'zorroApp' }), NzButtonModule],
providers: [],
bootstrap: [AppComponent]
})
Expand Down
4 changes: 2 additions & 2 deletions integration/rollup/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { NzButtonModule } from 'ng-zorro-antd/button';

import { AppComponent } from './app.component';

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, NgZorroAntdModule],
imports: [BrowserModule, NzButtonModule],
providers: [],
bootstrap: [AppComponent]
})
Expand Down
4 changes: 2 additions & 2 deletions integration/webpack/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { NzButtonModule } from 'ng-zorro-antd/button';

import { AppComponent } from './app.component';

@NgModule({
declarations: [AppComponent],
imports: [BrowserModule, NgZorroAntdModule],
imports: [BrowserModule, NzButtonModule],
providers: [],
bootstrap: [AppComponent]
})
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"resize-observer-polyfill": "^1.5.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.900.0",
"@angular-devkit/build-ng-packagr": "~0.900.0",
"@angular-devkit/build-angular": "~0.901.0",
"@angular-devkit/build-ng-packagr": "~0.901.0",
"@angular-devkit/core": "^9.0.0",
"@angular-devkit/schematics": "^9.0.0",
"@angular/animations": "^9.0.0",
Expand Down Expand Up @@ -97,7 +97,7 @@
"minimist": "^1.2.0",
"monaco-editor": "^0.17.1",
"ng-packagr": "^9.0.0",
"ngx-color": "^4.0.0",
"ngx-color": "^5.0.0",
"node-prismjs": "^0.1.2",
"parse5": "^5.1.1",
"prettier": "^2.0.2",
Expand All @@ -115,9 +115,9 @@
"tsickle": "^0.38.1",
"tslib": "^1.10.0",
"tslint": "~5.18.0",
"typescript": "~3.8.0",
"typescript": "~3.8.3",
"yaml-front-matter": "^4.0.0",
"zone.js": "~0.10.2"
"zone.js": "~0.10.3"
},
"lint-staged": {
"components/**/*.{html,ts}": [
Expand Down
1 change: 1 addition & 0 deletions scripts/build-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface BuildConfig {
scriptsDir: string;
outputDir: string;
publishDir: string;
libDir: string;
}

const BUILD_CONFIG_FILENAME = 'build-config.js';
Expand Down
9 changes: 8 additions & 1 deletion scripts/gulp/tasks/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@ task('library:copy-resources', () => {
);
});

task('build:library', series('library:build-zorro', parallel('library:compile-less', 'library:copy-resources', 'build:schematics')));
// Copies files without ngcc to lib folder.
task('library:copy-libs', () => {
return src([join(buildConfig.publishDir, '**/*')]).pipe(
dest(join(buildConfig.libDir))
);
});

task('build:library', series('library:build-zorro', parallel('library:compile-less', 'library:copy-resources', 'build:schematics', 'library:copy-libs')));

0 comments on commit 7f7989e

Please sign in to comment.