* finish task #2350.

This commit is contained in:
chenfeiCF
2015-10-27 18:55:59 +08:00
parent c4bd3be15d
commit 546e61c36a
10 changed files with 87 additions and 8 deletions

View File

@@ -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
*

View File

@@ -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');

View File

@@ -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]);

View File

@@ -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();
}

View File

@@ -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);});
}
}

View File

@@ -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 = '发布日期';

View File

@@ -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')

View File

@@ -13,6 +13,10 @@
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/datepicker.html.php';?>
<?php include '../../common/view/kindeditor.html.php';?>
<?php
js::set('productID' , $productID);
js::set('page' , 'create');
?>
<div class='container mw-1400px'>
<div id='titlebar'>
<div class='heading'>
@@ -22,6 +26,12 @@
</div>
<form class='form-condensed' method='post' target='hiddenwin' id='dataform' enctype='multipart/form-data'>
<table class='table table-form'>
<?php if($product->type != 'normal'):?>
<tr>
<th class='w-110px'><?php echo $lang->release->branch;?></th>
<td><?php echo html::select('branch', $branches, '', "onchange='loadBranchBuilds(this.value)' class='form-control chosen'");?></td>
</tr>
<?php endif;?>
<tr>
<th class='w-110px'><?php echo $lang->release->name;?></th>
<td class='w-p25-f'>
@@ -33,8 +43,7 @@
</tr>
<tr>
<th><?php echo $lang->release->build;?></th>
<td><?php echo html::select('build', $builds, '', "class='form-control chosen'");?></td>
<td><?php if(empty($builds)) echo $lang->build->notice; ?></td>
<td><span id='buildBox'><?php echo html::select('build', $builds, '', "class='form-control chosen'");?></span></td>
</tr>
<tr>
<th><?php echo $lang->release->date;?></th>

View File

@@ -13,6 +13,11 @@
<?php include '../../common/view/header.html.php';?>
<?php include '../../common/view/datepicker.html.php';?>
<?php include '../../common/view/kindeditor.html.php';?>
<?php
js::set('page' , 'edit');
js::set('productID' , $release->product);
js::set('oldReleasedBuild' , $release->build);
?>
<div class='container mw-1400px'>
<div id='titlebar'>
<div class='heading'>
@@ -23,13 +28,19 @@
</div>
<form class='form-condensed' method='post' target='hiddenwin' id='dataform' enctype='multipart/form-data'>
<table class='table table-form'>
<?php if($product->type != 'normal'):?>
<tr>
<th class='w-110px'><?php echo $lang->release->branch;?></th>
<td><?php echo html::select('branch', $branches, $branch, "onchange='loadBranchBuilds(this.value)' class='form-control chosen'");?></td>
</tr>
<?php endif;?>
<tr>
<th class='w-90px'><?php echo $lang->release->name;?></th>
<td class='w-p25-f'><?php echo html::input('name', $release->name, "class='form-control'");?></td><td></td>
</tr>
<tr>
<th><?php echo $lang->release->build;?></th>
<td><?php echo html::select('build', $builds, $release->build, "class='form-control chosen'"); ?></td><td></td>
<td><span id='buildBox'><?php echo html::select('build', $builds, $release->build, "class='form-control chosen'"); ?></span></td><td></td>
</tr>
<tr>
<th><?php echo $lang->release->date;?></th>

View File

@@ -266,6 +266,12 @@
<th class='w-80px'><?php echo $lang->release->product;?></th>
<td><?php echo $release->productName;?></td>
</tr>
<?php if($release->productType != 'normal'):?>
<tr>
<th><?php echo $lang->release->branch;?></th>
<td><?php echo $branchName;?></td>
</tr>
<?php endif;?>
<tr>
<th><?php echo $lang->release->name;?></th>
<td><?php echo $release->name;?></td>