[Rt-commit] rt branch, 4.4/history-scroll-load-all, created. rt-4.4.1-98-g72c4aa1
Dustin Graves
dustin at bestpractical.com
Fri Aug 5 18:18:32 EDT 2016
The branch, 4.4/history-scroll-load-all has been created
at 72c4aa1ab436b14a98f4e398fdfd3ca32ae6ce4a (commit)
- Log -----------------------------------------------------------------
commit 72c4aa1ab436b14a98f4e398fdfd3ca32ae6ce4a
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/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..31cab5c 100644
--- a/share/html/Ticket/Elements/ScrollShowHistory
+++ b/share/html/Ticket/Elements/ScrollShowHistory
@@ -73,6 +73,11 @@ my $oldestTransactionsFirst = RT->Config->Get("OldestTransactionsFirst", $sessio
ShowDisplayModes => $ShowDisplayModes,
&>
+<div id="LoadAllHistoryContainer">
+ <input class="button" type="button" id="LoadAllHistory" value="Load All" />
+ <br /><br />
+</div>
+
</div>
% if ($ShowDisplayModes or $ShowTitle) {
<& /Widgets/TitleBoxEnd &>
@@ -86,7 +91,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 +129,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 +157,17 @@ jQuery(function(){
}
} else {
disableLoading = true;
+
+ // disable 'Load All' button 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 +176,14 @@ jQuery(function(){
});
};
+ var loadAllHistory = function() {
+ // hide button
+ 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 +197,11 @@ jQuery(function(){
loadHistoryPage();
});
+ jQuery('.history-container').on('click', '#LoadAllHistory', function(e) {
+ e.preventDefault();
+ loadAllHistory();
+ });
+
loadHistoryPage();
});
</script>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list