Skip to content

Commit

Permalink
Show an icon when some child TPs not shown on Search Test Plans page
Browse files Browse the repository at this point in the history
to let the user know what parent-child hierarchies shown on the page
may be incomplete because the data has been filtered out by their search
criteria.

Closes #3313
  • Loading branch information
atodorov committed Nov 27, 2023
1 parent 93cfe6b commit 68740f4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions tcms/testplans/static/testplans/js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export function pageTestplansSearchReadyHandler () {
initializeDateTimePicker('#id_before')
initializeDateTimePicker('#id_after')

const rowsNotShownMessage = $('#main-element').data('trans-some-rows-not-shown')
const table = $('#resultsTable').DataTable({
pageLength: $('#navbar').data('defaultpagesize'),
ajax: function (data, callbackF, settings) {
Expand Down Expand Up @@ -108,6 +109,7 @@ export function pageTestplansSearchReadyHandler () {
data: null,
render: function (data, type, full, meta) {
let result = '<a href="/plan/' + data.id + '/">' + escapeHTML(data.name) + '</a>'
result = result + ` <span class="pficon pficon-rebalance children-not-shown-message" title="${rowsNotShownMessage}"></span>`
if (!data.is_active) {
result = '<strike>' + result + '</strike>'
}
Expand Down Expand Up @@ -136,6 +138,16 @@ export function pageTestplansSearchReadyHandler () {
// very easy to display child rows afterwards! Not a big issue for now.
}
},
drawCallback: function (settings) {
const data = this.api().data()
$('.children-not-shown-message').hide()

data.each(function (row) {
if (row.children__count && row.children__count > hiddenChildRows[row.id].length) {
$(`.test-plan-row-${row.id} .children-not-shown-message`).show()
}
})
},
dom: 'Bptp',
buttons: exportButtons,
language: {
Expand Down
6 changes: 5 additions & 1 deletion tcms/testplans/templates/testplans/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
{% block page_id %}page-testplans-search{% endblock %}

{% block contents %}
<div class="container-fluid container-cards-pf">
<div
class="container-fluid container-cards-pf"
id="main-element"
data-trans-some-rows-not-shown="{% trans 'Some child test plans do not match search criteria'%}"
>
<form class="form-horizontal" method="get">
{% csrf_token %}

Expand Down

0 comments on commit 68740f4

Please sign in to comment.