@@ -65,14 +65,12 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
65
65
66
66
statics : {
67
67
popUpInWindow : function ( title , studyDetailsEditor , width = 400 , height = 400 ) {
68
- const win = new qx . ui . window . Window ( title ) . set ( {
68
+ const win = new osparc . ui . window . Window ( title ) . set ( {
69
69
autoDestroy : true ,
70
- layout : new qx . ui . layout . VBox ( ) ,
71
- appearance : "service-window" ,
70
+ layout : new qx . ui . layout . Grow ( ) ,
72
71
showMinimize : false ,
73
72
showMaximize : false ,
74
73
resizable : true ,
75
- contentPadding : 10 ,
76
74
width : width ,
77
75
height : height ,
78
76
modal : true
@@ -99,8 +97,10 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
99
97
100
98
__createDisplayView : function ( study , isTemplate , winWidth ) {
101
99
const displayView = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 10 ) ) ;
100
+ displayView . add ( new osparc . component . metadata . StudyDetails ( study , winWidth ) , {
101
+ flex : 1
102
+ } ) ;
102
103
displayView . add ( this . __createButtons ( isTemplate ) ) ;
103
- displayView . add ( new osparc . component . metadata . StudyDetails ( study , winWidth ) ) ;
104
104
return displayView ;
105
105
} ,
106
106
@@ -109,54 +109,48 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
109
109
const canCreateTemplate = osparc . data . Permissions . getInstance ( ) . canDo ( "studies.template.create" ) ;
110
110
const canUpdateTemplate = osparc . data . Permissions . getInstance ( ) . canDo ( "studies.template.update" ) ;
111
111
112
- const buttonsLayout = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 8 ) . set ( {
113
- alignY : "middle"
114
- } ) ) . set ( {
115
- marginTop : 10
116
- } ) ;
112
+ const buttonsToolbar = new qx . ui . toolbar . ToolBar ( ) ;
117
113
118
- const modeButton = new qx . ui . form . Button ( this . tr ( "Edit" ) ) . set ( {
119
- appearance : "md-button" ,
114
+ const modeButton = new qx . ui . toolbar . Button ( this . tr ( "Edit" ) ) . set ( {
115
+ appearance : "toolbar- md-button" ,
120
116
visibility : isCurrentUserOwner && ( ! isTemplate || canUpdateTemplate ) ? "visible" : "excluded"
121
117
} ) ;
122
118
osparc . utils . Utils . setIdToWidget ( modeButton , "editStudyBtn" ) ;
123
119
modeButton . addListener ( "execute" , ( ) => this . setMode ( "edit" ) , this ) ;
124
- buttonsLayout . add ( modeButton ) ;
120
+ buttonsToolbar . add ( modeButton ) ;
125
121
126
122
if ( ! isTemplate ) {
127
- const permissionsButton = new qx . ui . form . Button ( this . tr ( "Permissions" ) ) . set ( {
128
- appearance : "md-button"
123
+ const permissionsButton = new qx . ui . toolbar . Button ( this . tr ( "Permissions" ) ) . set ( {
124
+ appearance : "toolbar- md-button"
129
125
} ) ;
130
126
osparc . utils . Utils . setIdToWidget ( permissionsButton , "permissionsBtn" ) ;
131
127
permissionsButton . addListener ( "execute" , e => {
132
128
this . __openPermissions ( ) ;
133
129
} , this ) ;
134
- buttonsLayout . add ( permissionsButton ) ;
130
+ buttonsToolbar . add ( permissionsButton ) ;
135
131
136
132
if ( isCurrentUserOwner && canCreateTemplate ) {
137
- const saveAsTemplateButton = new qx . ui . form . Button ( this . tr ( "Save as Template" ) ) . set ( {
138
- appearance : "md-button"
133
+ const saveAsTemplateButton = new qx . ui . toolbar . Button ( this . tr ( "Save as Template" ) ) . set ( {
134
+ appearance : "toolbar- md-button"
139
135
} ) ;
140
136
osparc . utils . Utils . setIdToWidget ( saveAsTemplateButton , "saveAsTemplateBtn" ) ;
141
137
saveAsTemplateButton . addListener ( "execute" , e => {
142
138
this . __openSaveAsTemplate ( ) ;
143
139
} , this ) ;
144
- buttonsLayout . add ( saveAsTemplateButton ) ;
140
+ buttonsToolbar . add ( saveAsTemplateButton ) ;
145
141
}
146
142
}
147
143
148
- buttonsLayout . add ( new qx . ui . core . Spacer ( ) , {
149
- flex : 1
150
- } ) ;
144
+ buttonsToolbar . addSpacer ( ) ;
151
145
152
- const openButton = this . __openButton = new qx . ui . form . Button ( this . tr ( "Open" ) ) . set ( {
153
- appearance : "md-button"
146
+ const openButton = this . __openButton = new qx . ui . toolbar . Button ( this . tr ( "Open" ) ) . set ( {
147
+ appearance : "toolbar- md-button"
154
148
} ) ;
155
149
osparc . utils . Utils . setIdToWidget ( openButton , "openStudyBtn" ) ;
156
150
openButton . addListener ( "execute" , ( ) => this . fireEvent ( "openStudy" ) , this ) ;
157
- buttonsLayout . add ( openButton ) ;
151
+ buttonsToolbar . add ( openButton ) ;
158
152
159
- return buttonsLayout ;
153
+ return buttonsToolbar ;
160
154
} ,
161
155
162
156
__createEditView : function ( isTemplate ) {
@@ -165,9 +159,7 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
165
159
const fieldIsEnabled = isCurrentUserOwner && ( ! isTemplate || canUpdateTemplate ) ;
166
160
167
161
const editView = new qx . ui . container . Composite ( new qx . ui . layout . VBox ( 8 ) ) ;
168
- const buttons = new qx . ui . container . Composite ( new qx . ui . layout . HBox ( 8 ) . set ( {
169
- alignX : "right"
170
- } ) ) ;
162
+ const buttonsToolbar = new qx . ui . toolbar . ToolBar ( ) ;
171
163
172
164
this . __fields = {
173
165
name : new qx . ui . form . TextField ( this . __studyModel . getName ( ) ) . set ( {
@@ -176,34 +168,13 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
176
168
enabled : fieldIsEnabled
177
169
} ) ,
178
170
description : new qx . ui . form . TextArea ( this . __studyModel . getDescription ( ) ) . set ( {
179
- autoSize : true ,
180
- minHeight : 100 ,
181
- maxHeight : 500 ,
182
171
enabled : fieldIsEnabled
183
172
} ) ,
184
173
thumbnail : new qx . ui . form . TextField ( this . __studyModel . getThumbnail ( ) ) . set ( {
185
174
enabled : fieldIsEnabled
186
175
} )
187
176
} ;
188
177
189
- const saveButton = new qx . ui . form . Button ( this . tr ( "Save" ) , "@FontAwesome5Solid/save/16" ) . set ( {
190
- appearance : "lg-button"
191
- } ) ;
192
- osparc . utils . Utils . setIdToWidget ( saveButton , "studyDetailsEditorSaveBtn" ) ;
193
- saveButton . addListener ( "execute" , e => {
194
- const btn = e . getTarget ( ) ;
195
- btn . setIcon ( "@FontAwesome5Solid/circle-notch/16" ) ;
196
- btn . getChildControl ( "icon" ) . getContentElement ( )
197
- . addClass ( "rotate" ) ;
198
- this . __saveStudy ( isTemplate , btn ) ;
199
- } , this ) ;
200
- const cancelButton = new qx . ui . form . Button ( this . tr ( "Cancel" ) ) . set ( {
201
- appearance : "lg-button" ,
202
- enabled : isCurrentUserOwner && ( ! isTemplate || canUpdateTemplate )
203
- } ) ;
204
- osparc . utils . Utils . setIdToWidget ( cancelButton , "studyDetailsEditorCancelBtn" ) ;
205
- cancelButton . addListener ( "execute" , ( ) => this . setMode ( "display" ) , this ) ;
206
-
207
178
const {
208
179
name,
209
180
description,
@@ -219,7 +190,9 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
219
190
font : "text-14"
220
191
} ) ) ;
221
192
osparc . utils . Utils . setIdToWidget ( description , "studyDetailsEditorDescFld" ) ;
222
- editView . add ( description ) ;
193
+ editView . add ( description , {
194
+ flex : 1
195
+ } ) ;
223
196
editView . add ( new qx . ui . basic . Label ( this . tr ( "Thumbnail" ) ) . set ( {
224
197
font : "text-14"
225
198
} ) ) ;
@@ -230,9 +203,28 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
230
203
editView . add ( this . __tagsSection ( ) ) ;
231
204
}
232
205
233
- buttons . add ( saveButton ) ;
234
- buttons . add ( cancelButton ) ;
235
- editView . add ( buttons ) ;
206
+ const saveButton = new qx . ui . toolbar . Button ( this . tr ( "Save" ) , "@FontAwesome5Solid/save/16" ) . set ( {
207
+ appearance : "toolbar-lg-button"
208
+ } ) ;
209
+ osparc . utils . Utils . setIdToWidget ( saveButton , "studyDetailsEditorSaveBtn" ) ;
210
+ saveButton . addListener ( "execute" , e => {
211
+ const btn = e . getTarget ( ) ;
212
+ btn . setIcon ( "@FontAwesome5Solid/circle-notch/16" ) ;
213
+ btn . getChildControl ( "icon" ) . getContentElement ( )
214
+ . addClass ( "rotate" ) ;
215
+ this . __saveStudy ( isTemplate , btn ) ;
216
+ } , this ) ;
217
+ const cancelButton = new qx . ui . toolbar . Button ( this . tr ( "Cancel" ) ) . set ( {
218
+ appearance : "toolbar-lg-button" ,
219
+ enabled : isCurrentUserOwner && ( ! isTemplate || canUpdateTemplate )
220
+ } ) ;
221
+ osparc . utils . Utils . setIdToWidget ( cancelButton , "studyDetailsEditorCancelBtn" ) ;
222
+ cancelButton . addListener ( "execute" , ( ) => this . setMode ( "display" ) , this ) ;
223
+
224
+ buttonsToolbar . addSpacer ( ) ;
225
+ buttonsToolbar . add ( saveButton ) ;
226
+ buttonsToolbar . add ( cancelButton ) ;
227
+ editView . add ( buttonsToolbar ) ;
236
228
237
229
return editView ;
238
230
} ,
@@ -279,18 +271,22 @@ qx.Class.define("osparc.component.metadata.StudyDetailsEditor", {
279
271
} ,
280
272
281
273
__saveStudy : function ( isTemplate , btn ) {
274
+ const data = this . __serializeForm ( ) ;
275
+ // FIXME: Avoid adding invalid properties to standard entities.
276
+ delete data . locked ;
277
+ delete data . resourceType ;
282
278
const params = {
283
279
url : {
284
280
projectId : this . __studyModel . getUuid ( )
285
281
} ,
286
- data : this . __serializeForm ( )
282
+ data
287
283
} ;
288
284
osparc . data . Resources . fetch ( isTemplate ? "templates" : "studies" , "put" , params )
289
- . then ( data => {
285
+ . then ( studyData => {
290
286
btn . resetIcon ( ) ;
291
287
btn . getChildControl ( "icon" ) . getContentElement ( )
292
288
. removeClass ( "rotate" ) ;
293
- this . __studyModel . set ( data ) ;
289
+ this . __studyModel . set ( studyData ) ;
294
290
this . setMode ( "display" ) ;
295
291
this . fireEvent ( isTemplate ? "updateTemplate" : "updateStudy" ) ;
296
292
} )
0 commit comments