File tree Expand file tree Collapse file tree
administration/static/app/controllers Expand file tree Collapse file tree Original file line number Diff line number Diff line change 108108 document . title = 'Aula: {0}' . format ( l . name ) ;
109109
110110 if ( l . units . length > 0 ) {
111- if ( $location . search ( ) . unit ) {
112- $scope . selectUnit ( l . units [ $location . search ( ) . unit ] )
113- }
114- else {
115- $scope . selectUnit ( l . units [ 0 ] ) ;
116- }
111+ var u = $location . search ( ) . unit ?
112+ l . units [ $location . search ( ) . unit ] : undefined ;
113+
114+ u = u ? l . units [ $location . search ( ) . unit ] : l . units [ 0 ] ;
115+ $scope . selectUnit ( u )
117116 } else {
118117 $scope . addUnit ( ) ;
119118 }
174173 } ;
175174
176175 $scope . selectUnit = function ( u ) {
177- Unit . get ( { id : u . id } , function ( data ) {
178- u = data ;
176+ if ( u && u . id ) {
177+ Unit . get ( { id : u . id } , function ( data ) {
178+ setupUnit ( data )
179+ } ) ;
180+ } else {
181+ setupUnit ( u ) ;
182+ }
183+ function setupUnit ( u ) {
179184 $scope . currentUnit = u ;
180185
181186 for ( i = 0 ; i < $scope . lesson . units . length ; i ++ ) {
197202
198203 // MarkdownDirective.resetEditors();
199204 MarkdownDirective . refreshEditorsPreview ( ) ;
200-
201- } ) ;
205+ }
202206 } ;
203207
204208 $scope . addUnit = function ( ) {
You can’t perform that action at this time.
0 commit comments