From 54fcd2361fad763bc37ed4ab592b592e1d9045bd Mon Sep 17 00:00:00 2001 From: Rady Date: Wed, 11 Nov 2020 23:52:55 +0200 Subject: [PATCH] Select testplan data element only once --- tcms/testplans/static/testplans/js/get.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tcms/testplans/static/testplans/js/get.js b/tcms/testplans/static/testplans/js/get.js index 32e29c8a18..faf78fddfe 100644 --- a/tcms/testplans/static/testplans/js/get.js +++ b/tcms/testplans/static/testplans/js/get.js @@ -8,16 +8,17 @@ let testCaseStatusConfirmedPK = null; $(document).ready(function() { - testCaseStatusConfirmedPK = Number($('#test_plan_pk').data('testcasestatus-confirmed-pk')); + const testPlanDataElement = $('#test_plan_pk'); + testCaseStatusConfirmedPK = Number(testPlanDataElement.data('testcasestatus-confirmed-pk')); - const testPlanId = $('#test_plan_pk').data('testplan-pk'); + const testPlanId = testPlanDataElement.data('testplan-pk'); const permissions = { - 'perm-change-testcase': $('#test_plan_pk').data('perm-change-testcase') === 'True', - 'perm-remove-testcase': $('#test_plan_pk').data('perm-remove-testcase') === 'True', - 'perm-add-testcase': $('#test_plan_pk').data('perm-add-testcase') === 'True', - 'perm-add-comment': $('#test_plan_pk').data('perm-add-comment') === 'True', - 'perm-delete-comment': $('#test_plan_pk').data('perm-delete-comment') === 'True' + 'perm-change-testcase': testPlanDataElement.data('perm-change-testcase') === 'True', + 'perm-remove-testcase': testPlanDataElement.data('perm-remove-testcase') === 'True', + 'perm-add-testcase': testPlanDataElement.data('perm-add-testcase') === 'True', + 'perm-add-comment': testPlanDataElement.data('perm-add-comment') === 'True', + 'perm-delete-comment': testPlanDataElement.data('perm-delete-comment') === 'True' }; $('#btn-search-cases').click(function () { @@ -25,7 +26,7 @@ $(document).ready(function() { }); // bind everything in tags table - const perm_remove_tag = $('#test_plan_pk').data('perm-remove-tag') === 'True'; + const perm_remove_tag = testPlanDataElement.data('perm-remove-tag') === 'True'; tagsCard('TestPlan', testPlanId, {plan: testPlanId}, perm_remove_tag); jsonRPC('TestCase.sortkeys', {'plan': testPlanId}, function(sortkeys) {