@@ -44,12 +44,14 @@ class LayoutManager {
4444 widgetFactory : WidgetFactory ;
4545 tabsetIconFactory : TabsetIconFactory ;
4646 dispatch ;
47-
47+ layoutManager = this ;
48+ enableMinimize = false ;
4849
4950 constructor (
5051 model ,
5152 widgetFactory : WidgetFactory = null ,
5253 tabsetIconFactory : TabsetIconFactory = null ,
54+ enableMinimize = false
5355 ) {
5456 this . model = FlexLayout . Model . fromJson (
5557 model ? model : defaultLayoutConfiguration
@@ -61,6 +63,7 @@ class LayoutManager {
6163 : new TabsetIconFactory ( ) ;
6264 this . middleware = this . middleware . bind ( this ) ;
6365 this . factory = this . factory . bind ( this ) ;
66+ this . enableMinimize = enableMinimize ;
6467 }
6568
6669 addWidget ( widgetConfiguration ) {
@@ -79,23 +82,33 @@ class LayoutManager {
7982 ) ;
8083 }
8184
82- Component = ( { classes} ) => (
85+ onRenderTabSet = ( panel , renderValues ) => {
86+ if ( panel . getType ( ) === "tabset" && this . enableMinimize ) {
87+ if ( panel . getId ( ) != 'leftPanel' && panel . getChildren ( ) . length > 0 ) {
88+ renderValues . buttons . push ( < div key = { panel . getId ( ) } className = "fa fa-window-minimize customIconFlexLayout" onClick = { ( ) => {
89+ this . minimizeWidget ( panel . getSelectedNode ( ) . getId ( ) )
90+ } } /> ) ;
91+ }
92+ }
93+ }
94+
95+ Component = ( layoutManager : LayoutManager ) => ( { classes} ) => (
8396 < div className = { classes . container } >
8497 < div className = { classes . spacer } />
8598 < div className = { classes . flexlayout } >
8699 < FlexLayout . Layout
87100 model = { this . model }
88101 factory = { this . factory }
89102 // iconFactory={layoutManager.iconFactory.bind(this)}
90- onAction = { action => this . onAction ( action ) }
91- onRenderTab = { ( node , renderValues ) => null }
103+ onAction = { action => layoutManager . onAction ( action ) }
104+ onRenderTab = { ( node , renderValues ) => layoutManager . onRenderTabSet ( node , renderValues ) }
92105 />
93106 </ div >
94107 < div className = { classes . spacer } />
95108 </ div >
96109 ) ;
97110
98- getComponent = ( ) => withStyles ( styles ) ( this . Component ) ;
111+ getComponent = ( ) => withStyles ( styles ) ( this . Component ( this ) ) ;
99112
100113
101114 private createTabSet ( tabsetID ) {
@@ -194,7 +207,7 @@ class LayoutManager {
194207 break ;
195208 case Actions . DELETE_TAB : {
196209 if ( this . getWidget ( action . data . node ) . hideOnClose ) {
197- this . moveWidgetToBorder ( action ) ;
210+ this . minimizeWidget ( action . data . node ) ;
198211 defaultAction = false ;
199212 }
200213 break ;
@@ -273,15 +286,19 @@ class LayoutManager {
273286 }
274287 }
275288
276- moveWidgetToBorder ( action ) {
289+
290+
291+
292+ minimizeWidget ( widgetId ) {
277293
278- var updatedWidget = this . getWidget ( action . id ) ;
294+ var updatedWidget = this . getWidget ( widgetId ) ;
279295 if ( updatedWidget === undefined ) {
280296 return ;
281297 }
282- updatedWidget . status = WidgetStatus . BORDER ;
298+ updatedWidget . status = WidgetStatus . MINIMIZED ;
283299 updatedWidget . panelName = "border_bottom" ;
284300 this . updateWidget ( updatedWidget ) ;
301+ // this.model.doAction(FlexLayout.Actions.moveNode(widgetId, "border_bottom", FlexLayout.DockLocation.CENTER, 0));
285302 }
286303
287304 updateWidget ( widget : Widget ) {
@@ -290,6 +307,7 @@ class LayoutManager {
290307 this . widgetFactory . updateWidget ( widget ) ;
291308 model . doAction ( Actions . updateNodeAttributes ( widget . id , widget2Node ( widget ) ) ) ;
292309 }
310+ this . model . doAction ( FlexLayout . Actions . moveNode ( widget . id , widget . panelName , FlexLayout . DockLocation . CENTER , widget . pos ) ) ;
293311
294312 }
295313 onActionMaximizeWidget ( action ) {
0 commit comments