@@ -33,27 +33,20 @@ qx.Class.define("osparc.editor.WorkspaceEditor", {
3333 manager . add ( title ) ;
3434 this . getChildControl ( "description" ) ;
3535 this . getChildControl ( "thumbnail" ) ;
36+ this . getChildControl ( "cancel" ) ;
37+ const saveButton = this . getChildControl ( "save" ) ;
3638 if ( workspace ) {
3739 // editing
38- this . getChildControl ( "cancel" ) . addListener ( "execute" , ( ) => {
39- this . fireEvent ( "cancel" ) ;
40- } , this ) ;
41- this . getChildControl ( "save" ) ;
4240 this . setWorkspace ( workspace ) ;
4341 } else {
4442 // creating
45- this . getChildControl ( "cancel" ) . addListener ( "execute" , ( ) => {
46- osparc . store . Workspaces . getInstance ( ) . deleteWorkspace ( this . getWorkspace ( ) . getWorkspaceId ( ) )
47- this . fireEvent ( "cancel" ) ;
48- } , this ) ;
49- this . getChildControl ( "create" ) ;
43+ this . __creatingWorkspace = true ;
44+ saveButton . setLabel ( this . tr ( "Create" ) ) ;
5045 this . __createWorkspace ( )
5146 . then ( newWorkspace => {
5247 this . setWorkspace ( newWorkspace ) ;
53- this . fireDataEvent ( "workspaceCreated" , newWorkspace )
54- const permissionsView = new osparc . share . CollaboratorsWorkspace ( newWorkspace ) ;
55- permissionsView . addListener ( "updateAccessRights" , ( ) => this . fireDataEvent ( "updateAccessRights" , newWorkspace . getWorkspaceId ( ) ) , this ) ;
56- this . _addAt ( permissionsView , this . self ( ) . POS . SHARING ) ;
48+ this . fireDataEvent ( "workspaceCreated" , newWorkspace ) ;
49+ this . getChildControl ( "sharing" ) ;
5750 } ) ;
5851 }
5952
@@ -109,6 +102,8 @@ qx.Class.define("osparc.editor.WorkspaceEditor", {
109102 } ,
110103
111104 members : {
105+ __creatingWorkspace : null ,
106+
112107 _createChildControlImpl : function ( id ) {
113108 let control ;
114109 switch ( id ) {
@@ -155,32 +150,25 @@ qx.Class.define("osparc.editor.WorkspaceEditor", {
155150 this . _addAt ( control , this . self ( ) . POS . THUMBNAIL ) ;
156151 break ;
157152 }
153+ case "sharing" : {
154+ control = new osparc . share . CollaboratorsWorkspace ( this . getWorkspace ( ) ) ;
155+ control . addListener ( "updateAccessRights" , ( ) => this . fireDataEvent ( "updateAccessRights" , this . getWorkspace ( ) . getWorkspaceId ( ) ) , this ) ;
156+ this . _addAt ( control , this . self ( ) . POS . SHARING ) ;
157+ break ;
158+ }
158159 case "buttons-layout" : {
159160 control = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 8 ) . set ( {
160161 alignX : "right"
161162 } ) ) ;
162163 this . _addAt ( control , this . self ( ) . POS . BUTTONS ) ;
163164 break ;
164165 }
165- case "create" : {
166- const buttons = this . getChildControl ( "buttons-layout" ) ;
167- control = new osparc . ui . form . FetchButton ( this . tr ( "Create" ) ) . set ( {
168- appearance : "form-button"
169- } ) ;
170- control . addListener ( "execute" , ( ) => {
171- this . __saveWorkspace ( control ) ;
172- } , this ) ;
173- buttons . addAt ( control , 1 ) ;
174- break ;
175- }
176166 case "save" : {
177167 const buttons = this . getChildControl ( "buttons-layout" ) ;
178168 control = new osparc . ui . form . FetchButton ( this . tr ( "Save" ) ) . set ( {
179169 appearance : "form-button"
180170 } ) ;
181- control . addListener ( "execute" , ( ) => {
182- this . __saveWorkspace ( control ) ;
183- } , this ) ;
171+ control . addListener ( "execute" , ( ) => this . __saveWorkspace ( control ) , this ) ;
184172 buttons . addAt ( control , 1 ) ;
185173 break ;
186174 }
@@ -189,6 +177,7 @@ qx.Class.define("osparc.editor.WorkspaceEditor", {
189177 control = new qx . ui . form . Button ( this . tr ( "Cancel" ) ) . set ( {
190178 appearance : "form-button-text"
191179 } ) ;
180+ control . addListener ( "execute" , ( ) => this . cancel ( ) , this ) ;
192181 buttons . addAt ( control , 0 ) ;
193182 break ;
194183 }
@@ -232,6 +221,13 @@ qx.Class.define("osparc.editor.WorkspaceEditor", {
232221 }
233222 } ,
234223
224+ cancel : function ( ) {
225+ if ( this . __creatingWorkspace ) {
226+ osparc . store . Workspaces . getInstance ( ) . deleteWorkspace ( this . getWorkspace ( ) . getWorkspaceId ( ) ) ;
227+ }
228+ this . fireEvent ( "cancel" ) ;
229+ } ,
230+
235231 __onAppear : function ( ) {
236232 const title = this . getChildControl ( "title" ) ;
237233 title . focus ( ) ;
0 commit comments