diff --git a/module/build/control.php b/module/build/control.php index b2295656b7..8ea7b4ce96 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -256,6 +256,7 @@ class build extends control * AJAX: get all builds of a project in html select. * * @param int $projectID + * @param int $productID * @param string $varName the name of the select object to create * @param string $build build to selected * @access public @@ -272,6 +273,38 @@ class build extends control if($varName == 'resolvedBuild') die(html::select($varName, $this->build->getProjectBuildPairs($projectID, $productID, 'noempty'), $build, "class='form-control'")); } + /** + * AJAX: get builds of a branch in html select. + * + * @param int $productID + * @param int $branchID + * @param string $operation the operation of creating a release or editing. + * @param string $build build to selected. + * @access public + * @return string + */ + public function ajaxGetBranchBuilds($productID, $branchID, $operation, $build = '') + { + $builds = $this->build->getProductBuildPairs($productID, $branchID); + $releasedBuilds = $this->loadModel('release')->getReleaseBuilds($productID); + + if($operation == 'editRelease') + { + foreach($releasedBuilds as $buildID) + { + if($build == $buildID) continue; + unset($builds[$buildID]); + } + } + if($operation == 'createRelease') + { + foreach($releasedBuilds as $buildID) unset($builds[$buildID]); + } + unset($builds['trunk']); + + die(html::select('build', $builds, $build, "class='form-control'")); + } + /** * Link stories * diff --git a/module/build/model.php b/module/build/model.php index 77ddde7c01..122e480b08 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -96,7 +96,7 @@ class buildModel extends model * @access public * @return string */ - public function getProductBuildPairs($products, $params = '') + public function getProductBuildPairs($products, $branchID = 0, $params = '') { $sysBuilds = array(); if(strpos($params, 'noempty') === false) $sysBuilds = array('' => ''); @@ -106,11 +106,13 @@ class buildModel extends model ->leftJoin(TABLE_PROJECT)->alias('t2') ->on('t1.project = t2.id') ->where('t1.product')->in($products) + ->beginIF($branchID)->andWhere('t1.branch')->eq($branchID)->fi() ->beginIF(strpos($params, 'nodone') !== false)->andWhere('t2.status')->ne('done')->fi() ->andWhere('t1.deleted')->eq(0) ->orderBy('t1.date desc, t1.id desc')->fetchAll('id'); $releases = $this->dao->select('build,name,deleted')->from(TABLE_RELEASE) ->where('product')->in($products) + ->beginIF($branchID)->andWhere('branch')->eq($branchID)->fi() ->beginIF(strpos($params, 'noterminate') !== false)->andWhere('status')->ne('terminate')->fi() ->fetchAll('build'); diff --git a/module/project/model.php b/module/project/model.php index 1f2fba6ea3..cf533db635 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -634,7 +634,7 @@ class projectModel extends model public function getProjectStats($status = 'undone', $productID = 0, $itemCounts = 30, $orderBy = 'order_desc', $pager = null) { /* Init vars. */ - $projects = $this->getList($status, 0, $productID, $branch); + $projects = $this->getList($status, 0, $productID); foreach($projects as $projectID => $project) { if(!$this->checkPriv($project)) unset($projects[$projectID]); diff --git a/module/release/control.php b/module/release/control.php index 96c8c94507..0c5b2d1fd1 100644 --- a/module/release/control.php +++ b/module/release/control.php @@ -107,14 +107,14 @@ class release extends control /* Get release and build. */ $release = $this->release->getById((int)$releaseID); - $this->commonAction($release->product); + $this->commonAction($release->product, $release->branch); $build = $this->build->getById($release->build); $this->view->title = $this->view->product->name . $this->lang->colon . $this->lang->release->edit; $this->view->position[] = $this->lang->release->edit; $this->view->release = $release; $this->view->build = $build; - $this->view->builds = $this->loadModel('build')->getProductBuildPairs($release->product, 'notrunk'); + $this->view->builds = $this->loadModel('build')->getProductBuildPairs($release->product, $release->branch, 'notrunk'); $this->display(); } @@ -160,6 +160,7 @@ class release extends control $this->view->type = $type; $this->view->link = $link; $this->view->param = $param; + $this->view->branchName = $release->productType == 'normal' ? '' : $this->loadModel('branch')->getById($release->branch); $this->display(); } diff --git a/module/release/js/common.js b/module/release/js/common.js index 1f3ddf85b3..6fdbfa8c78 100644 --- a/module/release/js/common.js +++ b/module/release/js/common.js @@ -2,3 +2,19 @@ $(document).ready(function() { $("a.preview").modalTrigger({width:1000, type:'iframe'}); }) + +function loadBranchBuilds(branchID) +{ + if(page == 'create') + { + oldReleasedBuild = $('#build').val() ? $('#build').val() : 0; + + link = createLink('build', 'ajaxGetBranchBuilds', 'productID=' + productID + '&branchID=' + branchID + '&operation=createRelease&build=' + oldReleasedBuild); + $('#buildBox').load(link, function(){$('#build').chosen(defaultChosenOptions);}); + } + else + { + link = createLink('build', 'ajaxGetBranchBuilds', 'productID=' + productID + '&branchID=' + branchID + '&operation=editRelease&build=' + oldReleasedBuild); + $('#buildBox').load(link, function(){$('#build').chosen(defaultChosenOptions);}); + } +} diff --git a/module/release/lang/zh-cn.php b/module/release/lang/zh-cn.php index 8f077b0a04..a0a5ceab24 100644 --- a/module/release/lang/zh-cn.php +++ b/module/release/lang/zh-cn.php @@ -31,6 +31,7 @@ $lang->release->basicInfo = '基本信息'; $lang->release->id = 'ID'; $lang->release->product = $lang->productCommon; +$lang->release->branch = '所属分支'; $lang->release->build = '版本'; $lang->release->name = '发布名称'; $lang->release->date = '发布日期'; diff --git a/module/release/model.php b/module/release/model.php index f7a58a1660..c1895d9390 100644 --- a/module/release/model.php +++ b/module/release/model.php @@ -23,7 +23,7 @@ class releaseModel extends model */ public function getByID($releaseID, $setImgSize = false) { - $release = $this->dao->select('t1.*, t2.id as buildID, t2.filePath, t2.scmPath, t2.name as buildName, t3.name as productName') + $release = $this->dao->select('t1.*, t2.id as buildID, t2.filePath, t2.scmPath, t2.name as buildName, t3.name as productName, t3.type as productType') ->from(TABLE_RELEASE)->alias('t1') ->leftJoin(TABLE_BUILD)->alias('t2')->on('t1.build = t2.id') ->leftJoin(TABLE_PRODUCT)->alias('t3')->on('t1.product = t3.id') diff --git a/module/release/view/create.html.php b/module/release/view/create.html.php index e1643b0817..5d5a9ac258 100644 --- a/module/release/view/create.html.php +++ b/module/release/view/create.html.php @@ -13,6 +13,10 @@ +
@@ -22,6 +26,12 @@
+ type != 'normal'):?> + + + + + - - + diff --git a/module/release/view/edit.html.php b/module/release/view/edit.html.php index 700ec5ccd7..90d6529b30 100644 --- a/module/release/view/edit.html.php +++ b/module/release/view/edit.html.php @@ -13,6 +13,11 @@ +product); +js::set('oldReleasedBuild' , $release->build); +?>
@@ -23,13 +28,19 @@
release->branch;?>
release->name;?> @@ -33,8 +43,7 @@
release->build;?>build->notice; ?>
release->date;?>
+ type != 'normal'):?> + + + + + - + diff --git a/module/release/view/view.html.php b/module/release/view/view.html.php index 3b66523c9a..bda44fb57f 100644 --- a/module/release/view/view.html.php +++ b/module/release/view/view.html.php @@ -266,6 +266,12 @@ + productType != 'normal'):?> + + + + +
release->branch;?>
release->name;?> name, "class='form-control'");?>
release->build;?>build, "class='form-control chosen'"); ?>build, "class='form-control chosen'"); ?>
release->date;?>release->product;?> productName;?>
release->branch;?>
release->name;?> name;?>