@@ -1904,13 +1904,14 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
19041904
19051905 __consolidateAnnotation : function ( initPos , annotation ) {
19061906 const type = this . __annotating ;
1907- const annotationTypes = osparc . workbench . Annotation . TYPES ;
19081907 const color = this . __annotationLastColor ? this . __annotationLastColor : osparc . workbench . Annotation . DEFAULT_COLOR ;
19091908 const serializeData = {
19101909 type,
19111910 color,
19121911 attributes : { }
19131912 } ;
1913+
1914+ const annotationTypes = osparc . workbench . Annotation . TYPES ;
19141915 if ( type === annotationTypes . RECT ) {
19151916 if ( [ null , undefined ] . includes ( annotation ) ) {
19161917 osparc . FlashMessenger . logAs ( this . tr ( "Draw a rectangle first" ) , "WARNING" ) ;
@@ -1920,55 +1921,63 @@ qx.Class.define("osparc.workbench.WorkbenchUI", {
19201921 } else {
19211922 serializeData . attributes = initPos ;
19221923 }
1923- if ( type === annotationTypes . NOTE ) {
1924- const noteEditor = new osparc . editor . AnnotationNoteCreator ( this . getStudy ( ) ) ;
1925- const win = osparc . editor . AnnotationNoteCreator . popUpInWindow ( noteEditor ) ;
1926- noteEditor . addListener ( "addNote" , ( ) => {
1927- const gid = noteEditor . getRecipientGid ( ) ;
1928- serializeData . attributes . recipientGid = gid ;
1929- serializeData . attributes . text = noteEditor . getNote ( ) ;
1930- const user = osparc . store . Groups . getInstance ( ) . getUserByGroupId ( gid )
1931- if ( user ) {
1932- osparc . notification . Notifications . pushNewAnnotationNote ( user . getUserId ( ) , this . getStudy ( ) . getUuid ( ) ) ;
1933- }
1934- this . __addAnnotation ( serializeData ) ;
1935- win . close ( ) ;
1936- } , this ) ;
1937- noteEditor . addListener ( "cancel" , ( ) => win . close ( ) ) ;
1938- } else if ( type === annotationTypes . RECT ) {
1939- this . __addAnnotation ( serializeData ) ;
1940- } else if ( type === annotationTypes . TEXT ) {
1941- const tempAnnotation = new osparc . workbench . Annotation ( null , {
1942- type : annotationTypes . TEXT ,
1943- color,
1944- attributes : {
1945- text : "" ,
1946- fontSize : 12
1947- }
1948- } ) ;
1949- const annotationEditor = new osparc . editor . AnnotationEditor ( tempAnnotation ) ;
1950- annotationEditor . addAddButtons ( ) ;
1951- tempAnnotation . addListener ( "changeColor" , e => this . __annotationLastColor = e . getData ( ) ) ;
1952- annotationEditor . addListener ( "appear" , ( ) => {
1953- const textField = annotationEditor . getChildControl ( "text-field" ) ;
1954- textField . focus ( ) ;
1955- textField . activate ( ) ;
1956- } ) ;
1957- const win = osparc . ui . window . Window . popUpInWindow ( annotationEditor , "Add Text Annotation" , 220 , 135 ) . set ( {
1958- clickAwayClose : true ,
1959- showClose : true
1960- } ) ;
1961- annotationEditor . addListener ( "addAnnotation" , ( ) => {
1962- win . close ( ) ;
1963- const form = annotationEditor . getForm ( ) ;
1964- serializeData . attributes . text = form . getItem ( "text" ) . getValue ( ) ;
1965- serializeData . attributes . color = form . getItem ( "color" ) . getValue ( ) ;
1966- serializeData . color = form . getItem ( "color" ) . getValue ( ) ;
1967- serializeData . attributes . fontSize = form . getItem ( "size" ) . getValue ( ) ;
1924+
1925+ switch ( type ) {
1926+ case annotationTypes . NOTE : {
1927+ const noteEditor = new osparc . editor . AnnotationNoteCreator ( this . getStudy ( ) ) ;
1928+ const win = osparc . editor . AnnotationNoteCreator . popUpInWindow ( noteEditor ) ;
1929+ noteEditor . addListener ( "addNote" , ( ) => {
1930+ const gid = noteEditor . getRecipientGid ( ) ;
1931+ serializeData . attributes . recipientGid = gid ;
1932+ serializeData . attributes . text = noteEditor . getNote ( ) ;
1933+ const user = osparc . store . Groups . getInstance ( ) . getUserByGroupId ( gid )
1934+ if ( user ) {
1935+ osparc . notification . Notifications . pushNewAnnotationNote ( user . getUserId ( ) , this . getStudy ( ) . getUuid ( ) ) ;
1936+ }
1937+ this . __addAnnotation ( serializeData ) ;
1938+ win . close ( ) ;
1939+ } , this ) ;
1940+ noteEditor . addListener ( "cancel" , ( ) => win . close ( ) ) ;
1941+ break ;
1942+ }
1943+ case annotationTypes . RECT :
19681944 this . __addAnnotation ( serializeData ) ;
1969- } , this ) ;
1970- win . open ( ) ;
1945+ break ;
1946+ case annotationTypes . TEXT : {
1947+ const tempAnnotation = new osparc . workbench . Annotation ( null , {
1948+ type : annotationTypes . TEXT ,
1949+ color,
1950+ attributes : {
1951+ text : "" ,
1952+ fontSize : 12
1953+ }
1954+ } ) ;
1955+ const annotationEditor = new osparc . editor . AnnotationEditor ( tempAnnotation ) ;
1956+ annotationEditor . addAddButtons ( ) ;
1957+ tempAnnotation . addListener ( "changeColor" , e => this . __annotationLastColor = e . getData ( ) ) ;
1958+ annotationEditor . addListener ( "appear" , ( ) => {
1959+ const textField = annotationEditor . getChildControl ( "text-field" ) ;
1960+ textField . focus ( ) ;
1961+ textField . activate ( ) ;
1962+ } ) ;
1963+ const win = osparc . ui . window . Window . popUpInWindow ( annotationEditor , "Add Text Annotation" , 220 , 135 ) . set ( {
1964+ clickAwayClose : true ,
1965+ showClose : true
1966+ } ) ;
1967+ annotationEditor . addListener ( "addAnnotation" , ( ) => {
1968+ win . close ( ) ;
1969+ const form = annotationEditor . getForm ( ) ;
1970+ serializeData . attributes . text = form . getItem ( "text" ) . getValue ( ) ;
1971+ serializeData . attributes . color = form . getItem ( "color" ) . getValue ( ) ;
1972+ serializeData . color = form . getItem ( "color" ) . getValue ( ) ;
1973+ serializeData . attributes . fontSize = form . getItem ( "size" ) . getValue ( ) ;
1974+ this . __addAnnotation ( serializeData ) ;
1975+ } , this ) ;
1976+ win . open ( ) ;
1977+ break ;
1978+ }
19711979 }
1980+
19721981 return true ;
19731982 } ,
19741983
0 commit comments