@@ -56,10 +56,14 @@ define(function(require){
5656
5757 initPaging : function ( ) {
5858 var $item = new AssetItemView ( { model : new AssetModel ( ) } ) . $el ;
59+ $item . css ( {
60+ visibility : 'hidden'
61+ } ) . appendTo ( 'body' ) ;
5962 var containerHeight = $ ( '.asset-management-assets-container' ) . outerHeight ( ) ;
6063 var itemHeight = $item . outerHeight ( true ) ;
6164 var columns = Math . floor ( $ ( '.asset-management-assets-container' ) . outerWidth ( ) / $item . outerWidth ( true ) ) ;
62- var rows = Math . floor ( containerHeight / itemHeight ) ;
65+ var rows = Math . max ( 1 , Math . ceil ( containerHeight / itemHeight ) ) ;
66+ $item . remove ( ) ;
6367 // columns stack nicely, but need to add extra row if it's not a clean split
6468 if ( ( containerHeight % itemHeight ) > 0 ) rows ++ ;
6569 this . pageSize = columns * rows ;
@@ -90,11 +94,11 @@ define(function(require){
9094 this . isCollectionFetching = true ;
9195
9296 this . collection . customQuery . tags = { $all : this . tags } ;
93-
97+
9498 if ( this . search ) {
9599 this . collection . customQuery . $or = [
96100 { title : { $regex : `.*${ this . search . toLowerCase ( ) } .*` , $options : 'i' } } ,
97- { description : { $regex : `.*${ this . search . toLowerCase ( ) } .*` , $options : 'i' } }
101+ { description : { $regex : `.*${ this . search . toLowerCase ( ) } .*` , $options : 'i' } }
98102 ]
99103 } else {
100104 delete this . collection . customQuery . $or ;
@@ -111,19 +115,19 @@ define(function(require){
111115 sort : this . sort
112116 } ) ;
113117 await this . tagsCollection . fetch ( ) ;
114-
118+
115119 this . collection . fetch ( {
116120 success : _ . bind ( function ( collection , response ) {
117121 this . allAssets . push ( ...collection . models ) ;
118122 this . isCollectionFetching = false ;
119123 // stop further fetching if this is the last page
120124 if ( response . length < this . pageSize ) this . shouldStopFetches = true ;
121-
125+
122126 $ ( '.asset-management-no-assets' ) . toggleClass ( 'display-none' , this . allAssets . length > 0 ) ;
123-
127+
124128 this . $ ( '.asset-management-list-item' ) . remove ( ) ;
125129 this . allAssets . forEach ( a => this . appendAssetItem ( a ) ) ;
126-
130+
127131 this . isCollectionFetching = false ;
128132
129133 Origin . trigger ( 'assetManagement:assetManagementCollection:fetched' ) ;
0 commit comments