From c44970e97a88198018270c5eb64cf15a21a5dea4 Mon Sep 17 00:00:00 2001 From: "Mr. Senko" Date: Sun, 13 Jan 2019 15:28:33 +0200 Subject: [PATCH] Implement Bugs card for Test Case page. Refs #18 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! --- tcms/testcases/static/testcases/js/get.js | 31 +++++++++++++++++++++ tcms/testcases/templates/testcases/get.html | 31 +++++++++++++-------- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/tcms/testcases/static/testcases/js/get.js b/tcms/testcases/static/testcases/js/get.js index 5decacaf2c..ecc39265b7 100644 --- a/tcms/testcases/static/testcases/js/get.js +++ b/tcms/testcases/static/testcases/js/get.js @@ -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 @@ -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 '' + name + ''; + } + }, + ], + dom: "t", + language: { + loadingRecords: '
', + processing: '
', + zeroRecords: "No records found" + }, + order: [[ 0, 'asc' ]], + }); }); diff --git a/tcms/testcases/templates/testcases/get.html b/tcms/testcases/templates/testcases/get.html index a3a6fc5aa2..67e736a995 100644 --- a/tcms/testcases/templates/testcases/get.html +++ b/tcms/testcases/templates/testcases/get.html @@ -16,6 +16,7 @@

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 }}: {{ test_case.summary }}

@@ -152,6 +153,25 @@

+
+
+

+ + {% trans 'Bugs' %} +

+ +
+ + + + + + +
{% trans 'Bug URL' %}
+
+
+
+

@@ -176,17 +196,6 @@

-
-
-

- - {% trans 'Bugs' %} -

- -
-
-
-