* Finish task #8497.

This commit is contained in:
holan20180123
2020-11-27 15:49:52 +08:00
parent 9e358b5905
commit b6c175f837
5 changed files with 28 additions and 98 deletions
+7 -14
View File
@@ -28,6 +28,7 @@ class projectrelease extends control
$this->loadModel('product');
$this->loadModel('release');
$this->view->products = $this->products = $this->product->getProductPairsByProject($this->session->PRJ);
if(empty($this->view->products)) $this->locate($this->createLink('product', 'create'));
}
/**
@@ -44,17 +45,13 @@ class projectrelease extends control
$this->lang->product->switcherMenu = $this->loadModel('product')->getSwitcher($productID);
$this->loadModel('product');
$this->loadModel('project');
$products = $this->product->getProductPairsByProject($this->session->PRJ);
if(empty($products)) $this->locate($this->createLink('product', 'create'));
$product = $this->product->getById($productID);
$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->project = $this->loadModel('project')->getById($this->session->PRJ);
$this->view->products = $products;
$this->product->setMenu($this->product->getPairs(), $productID ? $productID : key($products), $branch);
$this->product->setMenu($this->product->getPairs(), $productID, $branch);
}
/**
@@ -68,13 +65,13 @@ class projectrelease extends control
*/
public function browse($productID = 0, $branch = 0, $type = 'all')
{
if(!$productID) $productID = key($this->view->products);
$this->commonAction($productID, $branch);
$this->session->set('releaseList', $this->app->getURI(true));
$this->view->title = $this->view->project->name . $this->lang->colon . $this->lang->release->browse;
$this->view->position[] = $this->lang->release->browse;
$this->view->releases = $this->projectrelease->getList($productID, $branch, $type, $this->session->PRJ);
$this->view->productID = $productID;
$this->view->releases = $this->projectrelease->getList($productID, $branch, $type);
$this->view->type = $type;
$this->display();
}
@@ -91,7 +88,7 @@ class projectrelease extends control
{
if(!empty($_POST))
{
$releaseID = $this->projectrelease->create();
$releaseID = $this->projectrelease->create($productID, $branch);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
$this->loadModel('action')->create('release', $releaseID, 'opened');
@@ -101,20 +98,16 @@ class projectrelease extends control
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('view', "releaseID=$releaseID")));
}
$builds = $this->loadModel('build')->getProjectBuildPairs($this->session->PRJ, $productID, $branch, 'notrunk|withbranch');
$builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch, 'notrunk|withbranch', false);
$releaseBuilds = $this->projectrelease->getReleaseBuilds($productID, $branch);
foreach($releaseBuilds as $build) unset($builds[$build]);
unset($builds['trunk']);
$this->commonAction($productID, $branch);
$productID = !empty($productID) ? $productID : key($this->view->products);
$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->product = $this->product->getById($productID);
$this->view->branches = $this->loadModel('branch')->getPairs($productID);
$this->view->lastRelease = $this->projectrelease->getLast($productID, $branch);
$this->display();
}
-52
View File
@@ -2,55 +2,3 @@ $(document).ready(function()
{
$("a.preview").modalTrigger({width:1000, type:'iframe'});
})
function loadProduct(productID)
{
if(typeof parentStory != 'undefined' && parentStory)
{
confirmLoadProduct = confirm(moveChildrenTips);
if(!confirmLoadProduct)
{
$('#product').val(oldProductID);
$('#product').trigger("chosen:updated");
return false;
}
}
if(typeof hasSR != 'undefined' && hasSR)
{
confirmLoadProduct = confirm(moveSRTips);//Set hasSR variable in pro and biz.
if(!confirmLoadProduct)
{
$('#product').val(oldProductID);
$('#product').trigger("chosen:updated");
return false;
}
}
oldProductID = $('#product').val();
loadProductBranches(productID)
}
function loadBranch()
{
var branch = $('#branch').val();
if(typeof(branch) == 'undefined') branch = 0;
}
function loadProductBranches(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', config.currentMethod == 'create' ? '120px' : '65px').chosen();
}
$inputGroup.fixInputGroup();
})
}
+16 -12
View File
@@ -46,21 +46,19 @@ class projectreleaseModel extends model
* @param int $productID
* @param int $branch
* @param string $type
* @param int $projectID
* @access public
* @return array
*/
public function getList($productID, $branch = 0, $type = 'all', $projectID = 0)
public function getList($productID, $branch = 0, $type = 'all')
{
return $this->dao->select('t1.*, t2.name as productName, t3.id as buildID, t3.name as buildName, t3.project')
->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')
->where('t1.deleted')->eq(0)
->beginIF($projectID)->andWhere('t1.PRJ')->eq((int)$projectID)->fi()
->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->fi()
->where('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')
->fetchAll();
}
@@ -104,11 +102,16 @@ class projectreleaseModel extends model
/**
* Create a release.
*
* @param int $productID
* @param int $branch
*
* @access public
* @return int
*/
public function create()
public function create($productID, $branch = 0)
{
$productID = (int)$productID;
$branch = (int)$branch;
$buildID = 0;
/* Check build if build is required. */
@@ -119,6 +122,8 @@ class projectreleaseModel extends model
$release = fixer::input('post')
->add('PRJ', $this->session->PRJ)
->add('product', (int)$productID)
->add('branch', (int)$branch)
->setDefault('stories', '')
->join('stories', ',')
->join('bugs', ',')
@@ -130,11 +135,10 @@ class projectreleaseModel extends model
/* Auto create build when release is not link build. */
if(empty($release->build) and $release->name)
{
$branch = isset($release->branch) ? $release->branch : 0;
$build = $this->dao->select('*')->from(TABLE_BUILD)
$build = $this->dao->select('*')->from(TABLE_BUILD)
->where('deleted')->eq('0')
->andWhere('name')->eq($release->name)
->andWhere('product')->eq($release->product)
->andWhere('product')->eq($productID)
->andWhere('branch')->eq($branch)
->fetch();
if($build)
@@ -145,8 +149,8 @@ class projectreleaseModel extends model
{
$build = new stdclass();
$build->PRJ = $this->session->PRJ;
$build->product = $release->product;
$build->branch = $branch;
$build->product = (int)$productID;
$build->branch = (int)$branch;
$build->name = $release->name;
$build->date = $release->date;
$build->builder = $this->app->user->account;
@@ -156,7 +160,7 @@ class projectreleaseModel extends model
$build = $this->loadModel('file')->processImgURL($build, $this->config->release->editor->create['id']);
$this->dao->insert(TABLE_BUILD)->data($build)
->autoCheck()
->check('name', 'unique', "product = {$release->product} AND branch = {$branch} AND deleted = '0'")
->check('name', 'unique', "product = {$productID} AND branch = {$branch} AND deleted = '0'")
->batchCheck($this->config->release->create->requiredFields, 'notempty')
->exec();
if(dao::isError()) return false;
+5 -5
View File
@@ -16,14 +16,14 @@
<div id="mainMenu" class="clearfix">
<div class="btn-toolbar pull-left">
<?php
echo html::a(inlink('browse', "productID={$productID}&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={$productID}&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={$productID}&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', "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' : '') . "'");
?>
</div>
<div class="btn-toolbar pull-right">
<?php if(common::canModify('project', $project)):?>
<?php common::printLink('projectrelease', 'create', "productID=$productID&branch=$branch", "<i class='icon icon-plus'></i> {$lang->release->create}", '', "class='btn btn-primary'");?>
<?php common::printLink('projectrelease', 'create', "productID=$product->id&branch=$branch", "<i class='icon icon-plus'></i> {$lang->release->create}", '', "class='btn btn-primary'");?>
<?php endif;?>
</div>
</div>
@@ -33,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=$productID&branch=$branch"), "<i class='icon icon-plus'></i> " . $lang->release->create, '', "class='btn btn-info'");?>
<?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 endif;?>
</p>
</div>
@@ -20,21 +20,6 @@
<form class='load-indicator main-form form-ajax' id='dataform' method='post' enctype='multipart/form-data'>
<table class='table table-form'>
<tbody>
<tr>
<th><?php echo $lang->release->product;?></th>
<td>
<?php if($product->type != 'normal'):?>
<div class='input-group'>
<?php endif;?>
<?php echo html::select('product', $products, $productID, "onchange='loadProduct(this.value);' class='form-control chosen control-product'");?>
<?php if($product->type != 'normal'):?>
<span class='input-group-addon fix-border fix-padding'></span>
<?php echo html::select('branch', $branches, $branch, "onchange='loadBranch();' class='form-control chosen control-branch'");?>
</div>
<?php endif;?>
</td>
<td></td>
</tr>
<tr>
<th><?php echo $lang->release->name;?></th>
<td><?php echo html::input('name', '', "class='form-control' required");?></td>