diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-02-11 19:02:27 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-02-11 19:02:27 +0100 |
commit | 667351f1c0ead74db79f85fe396e522e6365f109 (patch) | |
tree | b8209fe1d6b34adf56b5128a66dc27c91d9e2770 /ishtar_common/static/js | |
parent | ea393e93b5fb421833eef06acbc2760d538d09f9 (diff) | |
download | Ishtar-667351f1c0ead74db79f85fe396e522e6365f109.tar.bz2 Ishtar-667351f1c0ead74db79f85fe396e522e6365f109.zip |
Galery: Fix pagination (refs #4403) - no data message
Diffstat (limited to 'ishtar_common/static/js')
-rw-r--r-- | ishtar_common/static/js/ishtar.js | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 3649960c0..9a50a4160 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -75,6 +75,7 @@ var entries_msg = "entries"; var info_entries_msg = "entrie(s)"; var table_to_msg = "to"; var table_of_msg = "of"; +var no_data_gallery_msg = "No data available in the gallery"; var activate_all_search_msg = "Searches in the shortcut menu deals with all items."; var activate_own_search_msg = "Searches in the shortcut menu deals with only your items."; var added_message = " items added."; @@ -1052,11 +1053,17 @@ var render_gallery = function(data_table, table_name, nb_select, gallery_id){ var page_total = data_table['total']; var page_current = data_table['page']; + var recordsTotal = data_table['recordsTotal']; html += "<span class='ishtar-gallery-info'>"; - html += info_show_msg + " " + ((page_current - 1) * nb_select + 1) + " " - html += table_to_msg + " " + page_current * nb_select; - - var recordsTotal = number_with_commas(data_table['recordsTotal']); + console.log(data_table); + var page_min = ((page_current - 1) * nb_select + 1); + if (page_min > recordsTotal) page_min = recordsTotal; + html += info_show_msg + " " + page_min + " "; + var page_max = page_current * nb_select; + if (page_max > recordsTotal) page_max = recordsTotal; + html += table_to_msg + " " + page_max; + + var recordsTotal = number_with_commas(recordsTotal); html += " " + table_of_msg + " " + recordsTotal + " "; html += info_entries_msg + "</span>"; @@ -1064,6 +1071,10 @@ var render_gallery = function(data_table, table_name, nb_select, gallery_id){ var captions = '<div class="lightgallery-captions">'; var table_cols = data_table["table-cols"]; + if(!data_table["rows"].length){ + html += "<div class='no-data'>" + no_data_gallery_msg + "</div>"; + } + $.each(data_table["rows"], function(idx, data){ var thumb = ""; if ("main_image__thumbnail" in data){ @@ -1120,12 +1131,11 @@ var render_gallery = function(data_table, table_name, nb_select, gallery_id){ var disabled = page_current == 1; html += render_paginate_button(page_current - 1, page_current, "Previous", disabled, " previous"); - html += render_paginate_button(1, page_current); - var idx_page = 2; + var idx_page = 1; if (page_current < 5){ while (idx_page <= 5){ - if (idx_page <= page_total){ + if (idx_page < page_total){ html += render_paginate_button(idx_page, page_current); } idx_page += 1; @@ -1190,8 +1200,7 @@ var current_image_page = 1; var register_image_gallery = function(gallery_id){ $(".image-pagination .paginate_button a").click(function(){ - current_image_page = $(this).attr('data-dt-idx'); - gallery_submit_search(); + gallery_submit_search($(this).attr('data-dt-idx')); }); lightGallery(document.getElementById(gallery_id), {selector: '.thumb-image'}); |