Merge "Added the pagination info at top of the table"

This commit is contained in:
Jenkins 2016-09-24 00:59:45 +00:00 committed by Gerrit Code Review
commit 03ba8d2820
5 changed files with 32 additions and 20 deletions

View File

@ -21,6 +21,13 @@
<table class="table table-striped table-rsp table-detail">
<thead>
<!--
This is where we display number of items and pagination controls in
the header.
-->
<tr>
<td hz-table-footer colspan="100" items="items"></td>
</tr>
<!--
Table-column-headers:
Set selectAll to True if you want to enable select all checkbox.

View File

@ -61,12 +61,12 @@
it('has the correct number of column headers', function() {
var $element = digestMarkup($scope, $compile, markup);
expect($element).toBeDefined();
expect($element.find('thead tr:eq(0) th').length).toBe(5);
expect($element.find('thead tr:nth-child(2) th').length).toBe(5);
});
it('displays selectAll checkbox when config selectAll set to True', function() {
var $element = digestMarkup($scope, $compile, markup);
expect($element.find('thead tr:eq(0) th:first input').attr(
expect($element.find('thead tr:nth-child(2) th:first input').attr(
'hz-select-all')).toBe('items');
});
@ -82,12 +82,12 @@
]
};
var $element = digestMarkup($scope, $compile, markup);
expect($element.find('thead tr:eq(0) th:first').hasClass('ng-hide')).toBe(true);
expect($element.find('thead tr:nth-child(2) th:first').hasClass('ng-hide')).toBe(true);
});
it('displays expander when config expand set to True', function() {
var $element = digestMarkup($scope, $compile, markup);
expect($element.find('thead tr:eq(0) th:eq(1)').hasClass('expander')).toBe(true);
expect($element.find('thead tr:nth-child(2) th:eq(1)').hasClass('expander')).toBe(true);
});
it('does not display expander when config expand set to False', function() {
@ -102,7 +102,7 @@
]
};
var $element = digestMarkup($scope, $compile, markup);
expect($element.find('thead tr:eq(0) th:eq(1)').hasClass('ng-hide')).toBe(true);
expect($element.find('thead tr:nth-child(2) th:eq(1)').hasClass('ng-hide')).toBe(true);
});
it('has the correct responsive priority classes', function() {

View File

@ -23,6 +23,7 @@
</tr>
{% endif %}
{% endblock table_breadcrumb %}
{% include "horizon/common/_data_table_pagination.html" %}
{% block table_columns %}
{% if not table.is_browser_table %}
<tr class="table_column_header">
@ -69,20 +70,7 @@
{% endfor %}
</tr>
{% endif %}
<tr>
<td colspan="{{ columns|length }}">
<span class="table_count">{% blocktrans count counter=rows|length %}Displaying {{ counter }} item{% plural %}Displaying {{ counter }} items{% endblocktrans %}</span>
{% if table.has_prev_data or table.has_more_data %}
<span class="spacer">|</span>
{% endif %}
{% if table.has_prev_data %}
<a href="?{{ table.get_prev_pagination_string }}">{% trans "&laquo;&nbsp;Prev" %}</a>
{% endif %}
{% if table.has_more_data %}
<a href="?{{ table.get_pagination_string }}">{% trans "Next&nbsp;&raquo;" %}</a>
{% endif %}
</td>
</tr>
{% include "horizon/common/_data_table_pagination.html" %}
</tfoot>
{% endif %}
{% endblock table_footer %}

View File

@ -0,0 +1,17 @@
{% load i18n %}
<tr>
<td colspan="{{ columns|length }}">
<span class="table_count">{% blocktrans count counter=rows|length %}
Displaying {{ counter }} item{% plural %}
Displaying {{ counter }} items{% endblocktrans %}</span>
{% if table.has_prev_data or table.has_more_data %}
<span class="spacer">|</span>
{% endif %}
{% if table.has_prev_data %}
<a href="?{{ table.get_prev_pagination_string }}">{% trans "&laquo;&nbsp;Prev" %}</a>
{% endif %}
{% if table.has_more_data %}
<a href="?{{ table.get_pagination_string }}">{% trans "Next&nbsp;&raquo;" %}</a>
{% endif %}
</td>
</tr>

View File

@ -273,7 +273,7 @@ class TabTests(test.TestCase):
req = self.factory.get("/")
res = view(req)
self.assertContains(res, "<table", 1)
self.assertContains(res, "Displaying 4 items", 1)
self.assertContains(res, "Displaying 4 items", 2)
# AJAX response to GET for row update
params = {"table": "my_table", "action": "row_update", "obj_id": "1"}