diff --git a/module/testcase/js/batchedit.js b/module/testcase/js/batchedit.js index 9df9b0827a..2b56dfa9a5 100644 --- a/module/testcase/js/batchedit.js +++ b/module/testcase/js/batchedit.js @@ -57,7 +57,7 @@ $(function() var storyLink = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branchID + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=50&type=full&hasParent=1&executionID=0&number=' + num); $.get(storyLink, function(stories) { - if(!stories) modules = ''; + if(!stories) stories = ''; $('#story' + num).replaceWith(stories); $('#story' + num + "_chosen").remove(); $('#story' + num).next('.picker').remove(); diff --git a/module/testcase/js/common.js b/module/testcase/js/common.js index f70847fd18..e9c3af13eb 100644 --- a/module/testcase/js/common.js +++ b/module/testcase/js/common.js @@ -361,7 +361,7 @@ function updateStepID() */ function loadStories(productID, moduleID, num) { - var branchIDName = config.currentMethod == 'batchcreate' ? '#branch' : '#branches'; + var branchIDName = (config.currentMethod == 'batchcreate' || config.currentMethod == 'showimport') ? '#branch' : '#branches'; var branchID = $(branchIDName + num).val(); var storyLink = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branchID + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=50&type=full&hasParent=1&executionID=0&number=' + num); $.get(storyLink, function(stories) diff --git a/module/testcase/js/showimport.js b/module/testcase/js/showimport.js index aede447892..b6490a25c1 100644 --- a/module/testcase/js/showimport.js +++ b/module/testcase/js/showimport.js @@ -1,25 +1,31 @@ -$(document).on('mouseup', '[id^=story].chosen-with-drop', function() +$("[name^='product']").each(function() { - var select = $(this).prev('select'); - var id = $(select).attr('id'); - var index = id.substring(5); - var moduleID = $('#module' + index).val(); - var branch = $('#branch' + index).length > 0 ? $('#branch' + index).val() : 0; - if(moduleID == 'ditto') + var id = $(this).attr('id'); + $(this).attr('id', 'product' + id.match(/\d+/)); +}); + +$("[name^='branch']").each(function() +{ + var id = $(this).attr('id'); + $(this).attr('id', 'branch' + id.match(/\d+/)); +}); + +$("[name^='story']").each(function() +{ + var id = $(this).attr('id'); + var num = id.substring(5); + var productID = $('#product' + num).val(); + var branchID = $('#branch' + num).val(); + var moduleID = $('#module' + num).val(); + var storyID = $("#story" + num).val(); + var storyLink = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branchID + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=50&type=full&hasParent=1&executionID=0&number=' + num); + $.get(storyLink, function(stories) { - for(var i = index - 1; i >=0; i--) - { - if($('#module' + i).val() != 'ditto') - { - moduleID = $('#module' + i).val(); - break; - } - } - } - var link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID + '&storyID='+ ($(select).val() || '0') + '&onlyOption=true&status=noclosed&limit=0&type=null'); - var $story = $('#story' + index); - if($story.data('loadLink') !== link) - { - $story.load(link, function(){$story.data('loadLink', link).trigger("chosen:updated");}); - } + if(!stories) stories = ''; + $('#story' + num).replaceWith(stories); + $('#story' + num + "_chosen").remove(); + $('#story' + num).next('.picker').remove(); + $('#story' + num).attr('name', 'story[' + num + ']').chosen(); + $('#story' + num).val(storyID).trigger('chosen:updated'); + }); }); diff --git a/module/testcase/view/showimport.html.php b/module/testcase/view/showimport.html.php index ea49c6a892..5421771f9e 100644 --- a/module/testcase/view/showimport.html.php +++ b/module/testcase/view/showimport.html.php @@ -82,7 +82,7 @@ $(function() title, ENT_QUOTES), "class='form-control'")?> branch) and $case->branch != 0) ? $modules[BRANCH_MAIN] + $modules[$case->branch] : $modules[BRANCH_MAIN];?> - module) ? $case->module : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->module : ''), "class='form-control chosen moduleChange'")?> + module) ? $case->module : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->module : ''), "class='form-control chosen moduleChange' onchange='loadStories($case->product, this.value, $key)'")?> story) ? $case->story : ((!empty($case->id) and isset($cases[$case->id])) ? $cases[$case->id]->story : '');?>