Skip to content

Commit

Permalink
Implement Bugs card for Test Case page. Refs #18
Browse files Browse the repository at this point in the history
Note: this is missing the add/remove functionality for now.
Bug.remove is very powerful and can remove bugs that are
attached to a TC but not coming from executions and also
bugs that are coming from executions.

Adding bugs is the reverse operation and I'm not quite sure how
that functionality is used outside test runs!
  • Loading branch information
atodorov committed Jan 13, 2019
1 parent b9aa6c9 commit c44970e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
31 changes: 31 additions & 0 deletions tcms/testcases/static/testcases/js/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,19 @@ function addComponent(object_id, _input, to_table) {


$(document).ready(function() {
var bug_systems_cache = {}
jsonRPC('BugSystem.filter', {}, function(data) {
data.forEach(function(element) {
bug_systems_cache[element.id] = element
});
});

var case_id = $('#test_case_pk').data('pk');
var product_id = $('#product_pk').data('pk');
var perm_remove_tag = $('#test_case_pk').data('perm-remove-tag') === 'True';
var perm_remove_component = $('#test_case_pk').data('perm-remove-component') === 'True';
var perm_remove_plan = $('#test_case_pk').data('perm-remove-plan') === 'True';
var perm_remove_bug = $('#test_case_pk').data('perm-remove-bug') === 'True';


// tags table
Expand Down Expand Up @@ -213,4 +221,27 @@ $(document).ready(function() {
});
});

// bugs table
var bugs_table = $('#bugs').DataTable({
ajax: function(data, callback, settings) {
dataTableJsonRPC('Bug.filter', {case: case_id}, callback);
},
columns: [
{
data: null,
render: function (data, type, full, meta) {
var url = bug_systems_cache[data.bug_system_id].url_reg_exp.replace('%s', data.bug_id).replace('%d', data.bug_id);
var name = bug_systems_cache[data.bug_system_id].name + ' #' + data.bug_id;
return '<a href="' + url + '">' + name + '</a>';
}
},
],
dom: "t",
language: {
loadingRecords: '<div class="spinner spinner-lg"></div>',
processing: '<div class="spinner spinner-lg"></div>',
zeroRecords: "No records found"
},
order: [[ 0, 'asc' ]],
});
});
31 changes: 20 additions & 11 deletions tcms/testcases/templates/testcases/get.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h1 class="col-md-12" style="margin-top: 0">
data-perm-remove-tag="{{ perms.testcases.delete_testcasetag }}"
data-perm-remove-component="{{ perms.testcases.delete_testcasecomponent }}"
data-perm-remove-plan="{{ perms.testcases.delete_testcaseplan }}"
data-perm-remove-bug="{{ perms.testcases.delete_bug }}"
>TC-{{ test_case.pk }}:</span> {{ test_case.summary }}
</h1>

Expand Down Expand Up @@ -152,6 +153,25 @@ <h2 class="card-pf-title">
</div>

<div class="row row-cards-pf">
<div class="col-xs-12 col-sm-6 col-md-3">
<div class="card-pf card-pf-accented">
<h2 class="card-pf-title">
<span class="fa fa-bug"></span>
{% trans 'Bugs' %}
</h2>

<div class="card-pf-body">
<table class="table" id="bugs">
<thead>
<tr>
<th>{% trans 'Bug URL' %}</th>
</tr>
</thead>
</table>
</div>
</div>
</div>

<div class="col-xs-12 col-sm-6 col-md-9">
<div class="card-pf card-pf-accented">
<h2 class="card-pf-title">
Expand All @@ -176,17 +196,6 @@ <h2 class="card-pf-title">
</div>
</div>

<div class="col-xs-12 col-sm-6 col-md-3">
<div class="card-pf card-pf-accented">
<h2 class="card-pf-title">
<span class="fa fa-bug"></span>
{% trans 'Bugs' %}
</h2>

<div class="card-pf-body">
</div>
</div>
</div>
</div>

<div class="row row-cards-pf">
Expand Down

0 comments on commit c44970e

Please sign in to comment.