Add pagination links

This commit is contained in:
Bat
2018-07-25 14:29:34 +02:00
parent 5549e4d0e5
commit 04dac6f87f
8 changed files with 47 additions and 1 deletions
+9
View File
@@ -61,6 +61,15 @@ impl Page {
}
}
/// Computes the total number of pages needed to display n_items
pub fn total(n_items: i32) -> i32 {
if n_items % ITEMS_PER_PAGE == 0 {
n_items / ITEMS_PER_PAGE
} else {
(n_items / ITEMS_PER_PAGE) + 1
}
}
pub fn limits(&self) -> (i32, i32) {
((self.page - 1) * ITEMS_PER_PAGE, self.page * ITEMS_PER_PAGE)
}