expose totalPages and totalEntries, and use the later to display

connections count
This commit is contained in:
howard-stearns 2018-07-10 11:26:23 -07:00
parent 1d33f51ca4
commit 886df959d1
2 changed files with 8 additions and 2 deletions

View file

@ -765,7 +765,7 @@ Rectangle {
TableViewColumn { TableViewColumn {
id: connectionsUserNameHeader; id: connectionsUserNameHeader;
role: "userName"; role: "userName";
title: connectionsTable.rowCount + (connectionsTable.rowCount === 1 ? " NAME" : " NAMES"); title: connectionsUserModel.totalEntries + (connectionsUserModel.totalEntries === 1 ? " NAME" : " NAMES");
width: connectionsNameCardWidth; width: connectionsNameCardWidth;
movable: false; movable: false;
resizable: false; resizable: false;

View file

@ -51,6 +51,8 @@ ListModel {
if (!delayedClear) { root.clear(); } if (!delayedClear) { root.clear(); }
currentPageToRetrieve = 1; currentPageToRetrieve = 1;
retrievedAtLeastOnePage = false; retrievedAtLeastOnePage = false;
totalPages = 0;
totalEntries = 0;
} }
// Page processing. // Page processing.
@ -59,6 +61,8 @@ ListModel {
property var processPage: function (data) { return data; } property var processPage: function (data) { return data; }
property var listView; // Optional. For debugging. property var listView; // Optional. For debugging.
property int totalPages: 0;
property int totalEntries: 0;
// Check consistency and call processPage. // Check consistency and call processPage.
function handlePage(error, response) { function handlePage(error, response) {
var processed; var processed;
@ -79,8 +83,10 @@ ListModel {
if (response.current_page && response.current_page !== currentPageToRetrieve) { // Not all endpoints specify this property. if (response.current_page && response.current_page !== currentPageToRetrieve) { // Not all endpoints specify this property.
return fail("Mismatched page, expected:" + currentPageToRetrieve); return fail("Mismatched page, expected:" + currentPageToRetrieve);
} }
totalPages = response.total_pages;
totalEntries = response.total_entries;
processed = processPage(response.data || response); processed = processPage(response.data || response);
if (response.total_pages && (response.total_pages === currentPageToRetrieve)) { if (totalPages && (totalPages === currentPageToRetrieve)) {
currentPageToRetrieve = -1; currentPageToRetrieve = -1;
} }