Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] MSTR-320: Fix table paging position and value when there are no rows #1236

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
MSTR-320: Fix table paging position and value when there are no rows
  • Loading branch information
guillegr123 committed Aug 19, 2024
commit 40f4c9e7134c5b093cf7fe468ac74e7b9db37d43
4 changes: 2 additions & 2 deletions src/apps/core/views/monster-table-paging.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</li>
</ul>
<div class="divider"></div>
<span class="label label-default">1-{{rowCount}} of {{rowCount}}</span>
<span class="label label-default">{{#compare rowCount "===" 0}}0{{else}}1{{/compare}}-{{rowCount}} of {{rowCount}}</span>
</div>
</td>
</td>
</tr>
14 changes: 11 additions & 3 deletions src/js/lib/monster.ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2868,15 +2868,23 @@ define(function(require) {
// If we gave a selector with many table, we need to add the component to each table, so we need to loop thru each table included in the jquery selector
$.each(table, function(k, singleTable) {
var $singleTable = $(singleTable),
$tablePaging = $singleTable.find('.footable-paging td');
$tablePaging = $singleTable.find('.footable-paging td'),
rowCount = footable.get($singleTable).rows.all.length;

if ($tablePaging.length === 0) {
var cols = 0;

$singleTable.find('tbody > tr:first > td').each(function() {
var colspanStr = $(this).attr('colspan');
cols += (_.parseInt(colspanStr) || 1);
});

$singleTable.find('tfoot').append(
$(monster.template(
monster.apps.core, 'monster-table-paging',
{
cols: $singleTable.find('tbody > tr:first > td').length,
rowCount: footable.get($singleTable).rows.all.length
cols: cols,
rowCount: rowCount
}
))
);
Expand Down