diff --git a/module/bug/control.php b/module/bug/control.php index 73e915c78f..a634ab3336 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -539,7 +539,7 @@ class bug extends control $this->view->bug = $bug; $this->view->productID = $productID; $this->view->productName = $this->products[$productID]; - $this->view->plans = $this->loadModel('productplan')->getPairs($productID); + $this->view->plans = $this->loadModel('productplan')->getPairs($productID, $bug->branch); $this->view->moduleOptionMenu = $this->tree->getOptionMenu($productID, $viewType = 'bug', $startModuleID = 0); $this->view->currentModuleID = $currentModuleID; $this->view->projects = $this->product->getProjectPairs($bug->product); diff --git a/module/bug/js/common.js b/module/bug/js/common.js index c2f8e3a927..a4f147738a 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -213,7 +213,8 @@ function loadProjectBuilds(projectID) */ function setStories(moduleID, productID) { - branch = $('#branch').val(); + var branch = $('#branch').val(); + if(typeof(branch) == 'undefined') branch = 0; link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID); $.get(link, function(stories) { diff --git a/module/product/control.php b/module/product/control.php index dbd11f3e87..46633adb86 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -524,7 +524,7 @@ class product extends control if(count($plans) == 1 and $needCreate) { $output .= ""; - $output .= html::a($this->createLink('productplan', 'create', "productID=$productID"), $this->lang->productplan->create, '_blank'); + $output .= html::a($this->createLink('productplan', 'create', "productID=$productID&branch=$branch"), $this->lang->productplan->create, '_blank'); $output .= '  '; $output .= html::a("javascript:loadProductPlans($productID)", $this->lang->refresh); $output .= ''; diff --git a/module/productplan/control.php b/module/productplan/control.php index 4f0b3a7115..63ba6c8dc4 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -18,12 +18,15 @@ class productplan extends control * @access public * @return void */ - public function commonAction($productID) + public function commonAction($productID, $branch = 0) { $this->loadModel('product'); - $this->view->product = $this->product->getById($productID); - $this->view->position[] = html::a($this->createLink('product', 'browse', "productID={$this->view->product->id}"), $this->view->product->name); - $this->product->setMenu($this->product->getPairs(), $productID); + $product = $this->product->getById($productID); + $this->view->product = $product; + $this->view->branch = $branch; + $this->view->branches = $product->type == 'normal' ? array() : $this->loadModel('branch')->getPairs($productID); + $this->view->position[] = html::a($this->createLink('product', 'browse', "productID={$this->view->product->id}&branch=$branch"), $this->view->product->name); + $this->product->setMenu($this->product->getPairs(), $productID, $branch); } /** @@ -33,17 +36,17 @@ class productplan extends control * @access public * @return void */ - public function create($product = '') + public function create($product = '', $branch = 0) { if(!empty($_POST)) { $planID = $this->productplan->create(); if(dao::isError()) die(js::error(dao::getError())); $this->loadModel('action')->create('productplan', $planID, 'opened'); - die(js::locate($this->createLink('productplan', 'browse', "productID=$product"), 'parent')); + die(js::locate($this->createLink('productplan', 'browse', "productID=$product&branch=$branch"), 'parent')); } - $this->commonAction($product); + $this->commonAction($product, $branch); $lastPlan = $this->productplan->getLast($product); if($lastPlan) { @@ -54,7 +57,7 @@ class productplan extends control $begin = date('Y-m-d', strtotime("+$delta days", $timestamp)); } - $this->view->begin = $lastPlan ? $begin : ''; + $this->view->begin = $lastPlan ? $begin : ''; $this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->productplan->create; $this->view->position[] = $this->lang->productplan->common; @@ -84,7 +87,7 @@ class productplan extends control } $plan = $this->productplan->getByID($planID); - $this->commonAction($plan->product); + $this->commonAction($plan->product, $plan->branch); $this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->productplan->edit; $this->view->position[] = $this->lang->productplan->edit; $this->view->plan = $plan; @@ -98,13 +101,13 @@ class productplan extends control * @access public * @return void */ - public function batchEdit($productID) + public function batchEdit($productID, $branch = 0) { if(isset($_POST['planIDList'])) { - $this->commonAction($productID); + $this->commonAction($productID, $branch); $this->view->title = $this->lang->productplan->batchEdit; - $this->view->position[] = html::a(inlink('browse', "productID=$productID"), $this->lang->productplan->common); + $this->view->position[] = html::a(inlink('browse', "productID=$productID&branch=$branch"), $this->lang->productplan->common); $this->view->position[] = $this->lang->productplan->batchEdit; $this->view->plans = $this->productplan->getByIDList($this->post->planIDList); @@ -119,7 +122,7 @@ class productplan extends control $actionID = $this->action->create('productplan', $planID, 'Edited'); $this->action->logHistory($actionID, $change); } - die(js::locate(inlink('browse', "productID=$productID"), 'parent')); + die(js::locate(inlink('browse', "productID=$productID&branch=$branch"), 'parent')); } die(js::locate('back')); } @@ -158,7 +161,7 @@ class productplan extends control } $this->send($response); } - die(js::locate(inlink('browse', "productID=$plan->product"), 'parent')); + die(js::locate(inlink('browse', "productID=$plan->product&branch=$plan->branch"), 'parent')); } } @@ -173,7 +176,7 @@ class productplan extends control * @access public * @return void */ - public function browse($productID = 0, $orderBy = 'begin_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1 ) + public function browse($productID = 0, $branch = 0, $orderBy = 'begin_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1 ) { /* Load pager. */ $this->app->loadClass('pager', $static = true); @@ -183,13 +186,13 @@ class productplan extends control $sort = $this->loadModel('common')->appendOrder($orderBy); $this->session->set('productPlanList', $this->app->getURI(true)); - $this->commonAction($productID); + $this->commonAction($productID, $branch); $products = $this->product->getPairs(); $this->view->title = $products[$productID] . $this->lang->colon . $this->lang->productplan->browse; $this->view->position[] = $this->lang->productplan->browse; $this->view->productID = $productID; $this->view->orderBy = $orderBy; - $this->view->plans = $this->productplan->getList($productID, $pager, $sort); + $this->view->plans = $this->productplan->getList($productID, $branch, $pager, $sort); $this->view->pager = $pager; $this->display(); } @@ -213,7 +216,7 @@ class productplan extends control $plan = $this->productplan->getByID($planID, true); if(!$plan) die(js::error($this->lang->notFound) . js::locate('back')); - $this->commonAction($plan->product); + $this->commonAction($plan->product, $plan->branch); $products = $this->product->getPairs(); $this->view->title = "PLAN #$plan->id $plan->title/" . $products[$plan->product]; $this->view->position[] = $this->lang->productplan->view; @@ -239,9 +242,9 @@ class productplan extends control * @access public * @return void */ - public function ajaxGetProductplans($productID) + public function ajaxGetProductplans($productID, $branch = 0) { - $plans = $this->productplan->getPairs($productID); + $plans = $this->productplan->getPairs($productID, $branch); die(html::select('plan', $plans, '', "class='form-control'")); } @@ -263,7 +266,7 @@ class productplan extends control $this->loadModel('story'); $this->loadModel('tree'); $plan = $this->productplan->getByID($planID); - $this->commonAction($plan->product); + $this->commonAction($plan->product, $plan->branch); $products = $this->product->getPairs(); /* Build search form. */ @@ -278,6 +281,15 @@ class productplan extends control $storyStatusList = $this->lang->story->statusList; unset($storyStatusList['closed']); $this->config->product->search['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => $storyStatusList); + if($this->view->product->type == 'normal') + { + unset($this->config->product->search['fields']['branch']); + unset($this->config->product->search['params']['branch']); + } + else + { + $this->config->product->search['params']['branch']['values'] = array('' => '') + $this->loadModel('branch')->getPairs($this->view->product->id, 'noempty'); + } $this->loadModel('search')->setSearchParams($this->config->product->search); if($browseType == 'bySearch') @@ -377,7 +389,7 @@ class productplan extends control $this->loadModel('bug'); $plan = $this->productplan->getByID($planID); - $this->commonAction($plan->product); + $this->commonAction($plan->product, $plan->branch); $products = $this->product->getPairs('nocode'); $productID = $plan->product; $queryID = ($browseType == 'bysearch') ? (int)$param : 0; diff --git a/module/productplan/lang/zh-cn.php b/module/productplan/lang/zh-cn.php index 65a34b28d3..ac2e427e1a 100644 --- a/module/productplan/lang/zh-cn.php +++ b/module/productplan/lang/zh-cn.php @@ -39,6 +39,7 @@ $lang->productplan->confirmUnlinkBug = "您确认移除该Bug吗?"; $lang->productplan->id = '编号'; $lang->productplan->product = $lang->productCommon; +$lang->productplan->branch = '所属分支'; $lang->productplan->title = '名称'; $lang->productplan->desc = '描述'; $lang->productplan->begin = '开始日期'; diff --git a/module/productplan/model.php b/module/productplan/model.php index f235daa7cd..ca1fd908f4 100644 --- a/module/productplan/model.php +++ b/module/productplan/model.php @@ -65,10 +65,11 @@ class productplanModel extends model * @access public * @return object */ - public function getList($product = 0, $pager = null, $orderBy = 'begin_desc') + public function getList($product = 0, $branch = 0, $pager = null, $orderBy = 'begin_desc') { return $this->dao->select('*')->from(TABLE_PRODUCTPLAN)->where('product')->eq($product) ->andWhere('deleted')->eq(0) + ->beginIF(!empty($branch))->andWhere('branch')->eq($branch)->fi() ->orderBy($orderBy) ->page($pager) ->fetchAll(); @@ -82,15 +83,14 @@ class productplanModel extends model * @access public * @return array */ - public function getPairs($product = 0, $expired = '') + public function getPairs($product = 0, $branch = 0, $expired = '') { $date = date('Y-m-d'); return array('' => '') + $this->dao->select('id,CONCAT(title, " [", begin, " ~ ", end, "]") as title')->from(TABLE_PRODUCTPLAN) ->where('product')->in($product) ->andWhere('deleted')->eq(0) - ->beginIF($expired == 'unexpired') - ->andWhere('end')->gt($date) - ->fi() + ->beginIF($branch)->andWhere("branch")->eq($branch)->fi() + ->beginIF($expired == 'unexpired')->andWhere('end')->gt($date)->fi() ->orderBy('begin desc')->fetchPairs(); } diff --git a/module/productplan/view/browse.html.php b/module/productplan/view/browse.html.php index d67135c221..7100e04144 100644 --- a/module/productplan/view/browse.html.php +++ b/module/productplan/view/browse.html.php @@ -15,13 +15,13 @@
productplan->browse;?>
- id", '', 'button', 'plus');?> + id&branch=$branch", '', 'button', 'plus');?>
-
id")?>'> +id&branch=$branch")?>'> - recTotal}&recPerPage={$pager->recPerPage}"; ?> + recTotal}&recPerPage={$pager->recPerPage}"; ?> diff --git a/module/productplan/view/create.html.php b/module/productplan/view/create.html.php index 89847d6a9a..2c2d4fe24e 100644 --- a/module/productplan/view/create.html.php +++ b/module/productplan/view/create.html.php @@ -27,6 +27,12 @@ + type != 'normal'):?> + + + + + diff --git a/module/productplan/view/edit.html.php b/module/productplan/view/edit.html.php index 0219f53f45..2ce86b73b8 100644 --- a/module/productplan/view/edit.html.php +++ b/module/productplan/view/edit.html.php @@ -28,6 +28,12 @@ + type != 'normal'):?> + + + + + diff --git a/module/story/view/create.html.php b/module/story/view/create.html.php index a982264f73..d41cab0fb7 100644 --- a/module/story/view/create.html.php +++ b/module/story/view/create.html.php @@ -56,7 +56,7 @@ if(count($plans) == 1) { echo ""; - echo html::a($this->createLink('productplan', 'create', "productID=$productID"), $lang->productplan->create, '_blank'); + echo html::a($this->createLink('productplan', 'create', "productID=$productID&branch=$branch"), $lang->productplan->create, '_blank'); echo '  '; echo html::a("javascript:loadProductPlans($productID)", $lang->refresh); echo ''; diff --git a/module/story/view/edit.html.php b/module/story/view/edit.html.php index 5e5874d9e1..41e8ed9126 100644 --- a/module/story/view/edit.html.php +++ b/module/story/view/edit.html.php @@ -87,7 +87,7 @@ if(count($plans) == 1) { echo ""; - echo html::a($this->createLink('productplan', 'create', "productID=$story->product"), $lang->productplan->create, '_blank'); + echo html::a($this->createLink('productplan', 'create', "productID=$story->product&branch=$story->branch"), $lang->productplan->create, '_blank'); echo html::a("javascript:loadProductPlans($story->product)", $lang->refresh); echo ''; } diff --git a/module/story/view/header.html.php b/module/story/view/header.html.php index f90d1c949b..5faabd2bea 100644 --- a/module/story/view/header.html.php +++ b/module/story/view/header.html.php @@ -10,8 +10,10 @@ function loadProduct(productID) function loadBranch() { - loadProductModules($('#product').val(), $('#branch').val()); - loadProductPlans($('#product').val(), $('#branch').val()); + var branch = $('#branch').val(); + if(typeof(branch) == 'undefined') branch = 0; + loadProductModules($('#product').val(), branch); + loadProductPlans($('#product').val(), branch); } function loadProductBranches(productID) diff --git a/module/testcase/js/common.js b/module/testcase/js/common.js index 6299821f6e..982a046b46 100644 --- a/module/testcase/js/common.js +++ b/module/testcase/js/common.js @@ -48,6 +48,7 @@ function setStories() moduleID = $('#module').val(); productID = $('#product').val(); branch = $('#branch').val(); + if(typeof(branch) == 'undefined') branch = 0; link = createLink('story', 'ajaxGetProductStories', 'productID=' + productID + '&branch=' + branch + '&moduleID=' + moduleID + '&storyID=0&onlyOption=false&status=noclosed&limit=50'); $.get(link, function(stories) { diff --git a/module/testcase/js/create.js b/module/testcase/js/create.js index 3c2522b6f7..155d6d7b66 100644 --- a/module/testcase/js/create.js +++ b/module/testcase/js/create.js @@ -97,7 +97,9 @@ $(function() if(key && key != $searchInput.data('lastkey')) { $searchResult.empty().append('
  • '); - var link = createLink('story', 'ajaxSearchProductStories', 'key=' + key + '&productID=' + $('#product').val() + '&branch=' + $('#branch').val() + '&moduleID=' + $('#module').val() + '&storyID=0&status=noclosed&limit=50'); + var branch = $('#branch').val(); + if(typeof(branch) == 'undefined') branch = 0; + var link = createLink('story', 'ajaxSearchProductStories', 'key=' + key + '&productID=' + $('#product').val() + '&branch=' + branch + '&moduleID=' + $('#module').val() + '&storyID=0&status=noclosed&limit=50'); $.getJSON(link, function(result) { $searchResult.empty();
    idAB);?> productplan->title);?>productplan->product;?> name;?>
    productplan->branch;?>
    productplan->title;?> productplan->product;?> name;?>
    productplan->branch;?>branch, 'class="form-control"');?>
    productplan->title;?> title, 'class="form-control"');?>