diff --git a/module/story/control.php b/module/story/control.php index 2c77f443e7..d65168cc40 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -1828,15 +1828,20 @@ class story extends control * AJAX: get stories of a product in html select. * * @param int $productID + * @param int $branch * @param int $moduleID * @param int $storyID * @param string $onlyOption * @param string $status * @param int $limit + * @param string $type + * @param bool $hasParent + * @param int $executionID + * @param int $number * @access public * @return void */ - public function ajaxGetProductStories($productID, $branch = 0, $moduleID = 0, $storyID = 0, $onlyOption = 'false', $status = '', $limit = 0, $type = 'full', $hasParent = 1, $executionID = 0) + public function ajaxGetProductStories($productID, $branch = 0, $moduleID = 0, $storyID = 0, $onlyOption = 'false', $status = '', $limit = 0, $type = 'full', $hasParent = 1, $executionID = 0, $number = '') { if($moduleID) { @@ -1858,11 +1863,11 @@ class story extends control } else { - $stories = $this->story->getProductStoryPairs($productID, $branch ? "0,$branch" : $branch, $moduleID, $storyStatus, 'id_desc', $limit, $type, 'story', $hasParent); + $stories = $this->story->getProductStoryPairs($productID, $branch, $moduleID, $storyStatus, 'id_desc', $limit, $type, 'story', $hasParent); } $storyID = isset($stories[$storyID]) ? $storyID : 0; - $select = html::select('story', empty($stories) ? array('' => '') : $stories, $storyID, "class='form-control'"); + $select = html::select('story' . $number, empty($stories) ? array('' => '') : $stories, $storyID, "class='form-control'"); /* If only need options, remove select wrap. */ if($onlyOption == 'true') die(substr($select, strpos($select, '>') + 1, -10)); diff --git a/module/story/model.php b/module/story/model.php index 5d51043f70..22ddb25fcf 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2228,13 +2228,12 @@ class storyModel extends model */ public function getProductStoryPairs($productID = 0, $branch = 0, $moduleIdList = 0, $status = 'all', $order = 'id_desc', $limit = 0, $type = 'full', $storyType = 'story', $hasParent = true) { - if($branch) $branch = "0,$branch";//Fix bug 1059. $stories = $this->dao->select('t1.id, t1.title, t1.module, t1.pri, t1.estimate, t2.name AS product') ->from(TABLE_STORY)->alias('t1')->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id') ->where('1=1') ->beginIF($productID)->andWhere('t1.product')->in($productID)->fi() ->beginIF($moduleIdList)->andWhere('t1.module')->in($moduleIdList)->fi() - ->beginIF($branch)->andWhere('t1.branch')->in($branch)->fi() + ->beginIF($branch !== 'all')->andWhere('t1.branch')->in($branch)->fi() ->beginIF(!$hasParent)->andWhere('t1.parent')->ge(0)->fi() ->beginIF($status and $status != 'all')->andWhere('t1.status')->in($status)->fi() ->andWhere('t1.deleted')->eq(0) @@ -2673,7 +2672,7 @@ class storyModel extends model ->where('t1.project')->eq((int)$executionID) ->andWhere('t2.deleted')->eq(0) ->beginIF($productID)->andWhere('t2.product')->eq((int)$productID)->fi() - ->beginIF($branch)->andWhere('t2.branch')->in("0,$branch")->fi() + ->beginIF($branch != 'all')->andWhere('t2.branch')->eq($branch)->fi() ->beginIF($moduleIdList)->andWhere('t2.module')->in($moduleIdList)->fi() ->beginIF($status == 'unclosed')->andWhere('t2.status')->ne('closed')->fi() ->orderBy('t1.`order` desc') diff --git a/module/testcase/control.php b/module/testcase/control.php index 01fdfb5e10..73501f4046 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -522,8 +522,9 @@ class testcase extends control $this->app->tab == 'project' ? $this->loadModel('project')->setMenu($this->session->project) : $this->testcase->setMenu($this->products, $productID, $branch); /* Set story list. */ - $story = $storyID ? $this->story->getByID($storyID) : ''; - $storyList = $storyID ? array($storyID => $story->id . ':' . $story->title) : array(''); + $story = $storyID ? $this->story->getByID($storyID) : ''; + $storyList = $this->loadModel('story')->getProductStoryPairs($productID, $branch); + $storyList += $storyID ? array($storyID => $story->id . ':' . $story->title) : array(''); /* Set module option menu. */ $moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'case', $startModuleID = 0, $branch === 'all' ? 0 : $branch); diff --git a/module/testcase/js/batchcreate.js b/module/testcase/js/batchcreate.js index adfc541b4f..421ffc79f9 100644 --- a/module/testcase/js/batchcreate.js +++ b/module/testcase/js/batchcreate.js @@ -3,66 +3,6 @@ $(document).ready(function() removeDitto();//Remove 'ditto' in first row. if($('#batchCreateForm table thead tr th.c-title').width() < 150) $('#batchCreateForm table thead tr th.c-title').width('150'); - $(document).on('mouseup', '.chosen-with-drop', function() - { - var select = $(this).prev('select'); - var id = $(select).attr('id'); - if(id.indexOf('story') != -1) - { - 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&hasParent=0'); - var $story = $('#story' + index); - if($story.data('loadLink') !== link) - { - $story.load(link, function(){$story.data('loadLink', link).trigger("chosen:updated");}); - } - } - if($(select).val() == 'ditto') - { - var index = $(select).closest('td').index(); - var row = $(select).closest('tr').index(); - var table = $(select).closest('tr').parent(); - var value = ''; - for(i = row - 1; i >= 0; i--) - { - value = $(table).find('tr').eq(i).find('td').eq(index).find('select').val(); - if(value != 'ditto') break; - } - $(select).val(value); - $(select).trigger("chosen:updated"); - } - }); - - $(document).on('mousedown', 'select', function() - { - if($(this).val() == 'ditto') - { - var index = $(this).closest('td').index(); - var row = $(this).closest('tr').index(); - var table = $(this).closest('tr').parent(); - var value = ''; - for(i = row - 1; i >= 0; i--) - { - value = $(table).find('tr').eq(i).find('td').eq(index).find('select').val(); - if(value != 'ditto') break; - } - $(this).val(value); - } - }); - $(document).keydown(function(event) { if(event.ctrlKey && event.keyCode == 38) @@ -106,6 +46,19 @@ function setModules(branchID, productID, num) $('#module' + num).replaceWith(modules); $("#module" + num + "_chosen").remove(); $("#module" + num).next('.picker').remove(); - $("#module" + num).chosen(); + $("#module" + num).attr('onchange', "loadStories("+ productID + ", this.value, " + num + ")").chosen(); }); + + loadStories(productID, 0, num); + + /* If the branch of the current row is inconsistent with the one below, clear the module and story of the nex row. */ + var nextBranchID = $('#branch' + (num + 1)).val(); + if(nextBranchID != branchID) + { + $('#module' + (num + 1)).find("option[value='ditto']").remove(); + $('#module' + (num + 1)).trigger("chosen:updated"); + + $('#plan' + (num + 1)).find("option[value='ditto']").remove(); + $('#plan' + (num + 1)).trigger("chosen:updated"); + } } diff --git a/module/testcase/js/common.js b/module/testcase/js/common.js index 5da8863fb8..38e2ae74ce 100644 --- a/module/testcase/js/common.js +++ b/module/testcase/js/common.js @@ -343,3 +343,26 @@ function updateStepID() var i = 1; $('.stepID').each(function(){$(this).html(i ++)}); } + +/** + * Set stories. + * + * @param int productID + * @param int moduleID + * @param int num + * @access public + * @return void + */ +function loadStories(productID, moduleID, num) +{ + var branchID = $('#branch' + 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) + { + if(!stories) modules = ''; + $('#story' + num).replaceWith(stories); + $("#story" + num + "_chosen").remove(); + $("#story" + num).next('.picker').remove(); + $("#story" + num).chosen(); + }); +} diff --git a/module/testcase/view/batchcreate.html.php b/module/testcase/view/batchcreate.html.php index 3b76d24e83..a5c29bf3d0 100644 --- a/module/testcase/view/batchcreate.html.php +++ b/module/testcase/view/batchcreate.html.php @@ -83,7 +83,7 @@ '> - ' style='overflow:visible'> + ' style='overflow:visible'> ' style='overflow:visible'> id : '', 'class="form-control chosen"');?>
@@ -124,7 +124,7 @@ %s '> - ' style='overflow:visible'> + ' style='overflow:visible'> ' style='overflow:visible'>