* Finish task #9009.
This commit is contained in:
@@ -98,7 +98,6 @@ class buildModel extends model
|
||||
->leftJoin(TABLE_RELEASE)->alias('t3')->on('t1.id = t3.build')
|
||||
->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id')
|
||||
->where('t1.PRJ')->eq((int)$projectID)
|
||||
->andWhere('t1.project')->ne(0)
|
||||
->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->fi()
|
||||
->beginIF($branch)->andWhere('t1.branch')->in("0,$branch")->fi()
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
|
||||
@@ -39,14 +39,18 @@ class projectrelease extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function commonAction($productID, $branch = 0)
|
||||
public function commonAction($productID = 0, $branch = 0)
|
||||
{
|
||||
$this->lang->product->menu = $this->lang->product->viewMenu;
|
||||
$this->lang->product->menu = $this->lang->product->viewMenu;
|
||||
$this->lang->product->switcherMenu = $this->loadModel('product')->getSwitcher($productID);
|
||||
|
||||
/* Get product and product list by project. */
|
||||
$this->loadModel('product');
|
||||
$products = $this->loadModel('product')->getProductPairsByProject($this->session->PRJ);
|
||||
if(!$productID) $productID = key($products);
|
||||
$product = $this->product->getById($productID);
|
||||
|
||||
$this->view->products = $products;
|
||||
$this->view->product = $product;
|
||||
$this->view->branches = (isset($product->type) and $product->type == 'normal') ? array() : $this->loadModel('branch')->getPairs($productID);
|
||||
$this->view->branch = $branch;
|
||||
@@ -56,28 +60,20 @@ class projectrelease extends control
|
||||
/**
|
||||
* Browse releases.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param string $type
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function browse($productID = 0, $branch = 0, $type = 'all')
|
||||
public function browse($type = 'all')
|
||||
{
|
||||
if(!$productID) $productID = key($this->products);
|
||||
$product = $this->product->getById($productID);
|
||||
$this->session->set('releaseList', $this->app->getURI(true));
|
||||
|
||||
$project = $this->loadModel('project')->getById($this->session->PRJ);
|
||||
|
||||
$this->view->title = $project->name . $this->lang->colon . $this->lang->release->browse;
|
||||
$this->view->position[] = $this->lang->release->browse;
|
||||
$this->view->project = $project;
|
||||
$this->view->products = $this->loadModel('product')->getProductsByProject($this->session->PRJ);
|
||||
$this->view->product = $product;
|
||||
$this->view->branches = (isset($product->type) and $product->type == 'normal') ? array() : $this->loadModel('branch')->getPairs($productID);
|
||||
$this->view->branch = $branch;
|
||||
$this->view->releases = $this->projectrelease->getList($this->session->PRJ, $productID, $branch, $type);
|
||||
$this->view->releases = $this->projectrelease->getList($this->session->PRJ, $type);
|
||||
$this->view->type = $type;
|
||||
$this->display();
|
||||
}
|
||||
@@ -90,31 +86,29 @@ class projectrelease extends control
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function create($productID, $branch = 0)
|
||||
public function create()
|
||||
{
|
||||
if(!empty($_POST))
|
||||
{
|
||||
$releaseID = $this->projectrelease->create($productID, $branch);
|
||||
$releaseID = $this->projectrelease->create();
|
||||
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
$this->loadModel('action')->create('release', $releaseID, 'opened');
|
||||
|
||||
$this->executeHooks($releaseID);
|
||||
|
||||
if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadProductBuilds($productID)"));
|
||||
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID")));
|
||||
}
|
||||
|
||||
$builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch, 'notrunk|withbranch', false);
|
||||
$releaseBuilds = $this->projectrelease->getReleaseBuilds($productID, $branch);
|
||||
/* Get the builds that can select. */
|
||||
$builds = $this->loadModel('build')->getProductBuildPairs($this->session->PRJ, 0, 0, 'notrunk');
|
||||
$releaseBuilds = $this->projectrelease->getReleaseBuilds($this->session->PRJ);
|
||||
foreach($releaseBuilds as $build) unset($builds[$build]);
|
||||
unset($builds['trunk']);
|
||||
|
||||
$this->commonAction($productID, $branch);
|
||||
$this->commonAction();
|
||||
$this->view->title = $this->view->project->name . $this->lang->colon . $this->lang->release->create;
|
||||
$this->view->position[] = $this->lang->release->create;
|
||||
$this->view->builds = $builds;
|
||||
$this->view->productID = $productID;
|
||||
$this->view->lastRelease = $this->projectrelease->getLast($productID, $branch);
|
||||
$this->view->lastRelease = $this->projectrelease->getLast($this->session->PRJ);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,3 +2,41 @@ $(document).ready(function()
|
||||
{
|
||||
$("a.preview").modalTrigger({width:1000, type:'iframe'});
|
||||
})
|
||||
|
||||
/**
|
||||
* Determined whether to show the productis.
|
||||
*
|
||||
* @param int $build
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function showProducts(build)
|
||||
{
|
||||
if(build) $('#productBox').hide();
|
||||
if(!build) $('#productBox').show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush the branch when switching products.
|
||||
*
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function loadBranches(productID)
|
||||
{
|
||||
$('#branch').remove();
|
||||
$('#branch_chosen').remove();
|
||||
$.get(createLink('branch', 'ajaxGetBranches', "productID=" + productID), function(data)
|
||||
{
|
||||
var $product = $('#product');
|
||||
var $inputGroup = $product.closest('.input-group');
|
||||
$inputGroup.find('.input-group-addon').toggleClass('hidden', !data);
|
||||
if(data)
|
||||
{
|
||||
$inputGroup.append(data);
|
||||
$('#branch').css('width', '120px').chosen();
|
||||
}
|
||||
$inputGroup.fixInputGroup();
|
||||
})
|
||||
}
|
||||
|
||||
@@ -52,13 +52,12 @@ class projectreleaseModel extends model
|
||||
*/
|
||||
public function getList($projectID, $productID, $branch = 0, $type = 'all')
|
||||
{
|
||||
return $this->dao->select('t1.*, t2.name as productName, t3.id as buildID, t3.name as buildName, t3.project')
|
||||
return $this->dao->select('t1.*, t2.name as productName, t3.id as buildID, t3.name as buildName, t3.project, t4.name as executionName')
|
||||
->from(TABLE_RELEASE)->alias('t1')
|
||||
->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id')
|
||||
->leftJoin(TABLE_BUILD)->alias('t3')->on('t1.build = t3.id')
|
||||
->leftJoin(TABLE_EXECUTION)->alias('t4')->on('t3.project = t4.id')
|
||||
->where('t1.PRJ')->eq((int)$projectID)
|
||||
->andWhere('t1.product')->eq((int)$productID)
|
||||
->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi()
|
||||
->beginIF($type != 'all')->andWhere('t1.status')->eq($type)->fi()
|
||||
->andWhere('t1.deleted')->eq(0)
|
||||
->orderBy('t1.date DESC')
|
||||
@@ -68,52 +67,45 @@ class projectreleaseModel extends model
|
||||
/**
|
||||
* Get last release.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return bool | object
|
||||
*/
|
||||
public function getLast($productID, $branch = 0)
|
||||
public function getLast($projectID)
|
||||
{
|
||||
return $this->dao->select('id, name')->from(TABLE_RELEASE)
|
||||
->where('product')->eq((int)$productID)
|
||||
->beginIF($branch)->andWhere('branch')->eq($branch)->fi()
|
||||
->where('PRJ')->eq((int)$projectID)
|
||||
->orderBy('date DESC')
|
||||
->limit(1)
|
||||
->fetch();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get release builds from product.
|
||||
* Get release builds from project.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
public function getReleaseBuilds($productID, $branch = 0)
|
||||
public function getReleaseBuilds($projectID)
|
||||
{
|
||||
$releases = $this->dao->select('build')->from(TABLE_RELEASE)
|
||||
->where('deleted')->eq(0)
|
||||
->andWhere('product')->eq($productID)
|
||||
->beginIF($branch)->andWhere('branch')->eq($branch)->fi()
|
||||
->andWhere('PRJ')->eq($projectID)
|
||||
->fetchAll('build');
|
||||
return array_keys($releases);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a release.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
*
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public function create($productID, $branch = 0)
|
||||
public function create()
|
||||
{
|
||||
$productID = (int)$productID;
|
||||
$branch = (int)$branch;
|
||||
$productID = $this->post->product;
|
||||
$branch = $this->post->branch;
|
||||
$buildID = 0;
|
||||
|
||||
/* Check build if build is required. */
|
||||
@@ -122,6 +114,13 @@ class projectreleaseModel extends model
|
||||
/* Check date must be not more than today. */
|
||||
if($this->post->date > date('Y-m-d')) return dao::$errors[] = $this->lang->release->errorDate;
|
||||
|
||||
if($this->post->build)
|
||||
{
|
||||
$build = $this->loadModel('build')->getByID($this->post->build);
|
||||
$productID = $build->product;
|
||||
$branch = $build->branch;
|
||||
}
|
||||
|
||||
$release = fixer::input('post')
|
||||
->add('PRJ', $this->session->PRJ)
|
||||
->add('product', (int)$productID)
|
||||
@@ -130,6 +129,8 @@ class projectreleaseModel extends model
|
||||
->join('stories', ',')
|
||||
->join('bugs', ',')
|
||||
->setIF($this->post->build == false, 'build', $buildID)
|
||||
->setIF($productID, 'product', $productID)
|
||||
->setIF($branch, 'branch', $branch)
|
||||
->stripTags($this->config->release->editor->create['id'], $this->config->allowedTags)
|
||||
->remove('allchecker,files,labels,uid')
|
||||
->get();
|
||||
|
||||
@@ -15,23 +15,15 @@
|
||||
<?php js::set('confirmDelete', $lang->release->confirmDelete)?>
|
||||
<div id="mainMenu" class="clearfix">
|
||||
<div class="btn-toolbar pull-left">
|
||||
<div class="btn-group">
|
||||
<?php echo html::a('javascript:;', "<span class='text'>{$product->name}</span> <span class='caret'></span>", '', "class='btn btn-link btn-limit' style='border-radius: 2px;' data-toggle='dropdown'")?>
|
||||
<ul class="dropdown-menu" style="max-height:240px; max-width: 300px; overflow-y:auto">
|
||||
<?php foreach($products as $product): ?>
|
||||
<li><?php echo html::a($this->inLink('browse', "productID=$product->id&branch=0&type=$type", '', '', $this->session->PRJ), $product->name);?></li>
|
||||
<?php endforeach;?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php
|
||||
echo html::a(inlink('browse', "productID={$product->id}&branch=$branch&type=all"), "<span class='text'>{$lang->release->all}</span>" . ($type == 'all' ? ' <span class="label label-light label-badge">' . count($releases) . '</span>' : ''), '', "id='allTab' class='btn btn-link" . ('all' == $type ? ' btn-active-text' : '') . "'");
|
||||
echo html::a(inlink('browse', "productID={$product->id}&branch=$branch&type=normal"), "<span class='text'>{$lang->release->statusList['normal']}</span>" . ($type == 'normal' ? ' <span class="label label-light label-badge">' . count($releases) . '</span>' : ''), '', "id='normalTab' class='btn btn-link" . ('normal' == $type ? ' btn-active-text' : '') . "'");
|
||||
echo html::a(inlink('browse', "productID={$product->id}&branch=$branch&type=terminate"), "<span class='text'>{$lang->release->statusList['terminate']}</span>" . ($type == 'terminate' ? ' <span class="label label-light label-badge">' . count($releases) . '</span>' : ''), '', "id='terminateTab' class='btn btn-link" . ('terminate' == $type ? ' btn-active-text' : '') . "'");
|
||||
echo html::a(inlink('browse', "type=all"), "<span class='text'>{$lang->release->all}</span>" . ($type == 'all' ? ' <span class="label label-light label-badge">' . count($releases) . '</span>' : ''), '', "id='allTab' class='btn btn-link" . ('all' == $type ? ' btn-active-text' : '') . "'");
|
||||
echo html::a(inlink('browse', "type=normal"), "<span class='text'>{$lang->release->statusList['normal']}</span>" . ($type == 'normal' ? ' <span class="label label-light label-badge">' . count($releases) . '</span>' : ''), '', "id='normalTab' class='btn btn-link" . ('normal' == $type ? ' btn-active-text' : '') . "'");
|
||||
echo html::a(inlink('browse', "type=terminate"), "<span class='text'>{$lang->release->statusList['terminate']}</span>" . ($type == 'terminate' ? ' <span class="label label-light label-badge">' . count($releases) . '</span>' : ''), '', "id='terminateTab' class='btn btn-link" . ('terminate' == $type ? ' btn-active-text' : '') . "'");
|
||||
?>
|
||||
</div>
|
||||
<div class="btn-toolbar pull-right">
|
||||
<?php if(common::canModify('project', $project)):?>
|
||||
<?php common::printLink('projectrelease', 'create', "productID=$product->id&branch=$branch", "<i class='icon icon-plus'></i> {$lang->release->create}", '', "class='btn btn-primary'");?>
|
||||
<?php common::printLink('projectrelease', 'create', '', "<i class='icon icon-plus'></i> {$lang->release->create}", '', "class='btn btn-primary'");?>
|
||||
<?php endif;?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -41,7 +33,7 @@
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->release->noRelease;?></span>
|
||||
<?php if(common::canModify('project', $project) and common::hasPriv('projectrelease', 'create')):?>
|
||||
<?php echo html::a($this->createLink('projectrelease', 'create', "productID=$product->id&branch=$branch"), "<i class='icon icon-plus'></i> " . $lang->release->create, '', "class='btn btn-info'");?>
|
||||
<?php echo html::a($this->createLink('projectrelease', 'create'), "<i class='icon icon-plus'></i> " . $lang->release->create, '', "class='btn btn-info'");?>
|
||||
<?php endif;?>
|
||||
</p>
|
||||
</div>
|
||||
@@ -51,10 +43,9 @@
|
||||
<tr>
|
||||
<th class='w-id'><?php echo $lang->release->id;?></th>
|
||||
<th><?php echo $lang->release->name;?></th>
|
||||
<th class='w-product'><?php echo $lang->release->product;?></th>
|
||||
<th class='w-project'><?php echo $lang->executionCommon;?></th>
|
||||
<th class='w-100px'><?php echo $lang->release->build;?></th>
|
||||
<?php if(isset($product->type) and $product->type != 'normal'):?>
|
||||
<th class='text-center w-100px'><?php echo $lang->product->branch;?></th>
|
||||
<?php endif;?>
|
||||
<th class='c-date text-center w-100px'><?php echo $lang->release->date;?></th>
|
||||
<th class='text-center w-90px'><?php echo $lang->release->status;?></th>
|
||||
<?php
|
||||
@@ -75,10 +66,9 @@
|
||||
echo html::a(inlink('view', "release=$release->id"), $release->name) . $flagIcon;
|
||||
?>
|
||||
</td>
|
||||
<td title='<?php echo $release->productName?>'><?php echo $release->productName?></td>
|
||||
<td title='<?php echo $release->executionName?>'><?php echo $release->executionName?></td>
|
||||
<td title='<?php echo $release->buildName?>'><?php echo empty($release->project) ? $release->buildName : html::a($this->createLink('build', 'view', "buildID=$release->buildID"), $release->buildName);?></td>
|
||||
<?php if(isset($product->type) and $product->type != 'normal'):?>
|
||||
<td class='text-center' title='<?php echo zget($branches, $release->branch, '');?>'><?php echo $branches[$release->branch];?></td>
|
||||
<?php endif;?>
|
||||
<td class='text-center'><?php echo $release->date;?></td>
|
||||
<?php $status = $this->processStatus('release', $release);?>
|
||||
<td class='c-status text-center' title='<?php echo $status;?>'>
|
||||
|
||||
@@ -33,7 +33,16 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->release->build;?></th>
|
||||
<td><?php echo html::select('build', $builds, '', "class='form-control chosen'");?></td><td></td>
|
||||
<td><?php echo html::select('build', $builds, '', "onchange='showProducts(this.value)' class='form-control chosen'");?></td><td></td>
|
||||
</tr>
|
||||
<tr id='productBox'>
|
||||
<th><?php echo $lang->release->product;?></th>
|
||||
<td>
|
||||
<div class='input-group'>
|
||||
<?php echo html::select('product', $products, '', "onchange='loadBranches(this.value)' class='form-control chosen'");?>
|
||||
<?php if($product->type != 'normal') echo html::select('branch', $branches, $branch, "class='form-control chosen control-branch'");?>
|
||||
</div>
|
||||
</td><td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->release->date;?></th>
|
||||
|
||||
Reference in New Issue
Block a user