Skip to content

Commit bb6dc07

Browse files
authored
Fix issue with saving state (#137)
* upgrade to angular 13 * clean state before saving * bump version
1 parent acd6e15 commit bb6dc07

File tree

11 files changed

+36
-75
lines changed

11 files changed

+36
-75
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ speed-measure-plugin.json
3232
.history/*
3333

3434
# misc
35+
/.angular/cache
3536
/.sass-cache
3637
/connect.lock
3738
/coverage

angular.json

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -97,18 +97,6 @@
9797
"src/assets"
9898
]
9999
}
100-
},
101-
"lint": {
102-
"builder": "@angular-devkit/build-angular:tslint",
103-
"options": {
104-
"tsConfig": [
105-
"src/tsconfig.app.json",
106-
"src/tsconfig.spec.json"
107-
],
108-
"exclude": [
109-
"**/node_modules/**"
110-
]
111-
}
112100
}
113101
}
114102
},
@@ -128,15 +116,6 @@
128116
"devServerTarget": "material-extensions:serve:production"
129117
}
130118
}
131-
},
132-
"lint": {
133-
"builder": "@angular-devkit/build-angular:tslint",
134-
"options": {
135-
"tsConfig": "e2e/tsconfig.e2e.json",
136-
"exclude": [
137-
"**/node_modules/**"
138-
]
139-
}
140119
}
141120
}
142121
},
@@ -165,18 +144,6 @@
165144
"tsConfig": "projects/table-builder/tsconfig.spec.json",
166145
"karmaConfig": "projects/table-builder/karma.conf.js"
167146
}
168-
},
169-
"lint": {
170-
"builder": "@angular-devkit/build-angular:tslint",
171-
"options": {
172-
"tsConfig": [
173-
"projects/table-builder/tsconfig.lib.json",
174-
"projects/table-builder/tsconfig.spec.json"
175-
],
176-
"exclude": [
177-
"**/node_modules/**"
178-
]
179-
}
180147
}
181148
}
182149
}

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,34 @@
1111
},
1212
"private": true,
1313
"dependencies": {
14-
"@angular/animations": "12.1.1",
15-
"@angular/cdk": "12.1.1",
16-
"@angular/common": "12.1.1",
17-
"@angular/compiler": "12.1.1",
18-
"@angular/core": "12.1.1",
19-
"@angular/forms": "12.1.1",
20-
"@angular/material": "12.1.1",
21-
"@angular/platform-browser": "12.1.1",
22-
"@angular/platform-browser-dynamic": "12.1.1",
23-
"@angular/router": "12.1.1",
14+
"@angular/animations": "13.0.0",
15+
"@angular/cdk": "13.0.0",
16+
"@angular/common": "13.0.0",
17+
"@angular/compiler": "13.0.0",
18+
"@angular/core": "13.0.0",
19+
"@angular/forms": "13.0.0",
20+
"@angular/material": "13.0.0",
21+
"@angular/platform-browser": "13.0.0",
22+
"@angular/platform-browser-dynamic": "13.0.0",
23+
"@angular/router": "13.0.0",
2424
"@ngrx/effects": "^12.2.0",
2525
"@ngrx/store": "^12.2.0",
2626
"@ngrx/store-devtools": "^12.2.0",
2727
"@ngrx/component-store": "^12.2.0",
2828
"@ngrx/component": "12.2.0",
2929
"core-js": "3.6.5",
3030
"immutability-helper": "^3.1.1",
31-
"rxjs": "6.6.6",
31+
"rxjs": "7.4.0",
3232
"tslib": "^2.3.0",
3333
"uuid4": "^2.0.2",
3434
"zone.js": "~0.11.4",
3535
"lodash": "^4.17.21"
3636
},
3737
"devDependencies": {
38-
"@angular-devkit/build-angular": "~12.1.1",
39-
"@angular/cli": "12.1.1",
40-
"@angular/compiler-cli": "12.1.1",
41-
"@angular/language-service": "12.1.1",
38+
"@angular-devkit/build-angular": "~13.0.1",
39+
"@angular/cli": "13.0.1",
40+
"@angular/compiler-cli": "13.0.0",
41+
"@angular/language-service": "13.0.0",
4242
"@types/jasmine": "~3.6.0",
4343
"@types/jasminewd2": "2.0.8",
4444
"@types/lodash": "^4.14.168",
@@ -51,10 +51,10 @@
5151
"karma-coverage-istanbul-reporter": "~3.0.3",
5252
"karma-jasmine": "~4.0.0",
5353
"karma-jasmine-html-reporter": "^1.5.0",
54-
"ng-packagr": "^12.1.0",
54+
"ng-packagr": "^13.0.3",
5555
"protractor": "~7.0.0",
5656
"ts-node": "9.0.0",
5757
"tslint": "~6.1.3",
58-
"typescript": "~4.3.5"
58+
"typescript": "~4.4.4"
5959
}
6060
}

projects/table-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mx-table-builder",
3-
"version": "0.4.29",
3+
"version": "0.5.0",
44
"peerDependencies": {
55
"@angular/common": "~12.1.1",
66
"@angular/core": "~12.1.1",

projects/table-builder/src/lib/components/table-container/table-container.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<ng-container multiSort >
22
<ng-container >
3-
3+
44
<div class="header-wrapper" >
55
<div class="title">
66
<ng-content select=".tb-header-title" *ngIf="(!(collapseHeader$ | async)) || (state.tableSettings$ | async).showTitleWhenHeaderCollapsed"></ng-content>
@@ -30,7 +30,7 @@
3030
</mat-icon>
3131
</div>
3232
</div>
33-
33+
3434
<div style="clear: both;">
3535
<tb-generic-table
3636
[rows]='customRows'
@@ -55,7 +55,7 @@
5555
</ng-container>
5656
</ng-template>
5757
<ng-template #headerMenuExtra>
58-
<button mat-menu-item (click)="state.resetState();OnStateReset.next()" >
58+
<button mat-menu-item (click)="state.resetState();OnStateReset.next(null)" >
5959
<mat-icon color="primary">autorenew</mat-icon>
6060
<span>Reset table</span>
6161
</button>
@@ -72,7 +72,7 @@
7272
<span>Choose Profile</span>
7373
</button>
7474
</ng-container>
75-
75+
7676
<mat-menu #savedNames='matMenu' panelClass='wide-menu' >
7777
<button mat-menu-item clickSubject #add='clickSubject' >
7878
<mat-icon>add</mat-icon>

projects/table-builder/src/lib/components/table-container/table-container.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from '@angular/core';
1111
import { combineLatest, Observable, ReplaySubject } from 'rxjs';
1212
import { ArrayAdditional, FieldType, MetaData } from '../../interfaces/report-def';
13-
import { distinctUntilChanged, filter, first, map, shareReplay, switchMap, withLatestFrom } from 'rxjs/operators';
13+
import { distinctUntilChanged, filter, first, last, map, shareReplay, switchMap, withLatestFrom } from 'rxjs/operators';
1414
import { TableBuilder } from '../../classes/table-builder';
1515
import { MatRowDef } from '@angular/material/table';
1616
import { CustomCellDirective } from '../../directives';
@@ -71,7 +71,7 @@ import { cloneDeep } from 'lodash';
7171
@Inject(TableBuilderConfigToken) private config: TableBuilderConfig,
7272
private store: Store<{globalStorageState: GlobalStorageState}>
7373
) {
74-
this.state.onLast( finalState => {
74+
this.state.on( this.state.getSavableState().pipe(last()), finalState => {
7575
if(this.tableId) {
7676
this.store.dispatch(setLocalProfile({key:this.tableId,value: finalState}));
7777
}
@@ -113,7 +113,7 @@ import { cloneDeep } from 'lodash';
113113
this.state.getSavableState().pipe(
114114
first()
115115
).subscribe( tableState => {
116-
this.OnSaveState.next();
116+
this.OnSaveState.next(null);
117117
this.store.dispatch(setLocalProfile({ key: this.tableId, value:tableState, persist: true} ));
118118
});
119119
}
@@ -159,10 +159,9 @@ import { cloneDeep } from 'lodash';
159159
return meta;
160160
}
161161

162-
cleanStateOnInitialLoad = ()=> (obs:Observable<PersistedTableState>) =>
162+
cleanStateOnInitialLoad = ()=> (obs:Observable<PersistedTableState>) =>
163163
combineLatest([obs.pipe(addTimeStamp()), this.tableBuilder.metaData$]).pipe(
164164
distinctUntilChanged(([state],[state2])=>state.index === state2.index),
165-
166165
map(([{value:state},metas],index)=>{
167166
if (index === 0) {
168167

projects/table-builder/src/test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ declare const require: any;
1414
// First, initialize the Angular testing environment.
1515
getTestBed().initTestEnvironment(
1616
BrowserDynamicTestingModule,
17-
platformBrowserDynamicTesting()
17+
platformBrowserDynamicTesting(), {
18+
teardown: { destroyAfterEach: false }
19+
}
1820
);
1921
// Then we find all the tests.
2022
const context = require.context('./', true, /\.spec\.ts$/);

projects/table-builder/tsconfig.lib.prod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
"declarationMap": false
55
},
66
"angularCompilerOptions": {
7-
"enableIvy": false
7+
"compilationMode": "partial"
88
}
99
}

src/custom-theme.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11

22
// Custom Theming for Angular Material
33
// For more information: https://material.angular.io/guide/theming
4-
@use '~@angular/material' as mat;
5-
@import '~@angular/material/theming';
4+
@use '@angular/material' as mat;
5+
@import '@angular/material/theming';
66
// Plus imports for other components in your app.
77

88
// Include the common styles for Angular Material. We include this here so that you only

src/polyfills.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@
1818
* BROWSER POLYFILLS
1919
*/
2020

21-
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
22-
// import 'classlist.js'; // Run `npm install --save classlist.js`.
23-
24-
/**
25-
* Web Animations `@angular/platform-browser/animations`
26-
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27-
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28-
*/
29-
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30-
3121
/**
3222
* By default, zone.js will patch all possible macroTask and DomEvents
3323
* user can disable parts of macroTask/DomEvents patch by setting following flags

0 commit comments

Comments
 (0)