import { ContainerConfig } from "../interface/config/container-config" ; import { GridColumnConfig } from "../interface/config/grid-column-config" ; import { GridConfiguration } from "../interface/config/grid-configuration" ; export const gridContainer = new ( class { private instances : ContainerConfig [ ] = [ ] ; setGridConfiguration ( instanceFunc , configuration ) { let instance = this . get ( instanceFunc ) ; if ( instance ) instance . configuration = configuration ; } get ( instanceFunc ) { let instance = this . instances . filter ( instance => instance . instance === instanceFunc ) [ 0 ] ; return instance ; } addColumn ( instanceFunc , propertyName , columnConfig ) { let instance = this . get ( instanceFunc ) as ContainerConfig ; if ( ! instance ) { instance = { instance : instanceFunc } ; instance . columns = [ ] ; this . instances . push ( instance ) ; } columnConfig . name = propertyName ; columnConfig . visible = columnConfig . visible === undefined ? true : columnConfig . visible ; columnConfig . allowSorting = columnConfig . allowSorting === undefined ? true : columnConfig . allowSorting ; instance . columns . push ( columnConfig ) ; } } ) ( ) ;