@@ -42,8 +42,22 @@ var MongoDBCollectionView = View.extend({
42
42
model : MongoDBCollection ,
43
43
schema : SampledSchema
44
44
} ,
45
+ showEmptyMessage : function ( ) {
46
+ this . queryByHook ( 'empty' ) . classList . remove ( 'hidden' ) ;
47
+ this . queryByHook ( 'non-empty' ) . classList . add ( 'hidden' ) ;
48
+ } ,
49
+ hideEmptyMessage : function ( ) {
50
+ if ( ! this . rendered ) return ;
51
+ this . queryByHook ( 'empty' ) . classList . add ( 'hidden' ) ;
52
+ this . queryByHook ( 'non-empty' ) . classList . remove ( 'hidden' ) ;
53
+ } ,
54
+ onSchemaSync : function ( ) {
55
+ ( this . schema . sample_size === 0 ) ? this . showEmptyMessage ( ) : this . hideEmptyMessage ( ) ;
56
+ } ,
45
57
initialize : function ( ) {
46
58
app . statusbar . watch ( this , this . schema ) ;
59
+ this . listenTo ( this . schema , 'sync' , this . onSchemaSync . bind ( this ) ) ;
60
+ this . listenTo ( this . schema , 'request' , this . hideEmptyMessage . bind ( this ) ) ;
47
61
this . listenTo ( app . queryOptions , 'change' , this . onQueryChanged . bind ( this ) ) ;
48
62
this . listenToAndRun ( this . parent , 'change:ns' , this . onCollectionChanged . bind ( this ) ) ;
49
63
} ,
@@ -55,7 +69,7 @@ var MongoDBCollectionView = View.extend({
55
69
return ;
56
70
}
57
71
this . visible = true ;
58
-
72
+ this . hideEmptyMessage ( ) ;
59
73
this . schema . ns = this . model . _id = ns ;
60
74
debug ( 'updating namespace to `%s`' , ns ) ;
61
75
this . schema . reset ( ) ;
0 commit comments