diff --git a/module/bug/model.php b/module/bug/model.php index 5ab908f07d..a53c9bfe16 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -2499,7 +2499,7 @@ class bugModel extends model } $allBranch = "`branch` = 'all'"; - if($branch !== 'all' and strpos($bugQuery, '`branch` =') === false) $bugQuery .= " AND `branch` in('$branch')"; + if($branch !== 'all' and strpos($bugQuery, '`branch` =') === false) $bugQuery .= " AND `branch` in('0','$branch')"; if(strpos($bugQuery, $allBranch) !== false) $bugQuery = str_replace($allBranch, '1', $bugQuery); $allProject = "`project` = 'all'"; diff --git a/module/build/control.php b/module/build/control.php index 77fa967f8f..30972ec028 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -492,8 +492,8 @@ class build extends control $this->config->product->search['actionURL'] = $this->createLink('build', 'view', "buildID=$buildID&type=story&link=true¶m=" . helper::safe64Encode("&browseType=bySearch&queryID=myQueryID")); $this->config->product->search['queryID'] = $queryID; $this->config->product->search['style'] = 'simple'; - $this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts(array($build->product => $build->product)); - $this->config->product->search['params']['module']['values'] = $this->tree->getOptionMenu($build->product, 'story', 0); + $this->config->product->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairsForStory($build->product, $build->branch, true); + $this->config->product->search['params']['module']['values'] = $this->tree->getOptionMenu($build->product, 'story', 0, $build->branch); $this->config->product->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $this->lang->story->statusList); if($product->type == 'normal') @@ -503,9 +503,11 @@ class build extends control } else { - $this->config->product->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); - $branches = array('' => '') + $this->loadModel('branch')->getPairs($build->product, 'noempty'); - if($build->branch) $branches = array('' => '', $build->branch => $branches[$build->branch]); + $branchPairs = $this->loadModel('branch')->getPairs($build->product, 'noempty'); + $branches = array('' => '') + array(BRANCH_MAIN => $this->lang->branch->main); + if($build->branch) $branches += array($build->branch => $branchPairs[$build->branch]); + + $this->config->product->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); $this->config->product->search['params']['branch']['values'] = $branches; } $this->loadModel('search')->setSearchParams($this->config->product->search); @@ -516,7 +518,7 @@ class build extends control } else { - $allStories = $this->story->getExecutionStories($build->execution, 0, 0, 't1.`order`_desc', 'byProduct', $build->product, 'story', $build->stories, $pager); + $allStories = $this->story->getExecutionStories($build->execution, $build->product, 0, 't1.`order`_desc', 'byBranch', $build->branch, 'story', $build->stories, $pager); } $this->view->allStories = $allStories; @@ -609,8 +611,8 @@ class build extends control $this->config->bug->search['actionURL'] = $this->createLink('build', 'view', "buildID=$buildID&type=bug&link=true¶m=" . helper::safe64Encode("&browseType=bySearch&queryID=myQueryID")); $this->config->bug->search['queryID'] = $queryID; $this->config->bug->search['style'] = 'simple'; - $this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts(array($build->product => $build->product)); - $this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($build->product, $viewType = 'bug', $startModuleID = 0); + $this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getPairsForStory($build->product, $build->branch, true); + $this->config->bug->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($build->product, 'bug', 0, $build->branch); $this->config->bug->search['params']['execution']['values'] = $this->loadModel('product')->getExecutionPairsByProduct($build->product, 0, 'id_desc', $this->session->project); $this->config->bug->search['params']['openedBuild']['values'] = $this->build->getProductBuildPairs($build->product, $branch = 0, $params = ''); $this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values']; @@ -624,9 +626,11 @@ class build extends control } else { - $this->config->bug->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); - $branches = array('' => '') + $this->loadModel('branch')->getPairs($build->product, 'noempty'); - if($build->branch) $branches = array('' => '', $build->branch => $branches[$build->branch]); + $branchPairs = $this->loadModel('branch')->getPairs($build->product, 'noempty'); + $branches = array('' => '') + array(BRANCH_MAIN => $this->lang->branch->main); + if($build->branch) $branches += array($build->branch => $branchPairs[$build->branch]); + + $this->config->bug->search['fields']['branch'] = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]); $this->config->bug->search['params']['branch']['values'] = $branches; } $this->loadModel('search')->setSearchParams($this->config->bug->search); diff --git a/module/build/js/common.js b/module/build/js/common.js index e92d9470ad..599c9cba24 100644 --- a/module/build/js/common.js +++ b/module/build/js/common.js @@ -15,7 +15,7 @@ function loadBranches(productID) oldBranch = productGroups[productID]['branches']; } - executionID = $('#execution').val(); + executionID = currentTab == 'execution' ? executionID : $('#execution').val(); $.get(createLink('branch', 'ajaxGetBranches', 'productID=' + productID + '&oldBranch=0¶m=active&projectID=' + executionID), function(data) { if(data) diff --git a/module/build/view/create.html.php b/module/build/view/create.html.php index 1ede2bdad7..996195e756 100644 --- a/module/build/view/create.html.php +++ b/module/build/view/create.html.php @@ -92,5 +92,7 @@ - + + +app->tab);?> diff --git a/module/execution/control.php b/module/execution/control.php index 1dce3dc299..9eaaddea6e 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -2507,7 +2507,7 @@ class execution extends control if($browseType == 'bySearch') { - $allStories = $this->story->getBySearch('', 0, $queryID, 'id', $objectID); + $allStories = $this->story->getBySearch('', '', $queryID, 'id', $objectID); } else { diff --git a/module/productplan/model.php b/module/productplan/model.php index 225f2c9116..d1730a4740 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -221,7 +221,7 @@ class productplanModel extends model $plans = $this->dao->select('id,title,parent,begin,end')->from(TABLE_PRODUCTPLAN) ->where('product')->in($product) ->andWhere('deleted')->eq(0) - ->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi() + ->beginIF($branch != '')->andWhere("branch")->in("0,$branch")->fi() ->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi() ->orderBy('begin desc') ->fetchAll('id'); diff --git a/module/story/model.php b/module/story/model.php index a8754ba8d6..3500d08537 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2446,10 +2446,14 @@ class storyModel extends model $branches = array(); foreach($products as $product) { - foreach($product->branches as $branchID) $branches[$branchID] = $branchID; + foreach($product->branches as $branchID) + { + if($branch == BRANCH_MAIN and $branchID) continue; + $branches[$branchID] = $branchID; + } } $branches = join(',', $branches); - if($branches) $storyQuery .= " AND `branch`" . helper::dbIN($branches); + $storyQuery .= " AND `branch`" . helper::dbIN($branches); if($this->app->moduleName == 'release' or $this->app->moduleName == 'build') { @@ -2590,10 +2594,9 @@ class storyModel extends model else { $productParam = ($type == 'byproduct' and $param) ? $param : $this->cookie->storyProductParam; - $branchParam = $branchID = ($type == 'bybranch' and $param !== '') ? $param : $this->cookie->storyBranchParam; + $branchParam = ($type == 'bybranch' and $param !== '') ? $param : $this->cookie->storyBranchParam; $moduleParam = ($type == 'bymodule' and $param) ? $param : $this->cookie->storyModuleParam; $modules = (empty($moduleParam) or $type != 'bymodule') ? array() : $this->dao->select('*')->from(TABLE_MODULE)->where('path')->like("%,$moduleParam,%")->andWhere('type')->eq('story')->andWhere('deleted')->eq(0)->fetchPairs('id', 'id'); - if(strpos($branchParam, ',') !== false) list($productParam, $branchParam) = explode(',', $branchParam); $unclosedStatus = $this->lang->story->statusList; unset($unclosedStatus['closed']); @@ -2617,7 +2620,7 @@ class storyModel extends model ->beginIF($excludeStories)->andWhere('t2.id')->notIN($excludeStories)->fi() ->beginIF($execution->type == 'project') ->beginIF(!empty($productID))->andWhere('t1.product')->eq($productID) - ->beginIF($type == 'bybranch' and $branchParam !== '')->andWhere('t2.branch')->eq($branchParam)->fi() + ->beginIF($type == 'bybranch' and $branchParam !== '')->andWhere('t2.branch')->in("0,$branchParam")->fi() ->beginIF(strpos('changed|closed', $type) !== false)->andWhere('t2.status')->eq($type)->fi() ->beginIF($type == 'unclosed')->andWhere('t2.status')->in(array_keys($unclosedStatus))->fi() ->beginIF($type == 'linkedexecution')->andWhere('t2.id')->in($storyIdList)->fi() @@ -2628,7 +2631,6 @@ class storyModel extends model ->beginIF($this->session->executionStoryBrowseType and strpos('changed|', $this->session->executionStoryBrowseType) !== false)->andWhere('t2.status')->in(array_keys($unclosedStatus))->fi() ->fi() ->beginIF($this->session->storyBrowseType and strpos('changed|', $this->session->storyBrowseType) !== false)->andWhere('t2.status')->in(array_keys($unclosedStatus))->fi() - ->beginIF(!empty($branchParam))->andWhere('t2.branch')->eq($branchParam)->fi() ->beginIF($modules)->andWhere('t2.module')->in($modules)->fi() ->andWhere('t2.deleted')->eq(0) ->orderBy($orderBy) diff --git a/module/tree/model.php b/module/tree/model.php index c46956a1df..3ed9be66bb 100644 --- a/module/tree/model.php +++ b/module/tree/model.php @@ -135,17 +135,14 @@ class treeModel extends model if($type == 'line') $rootID = 0; - $branches = array($branch => ''); + $branches = array(); if(strpos('story|bug|case', $type) !== false) { $product = $this->loadModel('product')->getById($rootID); if($product and $product->type != 'normal') { - $branchList = array('null' => '') + $this->loadModel('branch')->getPairs($rootID, 'all'); - - if(!$branch) $newBranches['null'] = ''; - $newBranches[$branch] = $branchList[$branch]; - $branches = $branch === 'all' ? $branchList : $newBranches; + $branchPairs = $this->loadModel('branch')->getPairs($rootID, 'all'); + $branches = $branch === 'all' ? $branchPairs : array($branch => $branchPairs[$branch]); } elseif($product and $product->type == 'normal') { @@ -156,11 +153,15 @@ class treeModel extends model $treeMenu = array(); foreach($branches as $branchID => $branch) { - $stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule, $branchID)); - $modules = array(); + $stmt = $this->dbh->query($this->buildMenuQuery($rootID, $type, $startModule, $branchID)); + $modules = array(); while($module = $stmt->fetch()) $modules[$module->id] = $module; - foreach($modules as $module) $this->buildTreeArray($treeMenu, $modules, $module, (empty($branch) or $branch == 'null') ? '/' : "/$branch/"); + foreach($modules as $module) + { + $branchName = ($product->type != 'normal' and $module->branch == BRANCH_MAIN) ? $this->lang->branch->main : $branch; + $this->buildTreeArray($treeMenu, $modules, $module, (empty($branchName)) ? '/' : "/$branchName/"); + } } ksort($treeMenu);