diff --git a/php/Job/Space/Select.php b/php/Job/Space/Select.php index 2189851..e061bc5 100644 --- a/php/Job/Space/Select.php +++ b/php/Job/Space/Select.php @@ -24,7 +24,8 @@ public function run() } $data = null; - $total = 0; + $total = null; + $next = false; try { $criteria = Criteria::index($this->index) @@ -54,7 +55,11 @@ public function run() [$total] = $this->getMapper()->getClient() ->call("box.space.$this->space.index.$indexName:count", $key); } catch (Exception $e) { - // ignore total calculation exception + $criteria = $criteria->andLimit($this->limit+1); + $extra = $this->getMapper()->getClient()->getSpace($this->space) + ->select($criteria); + // next page flag + $next = count($extra) > count($data); } } catch (Exception $e) { @@ -73,6 +78,6 @@ public function run() } } - return compact('data', 'total'); + return compact('data', 'total', 'next'); } } diff --git a/public/admin/js/Space/toolbar/Collection.js b/public/admin/js/Space/toolbar/Collection.js index afe1e98..e89a883 100644 --- a/public/admin/js/Space/toolbar/Collection.js +++ b/public/admin/js/Space/toolbar/Collection.js @@ -16,23 +16,31 @@ Ext.define('Admin.Space.toolbar.Collection', { var pageCount = Math.ceil(store.getTotalCount() / store.pageSize) || 1; var currentPage = store.currentPage; - this.down('[name=row-counter]').setValue(store.getTotalCount()); + if (store.proxy.lastResponse.total == null) { + this.down('[name=row-counter]').setValue('-'); + this.down('[name=total-pages]').setText('-'); + } else { + this.down('[name=row-counter]').setValue(store.getTotalCount()); + this.down('[name=total-pages]').setText(pageCount); + } - var stats = this.down('[name=paging-stats]'); var first = this.down('[name=first-page]'); var prev = this.down('[name=previous-page]'); var current = this.down('[name=current-page]'); - var delimeter = this.down('[name=current-page-delimiter]'); - var total = this.down('[name=total-pages]'); var next = this.down('[name=next-page]'); var last = this.down('[name=last-page]'); first.setDisabled(currentPage == 1); prev.setDisabled(currentPage == 1); current.setValue(currentPage); - total.setText(pageCount); next.setDisabled(currentPage == pageCount); last.setDisabled(currentPage == pageCount); + + // unknown row count + if (store.proxy.lastResponse.total == null) { + next.setDisabled(!store.proxy.lastResponse.next); + last.setDisabled(true); + } }, getDefaultItems() { @@ -106,9 +114,8 @@ Ext.define('Admin.Space.toolbar.Collection', { labelWidth: 65, name: 'row-counter', readOnly: true, - value: 0, width: 20, - xtype: 'numberfield', + xtype: 'textfield', }, ' ',{ xtype: 'numberfield', minValue: 1, @@ -129,8 +136,8 @@ Ext.define('Admin.Space.toolbar.Collection', { } var store = this.up('grid').store; if (store.pageSize != v) { - this.up('grid').store.setPageSize(v); - this.up('grid').store.loadPage(1); + store.setPageSize(v); + store.loadPage(1); } localStorage.setItem('admin-page-size', v); } @@ -164,7 +171,9 @@ Ext.define('Admin.Space.toolbar.Collection', { keyup(field) { var store = this.up('grid').store; var pageCount = Math.ceil(store.getTotalCount() / store.pageSize); - if(field.value <= pageCount && field.value >= 0) { + if (store.proxy.lastResponse.total == null) { + this.up('grid').store.loadPage(field.value || 1); + } else if (field.value <= pageCount && field.value >= 0) { this.up('grid').store.loadPage(field.value || 1); } else if(field.value > pageCount) { this.up('grid').store.loadPage(pageCount); diff --git a/public/admin/js/data/proxy/PagingDispatch.js b/public/admin/js/data/proxy/PagingDispatch.js index 7d9736b..0781c55 100644 --- a/public/admin/js/data/proxy/PagingDispatch.js +++ b/public/admin/js/data/proxy/PagingDispatch.js @@ -14,6 +14,7 @@ dispatch(this.job, params) .then(response => { + this.lastResponse = response; var resultSet = new Ext.data.ResultSet({ total: response.total, count: (response.data || []).length,