diff --git a/module/testcase/js/batchcreate.js b/module/testcase/js/batchcreate.js index b3b13f4504..52aca5f003 100644 --- a/module/testcase/js/batchcreate.js +++ b/module/testcase/js/batchcreate.js @@ -11,7 +11,7 @@ $(document).ready(function() { var index = id.substring(5); var moduleID = $('#module' + index).val(); - var branch = $('#branch' + index).val(); + var branch = $('#branch' + index).length > 0 ? $('#branch' + index).val() : 0; if(moduleID == 'ditto') { for(var i = index - 1; i >=0; i--) diff --git a/module/testcase/js/showimport.js b/module/testcase/js/showimport.js index 3ca378f148..aede447892 100644 --- a/module/testcase/js/showimport.js +++ b/module/testcase/js/showimport.js @@ -1,24 +1,25 @@ -$(document).on('change', '.moduleChange', function() +$(document).on('mouseup', '[id^=story].chosen-with-drop', function() { - var moduleID = $(this).val(); - if(typeof(moduleID) == 'undefined') moduleID = 0; - var id = $(this).attr('id'); - var index = id.substring(6); - link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID + '&storyID='+ '' + '&onlyOption=true&status=noclosed'); - $('#story' + index).load(link, function(){$(this).trigger("chosen:updated");}); -}) - -$(document).on('change', '.storyChange', function() -{ - var storyID = $(this).val(); - if(typeof(storyID) == 'undefined') storyID = 0; - var link = createLink('testcase', 'ajaxGetStoryModule', 'storyID=' + storyID); - var id = $(this).attr('id'); - var index = id.substring(5); - $.get(link, function(json) - { - var obj = JSON.parse(json); - $("#module" + index).val(obj.moduleID); - $('#module' + index).trigger("chosen:updated"); - }) -}) + 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') + { + 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");}); + } +});