@@ -27,6 +27,8 @@ import {
2727} from "./actions" ;
2828
2929import { MINIMIZED_PANEL } from '.' ;
30+ import { TabsetPosition } from './model' ;
31+ import { Tab } from '@geppettoengine/geppetto-client/js/components/interface/flexLayout2/src/view/Tab' ;
3032
3133const styles = ( theme ) => createStyles ( {
3234 container : {
@@ -80,7 +82,7 @@ class LayoutManager {
8082 const { model } = this ;
8183 let tabset = model . getNodeById ( widgetConfiguration . panelName ) ;
8284 if ( tabset === undefined ) {
83- this . createTabSet ( widgetConfiguration . panelName ) ;
85+ this . createTabSet ( widgetConfiguration . panelName , widgetConfiguration . defaultPosition , widgetConfiguration . defaultWeight ) ;
8486 }
8587 this . model . doAction (
8688 Actions . addNode (
@@ -119,32 +121,52 @@ class LayoutManager {
119121 getComponent = ( ) => withStyles ( styles ) ( this . Component ( this ) ) ;
120122
121123
122- private createTabSet ( tabsetID ) {
124+ private createTabSet ( tabsetID , position = TabsetPosition . BOTTOM , weight = 30 ) {
123125 // In case the tabset doesn't exist
124126 const { model } = this ;
125127 const rootNode = model . getNodeById ( "root" ) ;
126128
127- let hrow = new FlexLayout . RowNode ( model , { } ) ;
128- hrow . _setWeight ( 100 ) ;
129129
130- const tabset = new FlexLayout . TabSetNode ( model , { id : tabsetID } ) ;
131- tabset . _setWeight ( 20 ) ;
132130
131+ const tabset = new FlexLayout . TabSetNode ( model , { id : tabsetID } ) ;
132+ tabset . _setWeight ( weight ) ;
133+ let hrow = rootNode . getChildren ( ) . find ( child => child . getType ( ) === 'row' ) ;
134+ let hrowRowRow = null ;
135+ switch ( position ) {
136+ case TabsetPosition . RIGHT :
137+ rootNode . _addChild ( tabset ) ;
138+ break ;
139+ case TabsetPosition . LEFT :
140+ rootNode . _addChild ( tabset , 0 ) ;
141+ break ;
142+ case TabsetPosition . BOTTOM :
143+ case TabsetPosition . TOP : {
144+ if ( ! hrow ) {
145+ hrow = new FlexLayout . RowNode ( model , { } ) ;
146+ hrow . _setWeight ( 100 ) ;
147+
148+ hrowRowRow = new FlexLayout . RowNode ( model , { } ) ;
149+ hrowRowRow . _setWeight ( 100 - weight ) ;
150+ hrow . _addChild ( hrowRowRow ) ;
151+ rootNode . getChildren ( ) . forEach ( child => {
152+ hrowRowRow . _addChild ( child ) ;
153+ } ) ;
154+ rootNode . _removeAll ( ) ;
155+ rootNode . _addChild ( hrow ) ;
156+ }
133157
158+ if ( position === TabsetPosition . BOTTOM ) {
159+ hrow . _addChild ( tabset )
160+ } else {
161+ hrow . _addChild ( tabset , 0 ) ;
162+ }
134163
135- rootNode . getChildren ( ) . forEach ( child => {
136- if ( child [ 'getWeight' ] ) {
137- const newWeight = ( child as FlexLayout . TabSetNode ) . getWeight ( ) / 2 ;
138- child . _setWeight ( newWeight ) ;
139- hrow . _addChild ( child ) ;
164+ break ;
140165 }
141166
142- } ) ;
167+ }
143168
144- hrow . _addChild ( tabset ) ;
145169
146- rootNode . _removeAll ( ) ;
147- rootNode . _addChild ( hrow ) ;
148170 setTimeout ( ( ) => window . dispatchEvent ( new Event ( "resize" ) ) , 1000 ) ;
149171 }
150172
@@ -387,7 +409,7 @@ class LayoutManager {
387409 const panelName = widget . panelName ;
388410 let tabset = model . getNodeById ( panelName ) ;
389411 if ( tabset === undefined ) {
390- this . createTabSet ( panelName ) ;
412+ this . createTabSet ( panelName , widget . defaultPosition , widget . defaultWeight ) ;
391413 }
392414 this . moveWidget ( widget ) ;
393415 }
0 commit comments