From 7f7989eff89ef4bacd0e2b23696422b7a50daf15 Mon Sep 17 00:00:00 2001 From: Yadong Xie Date: Mon, 30 Mar 2020 13:10:24 +0800 Subject: [PATCH] fix(module:table): fix table no data (#4947) --- .gitignore | 3 ++ azure-pipelines.yml | 30 +++++++++---------- build-config.js | 1 + components/table/src/table-data.service.ts | 4 +-- components/table/src/table/table.component.ts | 19 +++++++----- integration/angular-cli/package.json | 2 +- integration/angular-cli/src/app/app.module.ts | 4 +-- integration/rollup/src/app/app.module.ts | 4 +-- integration/webpack/src/app/app.module.ts | 4 +-- package.json | 10 +++---- scripts/build-config.ts | 1 + scripts/gulp/tasks/library.ts | 9 +++++- 12 files changed, 54 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index 24c111b45bb..4dfa770d567 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # See http://help.github.com/ignore-files/ for more about ignoring files. +__ngcc_entry_points__.json + # compiled output dist/ /site/ @@ -7,6 +9,7 @@ tmp/ junit/ out-tsc/ /publish/ +/lib/ integration/**/lib/ integration/**/*.ngfactory.ts integration/**/*.ngsummary.json diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ba9c1344c4e..4ff58b9cc85 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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 diff --git a/build-config.js b/build-config.js index 917eca5eba2..466b47d827a 100644 --- a/build-config.js +++ b/build-config.js @@ -10,4 +10,5 @@ module.exports = { scriptsDir: join(__dirname, 'scripts'), outputDir: join(__dirname, 'dist'), publishDir: join(__dirname, 'publish'), + libDir: join(__dirname, 'lib') }; \ No newline at end of file diff --git a/components/table/src/table-data.service.ts b/components/table/src/table-data.service.ts index cdb8ef4d7cc..5a2cfa9fe72 100644 --- a/components/table/src/table-data.service.ts +++ b/components/table/src/table-data.service.ts @@ -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'; @@ -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() ); diff --git a/components/table/src/table/table.component.ts b/components/table/src/table/table.component.ts index c0981df09bf..50cc7308f78 100644 --- a/components/table/src/table/table.component.ts +++ b/components/table/src/table/table.component.ts @@ -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'; @@ -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); diff --git a/integration/angular-cli/package.json b/integration/angular-cli/package.json index 9dc6c275a13..7652949df0a 100644 --- a/integration/angular-cli/package.json +++ b/integration/angular-cli/package.json @@ -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": { diff --git a/integration/angular-cli/src/app/app.module.ts b/integration/angular-cli/src/app/app.module.ts index f57bab89ce0..61b11a16b00 100644 --- a/integration/angular-cli/src/app/app.module.ts +++ b/integration/angular-cli/src/app/app.module.ts @@ -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] }) diff --git a/integration/rollup/src/app/app.module.ts b/integration/rollup/src/app/app.module.ts index fd418f067b7..9b1a00f941d 100644 --- a/integration/rollup/src/app/app.module.ts +++ b/integration/rollup/src/app/app.module.ts @@ -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] }) diff --git a/integration/webpack/src/app/app.module.ts b/integration/webpack/src/app/app.module.ts index fd418f067b7..9b1a00f941d 100644 --- a/integration/webpack/src/app/app.module.ts +++ b/integration/webpack/src/app/app.module.ts @@ -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] }) diff --git a/package.json b/package.json index a21623d735e..b0c451ae6b0 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", @@ -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}": [ diff --git a/scripts/build-config.ts b/scripts/build-config.ts index a6586bf4dcc..864d684f1b2 100644 --- a/scripts/build-config.ts +++ b/scripts/build-config.ts @@ -8,6 +8,7 @@ export interface BuildConfig { scriptsDir: string; outputDir: string; publishDir: string; + libDir: string; } const BUILD_CONFIG_FILENAME = 'build-config.js'; diff --git a/scripts/gulp/tasks/library.ts b/scripts/gulp/tasks/library.ts index e970e519833..998129165ce 100644 --- a/scripts/gulp/tasks/library.ts +++ b/scripts/gulp/tasks/library.ts @@ -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')));