cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject git commit: updated refs/heads/master to ad051e8
Date Wed, 02 Jul 2014 23:03:39 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 1f7a81844 -> ad051e850


List view: Fix infinite scrolling

Fixes condition where, on 'refresh' of list view, infinite scrolling no longer
works due to leftover state prior to refresh. Now page # and end-of-list
indicator are stores in DOM object, for easier cleanup


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ad051e85
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ad051e85
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ad051e85

Branch: refs/heads/master
Commit: ad051e850409fe1b8d2a2f0d964822f59580280c
Parents: 1f7a818
Author: Brian Federle <brian.federle@citrix.com>
Authored: Wed Jul 2 16:02:52 2014 -0700
Committer: Brian Federle <brian.federle@citrix.com>
Committed: Wed Jul 2 16:02:52 2014 -0700

----------------------------------------------------------------------
 ui/scripts/ui/widgets/listView.js | 44 +++++++++++++++-------------------
 1 file changed, 19 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad051e85/ui/scripts/ui/widgets/listView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js
index 2ea817a..415169a 100644
--- a/ui/scripts/ui/widgets/listView.js
+++ b/ui/scripts/ui/widgets/listView.js
@@ -1035,6 +1035,7 @@
         var subselect = uiCustom ? listViewArgs.listView.subselect : null;
 
         if (!(data && data.length)) {
+            $listView.data('end-of-table', true);
             if (!$tbody.find('tr').size()) {
                 return [
                     $('<tr>').addClass('empty last').append(
@@ -1502,6 +1503,7 @@
         var reorder = options.reorder;
         var multiSelect = options.multiSelect;
         var $tbody = $table.find('tbody');
+        var $listView = $table.closest('.list-view');
 
         if (!loadArgs) loadArgs = {
             page: 1,
@@ -1512,11 +1514,16 @@
             }
         };
 
+        if (options.clearEndTable) {
+            $listView.data('page', 1);
+            $table.closest('.list-view').data('end-of-table', false);
+        }
+
         if (!append) {
             if (!append) $table.find('tbody tr').remove();
         }
 
-        var viewArgs = $table.closest('.list-view').data('view-args');
+        var viewArgs = $listView.data('view-args');
         var uiCustom = viewArgs.listView ? viewArgs.listView.uiCustom : false;
 
         setLoading($table, function(setLoadingArgs) {
@@ -1539,12 +1546,6 @@
                             noSelect: uiCustom
                         });
 
-                        if (args.data &&
-                            args.data.length < pageSize &&
-                            options.setEndTable) {
-                            options.setEndTable();
-                        }
-
                         setTimeout(function() {
                             $table.dataTable('refresh');
                         });
@@ -1686,16 +1687,13 @@
         var $toolbar = $('<div>').addClass('toolbar').appendTo($listView);
         var $table = $('<table>').appendTo($listView);
         var infScrollTimer;
-        var page = 1;
         var actions = listViewData.actions;
         var reorder = listViewData.reorder;
         var multiSelect = listViewData.multiSelect;
         var tableHeight = $table.height();
-        var endTable = false;
-        var setEndTable = function() {
-            endTable = true;
-        }
 
+        $listView.data('end-of-table', false);
+        $listView.data('page', 1);
 
         var $switcher;
         if (args.sections) {
@@ -1794,7 +1792,7 @@
             listViewData.preFilter,
             listViewData.fields,
             false, {
-                page: page,
+                page: $listView.data('page'),
                 filterBy: {
                     kind: $listView.find('select[id=filterBy]').val(),
                     search: {
@@ -1808,7 +1806,6 @@
                 context: args.context,
                 reorder: reorder,
                 detailView: listViewData.detailView,
-                setEndTable: setEndTable,
                 'multiSelect': multiSelect,
                 noActionCol: listViewData.noActionCol
             }
@@ -1842,14 +1839,14 @@
         var basicSearch = function() {
             $listView.removeData('advSearch');
 
-            page = 1;
+            $listView.data('page', 1);
             loadBody(
                 $table,
                 listViewData.dataProvider,
                 listViewData.preFilter,
                 listViewData.fields,
                 false, {
-                    page: page,
+                    page: $listView.data('page'),
                     filterBy: {
                         kind: $listView.find('select[id=filterBy]').val(),
                         search: {
@@ -1862,7 +1859,6 @@
                     context: $listView.data('view-args').context,
                     reorder: listViewData.reorder,
                     detailView: listViewData.detailView,
-                    setEndTable: setEndTable,
                     'multiSelect': multiSelect,
                     noActionCol: listViewData.noActionCol
                 }
@@ -1895,15 +1891,14 @@
         //advanced search
         var advancedSearch = function(args) {
             $listView.data('advSearch', args.data);
-
-            page = 1;
+            $listView.data('page', 1);
             loadBody(
                 $table,
                 listViewData.dataProvider,
                 listViewData.preFilter,
                 listViewData.fields,
                 false, {
-                    page: page,
+                    page: $listView.data('page'),
                     filterBy: {
                         kind: $listView.find('select[id=filterBy]').val(),
                         advSearch: args.data
@@ -1913,7 +1908,6 @@
                     context: $listView.data('view-args').context,
                     reorder: listViewData.reorder,
                     detailView: listViewData.detailView,
-                    setEndTable: setEndTable,
                     'multiSelect': multiSelect,
                     noActionCol: listViewData.noActionCol
                 }
@@ -1979,8 +1973,8 @@
                 var loadMoreData = $listView.scrollTop() >= ($table.height() - $listView.height())
- $listView.height() / 4;
                 var context = $listView.data('view-args').context;
 
-                if (loadMoreData && !endTable) {
-                    page = page + 1;
+                if (loadMoreData && !$listView.data('end-of-table')) {
+                    $listView.data('page', $listView.data('page') + 1);
 
                     var filterBy = {
                         kind: $listView.find('select[id=filterBy]').length > 0 ? $listView.find('select[id=filterBy]').val()
: 'all'
@@ -2000,12 +1994,11 @@
                         listViewData.preFilter,
                         listViewData.fields, true, {
                             context: context,
-                            page: page,
+                            page: $listView.data('page'),
                             filterBy: filterBy
                         }, actions, {
                             reorder: listViewData.reorder,
                             detailView: listViewData.detailView,
-                            setEndTable: setEndTable,
                             'multiSelect': multiSelect,
                             noActionCol: listViewData.noActionCol
                         });
@@ -2272,6 +2265,7 @@
                 false,
                 null,
                 listViewArgs.actions, {
+                    clearEndTable: true,
                     multiSelect: listViewArgs.multiSelect,
                     context: this.data('view-args').context,
                     detailView: listViewArgs.detailView


Mime
View raw message