From da319228983b42b4ec530176158e329262950405 Mon Sep 17 00:00:00 2001 From: asurendra Date: Thu, 21 Jan 2016 00:06:09 +0530 Subject: [PATCH] Introduced ajax to view steps to avoid large size html --- .../excord/controller/TestCaseController.java | 9 +++++ .../resources/public/js/custom/testcase.js | 24 ++++++----- .../public/js/custom/testplan_run.js | 15 ++++--- .../resources/templates/testcase.ftl.html | 39 +----------------- .../templates/testcase_step.ftl.html | 34 ++++++++++++++++ .../resources/templates/testplan_run.ftl.html | 40 +------------------ 6 files changed, 68 insertions(+), 93 deletions(-) create mode 100644 src/main/resources/templates/testcase_step.ftl.html diff --git a/src/main/java/com/deem/excord/controller/TestCaseController.java b/src/main/java/com/deem/excord/controller/TestCaseController.java index 802f708..18ed402 100644 --- a/src/main/java/com/deem/excord/controller/TestCaseController.java +++ b/src/main/java/com/deem/excord/controller/TestCaseController.java @@ -657,6 +657,15 @@ public String testcaseEdit(Model model, HttpServletRequest request, HttpSession return "testcase_form"; } + @RequestMapping(value = "/testcase_view", method = RequestMethod.GET) + public String testcaseView(Model model, HttpServletRequest request, HttpSession session, @RequestParam(value = "testcaseId", required = true) Long testcaseId) { + EcTestcase tc = tcDao.findOne(testcaseId); + List tsLst = tsDao.findByTestcaseId(tc); + model.addAttribute("tc", tc); + model.addAttribute("tsLst", tsLst); + return "testcase_step"; + } + @RequestMapping(value = "/testcase_req_link", method = RequestMethod.POST) public String testCaseRequirementLink(Model model, HttpServletRequest request, HttpSession session, @RequestParam(value = "nodeId", required = true) Long nodeId, @RequestParam(value = "testcaseChk") List testcaseChkLst) { String clipboardLinkTc = StringUtils.arrayToCommaDelimitedString(testcaseChkLst.toArray()); diff --git a/src/main/resources/public/js/custom/testcase.js b/src/main/resources/public/js/custom/testcase.js index 7cba0b6..d9ff4fb 100644 --- a/src/main/resources/public/js/custom/testcase.js +++ b/src/main/resources/public/js/custom/testcase.js @@ -1,21 +1,25 @@ $(document).ready(function () { - $(".teststepsTable").hide(); + $(".teststepShow").click(function () { + event.preventDefault(); + var testcaseId = $(this).attr("id"); + if ($("#tcstep_" + testcaseId).html().length > 0) { + $("#tcstep_" + testcaseId).html(""); + } else { + $.ajax({url: "/testcase_view?testcaseId=" + testcaseId, success: function (result) { + $("#tcstep_" + testcaseId).html(result); + } + }); + } + }); + $("#checkAll").click(function (event) { $('input:checkbox').not(this).prop('checked', this.checked); }); - $(".teststepShow").click(function (event) { - event.preventDefault(); - var id = $(this).attr("id"); - $("#teststeps_" + id).toggle(); - }); - - $("#addFolder").click(function (event) { event.preventDefault(); - var folderPath = $("#breadCrumbPath").val(); bootbox.prompt("Parent folder path: " + folderPath + ",
Please enter folder name:", function (result) { if (result !== null) { @@ -35,7 +39,7 @@ $(document).ready(function () { bootbox.alert("Please check a testcase!"); } }); - + $("#linkTestcaseRequirement").click(function (event) { event.preventDefault(); if ($('input[name="testcaseChk"]:checked').length > 0) { diff --git a/src/main/resources/public/js/custom/testplan_run.js b/src/main/resources/public/js/custom/testplan_run.js index 51dfc36..2362769 100644 --- a/src/main/resources/public/js/custom/testplan_run.js +++ b/src/main/resources/public/js/custom/testplan_run.js @@ -1,12 +1,9 @@ $(document).ready(function () { - $(".teststepsTable").hide(); - $("#checkAll").click(function (event) { $('input:checkbox').not(this).prop('checked', this.checked); }); - $("#testplanRunForm").submit(function (event) { if ($('input[name="testcaseChk"]:checked').length <= 0) { bootbox.alert("Please check a testcase!"); @@ -16,9 +13,15 @@ $(document).ready(function () { $(".teststepShow").click(function (event) { event.preventDefault(); - - var id = $(this).attr("id"); - $("#teststeps_" + id).toggle(); + var testcaseId = $(this).attr("id"); + if ($("#tcstep_" + testcaseId).html().length > 0) { + $("#tcstep_" + testcaseId).html(""); + } else { + $.ajax({url: "/testcase_view?testcaseId=" + testcaseId, success: function (result) { + $("#tcstep_" + testcaseId).html(result); + } + }); + } }); }); \ No newline at end of file diff --git a/src/main/resources/templates/testcase.ftl.html b/src/main/resources/templates/testcase.ftl.html index 32772dd..b870abd 100644 --- a/src/main/resources/templates/testcase.ftl.html +++ b/src/main/resources/templates/testcase.ftl.html @@ -140,49 +140,12 @@ - - - - - <#if tc.ecTeststepList??> - <#list tc.ecTeststepList as step> - - - - - - - -
- Description: ${tc.description?replace("\n", "
")} -
- Type: ${tc.caseType} -
- Product: ${tc.product} -
- Feature: ${tc.feature} -
- Added Version: ${tc.addedVersion} -
- Deprecated Version: ${tc.deprecatedVersion} -
- Bug Id: ${tc.bugId} -
- ${step.stepNumber} - - ${step.description?replace("\n", "
")} -
- ${step.expected?replace("\n", "
")} -
+
- - - - diff --git a/src/main/resources/templates/testcase_step.ftl.html b/src/main/resources/templates/testcase_step.ftl.html new file mode 100644 index 0000000..7afe083 --- /dev/null +++ b/src/main/resources/templates/testcase_step.ftl.html @@ -0,0 +1,34 @@ + + + + + <#if tc.ecTeststepList??> + <#list tc.ecTeststepList as step> + + + + + + + +
+ Description: ${tc.description?replace("\n", "
")} +
+ Type: ${tc.caseType} +
+ Product: ${tc.product} +
+ Feature: ${tc.feature} +
+ Added Version: ${tc.addedVersion} +
+ Deprecated Version: ${tc.deprecatedVersion} +
+ Bug Id: ${tc.bugId} +
+ ${step.stepNumber} + + ${step.description?replace("\n", "
")} +
+ ${step.expected?replace("\n", "
")} +
diff --git a/src/main/resources/templates/testplan_run.ftl.html b/src/main/resources/templates/testplan_run.ftl.html index 280038c..d03525b 100644 --- a/src/main/resources/templates/testplan_run.ftl.html +++ b/src/main/resources/templates/testplan_run.ftl.html @@ -117,45 +117,7 @@

Run Test Plan

- - - - - <#if tc.ecTeststepList??> - <#list tc.ecTeststepList as step> - - - - - - - -
- - Description: ${tc.description?replace("\n", "
")} -
- Automated: ${tc.automated?c} -
- Type: ${tc.caseType} -
- Product: ${tc.product} -
- Feature: ${tc.feature} -
- Added Version: ${tc.addedVersion} -
- Deprecated Version: ${tc.deprecatedVersion} -
- Bug Id: ${tc.bugId} -
- Time to Run: ${tc.timeToRun} mins -
- ${step.stepNumber} - - ${step.description?replace("\n", "
")} -
- ${step.expected?replace("\n", "
")} -
+