Skip to content

Commit dabd814

Browse files
#24 load saved view config from data views on data table change
1 parent b2c5d72 commit dabd814

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"config": {
3+
"aggregates": "{\"Education\":\"count\",\"Gender\":\"count\",\"Marital Status\":\"count\",\"Occupation\":\"count\",\"Yearly Income\":\"count\",\"Birth Date\":\"count\",\"Date First Purchase\":\"count\",\"Number Cars Owned\":\"sum\",\"Number Children At Home\":\"sum\",\"Total Children\":\"sum\",\"Total Purchase YTD\":\"sum\",\"Home Owner Flag\":\"count\"}",
4+
"column-pivots": "[]",
5+
"columns": "[\"Birth Date\",\"Date First Purchase\",\"Education\",\"Gender\",\"Home Owner Flag\",\"Marital Status\",\"Number Cars Owned\",\"Number Children At Home\",\"Occupation\",\"Total Children\",\"Total Purchase YTD\",\"Yearly Income\"]",
6+
"filters": "[]",
7+
"row-pivots": "[]",
8+
"settings": "true",
9+
"sort": "[[\"Education\",\"asc\"]]",
10+
"view": "grid"
11+
},
12+
"dataFileName": "Demographics.xlsx",
13+
"dataTable": "Demographics"
14+
}

src/data.preview.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,14 @@ export class DataPreview {
252252
* Saves updated data viewer config for restore on vscode reload.
253253
*/
254254
private updateConfig(viewConfig: any, dataTable: string) {
255-
if (viewConfig.hasOwnProperty('view') && // not a blank view config
255+
if (this._dataTable !== dataTable && this._dataViews.hasOwnProperty(dataTable)) {
256+
// load saved data view for the requested data table
257+
this._viewConfig = this._dataViews[dataTable];
258+
this._logger.debug(`updateConfig(${dataTable}): new view config:`, this._viewConfig);
259+
}
260+
else if (viewConfig.hasOwnProperty('view') && // not a blank view config
256261
JSON.stringify(this._viewConfig) !== JSON.stringify(viewConfig)) {
262+
// update view config for the loaded data table
257263
this._viewConfig = viewConfig;
258264
this._logger.debug(`updateConfig(${this._dataTable}): config:`, this._viewConfig);
259265
if (this._dataTable.length > 0) {

0 commit comments

Comments
 (0)