[Rt-commit] rt branch, 4.4/history-scroll-load-all, created. rt-4.4.1-98-g06cbf25

Dustin Graves dustin at bestpractical.com
Tue Aug 9 17:52:31 EDT 2016


The branch, 4.4/history-scroll-load-all has been created
        at  06cbf256f5b53d1d3e366cdd61223280e52b86b2 (commit)

- Log -----------------------------------------------------------------
commit 06cbf256f5b53d1d3e366cdd61223280e52b86b2
Author: Dustin Graves <dustin at bestpractical.com>
Date:   Fri Aug 5 22:17:23 2016 +0000

    add "Load All" button to "as you scroll" history mode
    
    Fixes: I#32094

diff --git a/share/html/Elements/ShowHistoryHeader b/share/html/Elements/ShowHistoryHeader
index 8954bc8..b05c75b 100644
--- a/share/html/Elements/ShowHistoryHeader
+++ b/share/html/Elements/ShowHistoryHeader
@@ -50,6 +50,7 @@ $Object
 $ShowHeaders       => 0
 $ShowTitle         => 1
 $ShowDisplayModes  => 1
+$ScrollShowHistory => 0
 </%ARGS>
 <%INIT>
 my $record_type = $Object->RecordType;
@@ -85,6 +86,14 @@ if ( $ShowDisplayModes or $ShowTitle ) {
                            qq{</a>};
         }
     }
+
+if ( $ScrollShowHistory ) {
+    $titleright .= qq{<span id="LoadAllHistoryContainer">} .
+                   ($titleright ? '—' : '') .
+                   qq{<a href="#" id="LoadAllHistory">} .
+                   loc('Load All') .
+                   qq{</a></span>};
+}
 </%perl>
 <& /Widgets/TitleBoxStart, title => $title, titleright_raw => $titleright &>
 % }
diff --git a/share/html/Helpers/TicketHistoryPage b/share/html/Helpers/TicketHistoryPage
index e4e7411..17a55a4 100644
--- a/share/html/Helpers/TicketHistoryPage
+++ b/share/html/Helpers/TicketHistoryPage
@@ -50,6 +50,7 @@ $id
 $oldestTransactionsFirst => RT->Config->Get("OldestTransactionsFirst", $session{CurrentUser});
 $lastTransactionId => undef
 $focusTransactionId => undef
+$loadAll => 0
 </%ARGS>
 <%INIT>
 my $TicketObj = RT::Ticket->new($session{'CurrentUser'});
@@ -82,7 +83,7 @@ if ($focusTransactionId) { # make sure we load enough if we need to focus a tran
         OPERATOR => $oldestTransactionsFirst ? '<=' : '>=',
         VALUE    => $focusTransactionId
     );
-} else { # otherwise, just load the standard page of 10 transactions
+} elsif (!$loadAll) { # otherwise, just load the standard page of 10 transactions
     $transactions->RowsPerPage(10);
     $transactions->FirstPage();
 }
diff --git a/share/html/Ticket/Elements/ScrollShowHistory b/share/html/Ticket/Elements/ScrollShowHistory
index a6687c3..03bdc95 100644
--- a/share/html/Ticket/Elements/ScrollShowHistory
+++ b/share/html/Ticket/Elements/ScrollShowHistory
@@ -71,6 +71,7 @@ my $oldestTransactionsFirst = RT->Config->Get("OldestTransactionsFirst", $sessio
     ShowHeaders       => $ShowHeaders,
     ShowTitle         => $ShowTitle,
     ShowDisplayModes  => $ShowDisplayModes,
+    ScrollShowHistory => 1,
     &>
 
 </div>
@@ -86,7 +87,8 @@ jQuery(function(){
         loadDistanceFromBottom = 1500, // to load before bottom of page is reached
         lastTransactionId = null,
         hash = window.location.hash,
-        hashTransactionId = null;
+        hashTransactionId = null,
+        loadAll = false;
 
     var oldestTransactionsFirst = <% $oldestTransactionsFirst || 0 %>;
 
@@ -123,6 +125,10 @@ jQuery(function(){
 
         var queryString = '&oldestTransactionsFirst=' + oldestTransactionsFirst;
         if (lastTransactionId) queryString += '&lastTransactionId=' + lastTransactionId;
+        if (loadAll) queryString += '&loadAll=1';
+
+        // don't load all over and over again
+        loadAll = false;
 
         // check for link to specific transaction and make sure we load enough to focus it
         if (hash && !lastTransactionId) {
@@ -147,10 +153,17 @@ jQuery(function(){
                     }
                 } else {
                     disableLoading = true;
+
+                    // hide 'Load All' link container if we're done loading
+                    var loadAllHistoryContainer = jQuery('#LoadAllHistoryContainer');
+                    loadAllHistoryContainer.hide();
                 }
 
                 isLoading = false;
                 removeLoadingMessage();
+
+                // make sure we load all if we clicked the "Load All" button while we were already loading
+                if (loadAll) loadHistoryPage();
             },
             error: function(xhr, reason) {
                 isLoading = false;
@@ -159,6 +172,14 @@ jQuery(function(){
         });
     };
 
+    var loadAllHistory = function() {
+        // hide link container
+        var loadAllHistoryContainer = jQuery('#LoadAllHistoryContainer');
+        loadAllHistoryContainer.hide();
+        loadAll = true;
+        loadHistoryPage();
+    };
+
     jQuery(window).scroll(function() {
         if(jQuery(window).scrollTop() >= jQuery(document).height() - jQuery(window).height() - loadDistanceFromBottom) {
             loadHistoryPage();
@@ -172,6 +193,11 @@ jQuery(function(){
         loadHistoryPage();
     });
 
+    jQuery('div.history').on('click', '#LoadAllHistory', function(e) {
+        e.preventDefault();
+        loadAllHistory();
+    });
+
     loadHistoryPage();
 });
 </script>

-----------------------------------------------------------------------


More information about the rt-commit mailing list