@@ -3,16 +3,17 @@ import { Transform } from './transform';
33import { View } from './view' ;
44
55import {
6- SortExecutor ,
76 FilterExecutor ,
7+ HideExecutor ,
8+ SortExecutor ,
89 TransformExecutor ,
910} from './transformExecutors' ;
1011
1112import { each } from '@lumino/algorithm' ;
1213
1314import { JSONExt } from '@lumino/coreutils' ;
1415
15- import { Signal , ISignal } from '@lumino/signaling' ;
16+ import { ISignal , Signal } from '@lumino/signaling' ;
1617import { DataSource } from '../datasource' ;
1718
1819/**
@@ -25,6 +26,7 @@ export class TransformStateManager {
2526 this . _state [ transform . column ] = {
2627 sort : undefined ,
2728 filter : undefined ,
29+ hide : undefined ,
2830 } ;
2931 }
3032
@@ -41,6 +43,9 @@ export class TransformStateManager {
4143 case 'filter' :
4244 this . _state [ transform . column ] [ 'filter' ] = transform ;
4345 break ;
46+ case 'hide' :
47+ this . _state [ transform . columnIndex ] [ 'hide' ] = transform ;
48+ break ;
4449 default :
4550 throw 'unreachable' ;
4651 }
@@ -110,6 +115,7 @@ export class TransformStateManager {
110115 private _createExecutors ( data : Readonly < DataSource > ) : TransformExecutor [ ] {
111116 const sortExecutors : SortExecutor [ ] = [ ] ;
112117 const filterExecutors : FilterExecutor [ ] = [ ] ;
118+ const hideExecutors : HideExecutor [ ] = [ ] ;
113119
114120 Object . keys ( this . _state ) . forEach ( ( column ) => {
115121 const transform : TransformStateManager . IColumn = this . _state [ column ] ;
@@ -146,10 +152,17 @@ export class TransformStateManager {
146152 } ) ;
147153 filterExecutors . push ( executor ) ;
148154 }
155+ if ( transform . hide ) {
156+ const executor = new HideExecutor ( {
157+ field : data . schema . fields [ transform . hide . columnIndex ] [ 'name' ] ,
158+ hideAll : transform . hide . hideAll ,
159+ } ) ;
160+ hideExecutors . push ( executor ) ;
161+ }
149162 } ) ;
150163
151164 // Always put filters first
152- return [ ...filterExecutors , ...sortExecutors ] ;
165+ return [ ...filterExecutors , ...sortExecutors , ... hideExecutors ] ;
153166 }
154167
155168 /**
@@ -171,10 +184,12 @@ export class TransformStateManager {
171184 columnState . sort = undefined ;
172185 } else if ( transformType === 'filter' ) {
173186 columnState . filter = undefined ;
187+ } else if ( transformType === 'hide' ) {
188+ columnState . hide = undefined ;
174189 } else {
175190 throw 'unreachable' ;
176191 }
177- if ( ! columnState . sort && ! columnState . filter ) {
192+ if ( ! columnState . sort && ! columnState . filter && ! columnState . hide ) {
178193 delete this . _state [ column ] ;
179194 }
180195 this . _changed . emit ( {
@@ -229,6 +244,9 @@ export class TransformStateManager {
229244 if ( this . _state [ column ] . filter ) {
230245 transforms . push ( this . _state [ column ] . filter ! ) ;
231246 }
247+ if ( this . _state [ column ] . hide ) {
248+ transforms . push ( this . _state [ column ] . hide ! ) ;
249+ }
232250 } ) ;
233251 return transforms ;
234252 }
@@ -255,6 +273,7 @@ export namespace TransformStateManager {
255273 export interface IColumn {
256274 filter : Transform . Filter | undefined ;
257275 sort : Transform . Sort | undefined ;
276+ hide : Transform . Hide | undefined ;
258277 }
259278 export interface IState {
260279 [ key : string ] : IColumn ;
0 commit comments