@@ -113,40 +113,43 @@ var StarView = Backbone.View.extend({
113113 console . log ( "Event star a node was fired for node Id " + "" ) ;
114114 if ( APP . appView . getCurrentRequestNodeId ( ) != null ) {
115115 var nodeId ;
116- if ( $ ( '#tree' ) . css ( 'display' ) == "none" ) {
116+ if ( $ ( '#tree' ) . css ( 'display' ) == "none" && $ ( '#currentStaredNode' ) . val ( ) != null ) {
117117 nodeId = $ ( '#currentStaredNode' ) . val ( ) ;
118118 } else {
119119 nodeId = APP . appView . getCurrentRequestNodeId ( ) ;
120120 }
121121 console . log ( "conversation id is ..." + APP . appView . getCurrentRequestNodeId ( ) ) ;
122- var node = new NodeModel ( {
123- id : nodeId
124- } ) ;
125- node . fetch ( {
126- success : function ( response ) {
127- var starred = ! response . get ( "starred" ) ;
128- var starModel = new StarModel ( ) ;
129- starModel . set ( 'id' , nodeId ) ;
130- starModel . set ( 'starred' , ! response . get ( "starred" ) ) ;
131- starModel . save ( null , {
132- success : function ( ) {
133- console . log ( "changes saves successfully" ) ;
134- if ( $ ( '#starred-items' ) . css ( 'display' ) == 'block' ) {
135- $ ( '.starred ' ) . click ( ) ;
136- }
137- if ( starred ) {
138- $ ( '#starNodeBtn' ) . html ( '<span class="glyphicon glyphicon-star"></span> Unstar' ) ;
139- }
140- else {
141- $ ( '#starNodeBtn' ) . html ( '<span class="glyphicon glyphicon-star"></span> Star' ) ;
142- }
143- } ,
144- error : function ( ) {
145- alert ( 'some error occured while saving the request' ) ;
146- }
147- } ) ;
148- }
149- } ) ;
122+ if ( nodeId ) {
123+ var node = new NodeModel ( {
124+ id : nodeId
125+ } ) ;
126+ node . fetch ( {
127+ success : function ( response ) {
128+ var starred = ! response . get ( "starred" ) ;
129+ var starModel = new StarModel ( ) ;
130+ starModel . set ( 'id' , nodeId ) ;
131+ starModel . set ( 'starred' , ! response . get ( "starred" ) ) ;
132+ starModel . save ( null , {
133+ success : function ( ) {
134+ console . log ( "changes saves successfully" ) ;
135+ if ( $ ( '#starred-items' ) . css ( 'display' ) == 'block' ) {
136+ $ ( '.starred ' ) . click ( ) ;
137+ }
138+ if ( starred ) {
139+ $ ( '#starNodeBtn' ) . html ( '<span class="glyphicon glyphicon-star"></span> Unstar' ) ;
140+ }
141+ else {
142+ $ ( '#starNodeBtn' ) . html ( '<span class="glyphicon glyphicon-star"></span> Star' ) ;
143+ }
144+ } ,
145+ error : function ( ) {
146+ alert ( 'some error occured while saving the request' ) ;
147+ }
148+ } ) ;
149+ }
150+ } ) ;
151+ }
152+
150153 }
151154 } ,
152155
0 commit comments