diff --git a/module/build/model.php b/module/build/model.php
index c6927fe4e7..cdeb440096 100644
--- a/module/build/model.php
+++ b/module/build/model.php
@@ -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)
diff --git a/module/projectrelease/control.php b/module/projectrelease/control.php
index defbce880c..ecd4ee58d0 100644
--- a/module/projectrelease/control.php
+++ b/module/projectrelease/control.php
@@ -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();
}
diff --git a/module/projectrelease/js/common.js b/module/projectrelease/js/common.js
index 1f3ddf85b3..28aa8ce628 100644
--- a/module/projectrelease/js/common.js
+++ b/module/projectrelease/js/common.js
@@ -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();
+ })
+}
diff --git a/module/projectrelease/model.php b/module/projectrelease/model.php
index c4d347303e..d7c7ffffd4 100644
--- a/module/projectrelease/model.php
+++ b/module/projectrelease/model.php
@@ -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();
diff --git a/module/projectrelease/view/browse.html.php b/module/projectrelease/view/browse.html.php
index d1f219770f..8b6600de9b 100644
--- a/module/projectrelease/view/browse.html.php
+++ b/module/projectrelease/view/browse.html.php
@@ -15,23 +15,15 @@
release->confirmDelete)?>
-
- {$product->name} ", '', "class='btn btn-link btn-limit' style='border-radius: 2px;' data-toggle='dropdown'")?>
-
-
id}&branch=$branch&type=all"), "
{$lang->release->all}" . ($type == 'all' ? '
' . count($releases) . '' : ''), '', "id='allTab' class='btn btn-link" . ('all' == $type ? ' btn-active-text' : '') . "'");
- echo html::a(inlink('browse', "productID={$product->id}&branch=$branch&type=normal"), "
{$lang->release->statusList['normal']}" . ($type == 'normal' ? '
' . count($releases) . '' : ''), '', "id='normalTab' class='btn btn-link" . ('normal' == $type ? ' btn-active-text' : '') . "'");
- echo html::a(inlink('browse', "productID={$product->id}&branch=$branch&type=terminate"), "
{$lang->release->statusList['terminate']}" . ($type == 'terminate' ? '
' . count($releases) . '' : ''), '', "id='terminateTab' class='btn btn-link" . ('terminate' == $type ? ' btn-active-text' : '') . "'");
+ echo html::a(inlink('browse', "type=all"), "
{$lang->release->all}" . ($type == 'all' ? '
' . count($releases) . '' : ''), '', "id='allTab' class='btn btn-link" . ('all' == $type ? ' btn-active-text' : '') . "'");
+ echo html::a(inlink('browse', "type=normal"), "
{$lang->release->statusList['normal']}" . ($type == 'normal' ? '
' . count($releases) . '' : ''), '', "id='normalTab' class='btn btn-link" . ('normal' == $type ? ' btn-active-text' : '') . "'");
+ echo html::a(inlink('browse', "type=terminate"), "
{$lang->release->statusList['terminate']}" . ($type == 'terminate' ? '
' . count($releases) . '' : ''), '', "id='terminateTab' class='btn btn-link" . ('terminate' == $type ? ' btn-active-text' : '') . "'");
?>
- id&branch=$branch", " {$lang->release->create}", '', "class='btn btn-primary'");?>
+ {$lang->release->create}", '', "class='btn btn-primary'");?>
@@ -41,7 +33,7 @@
release->noRelease;?>
- createLink('projectrelease', 'create', "productID=$product->id&branch=$branch"), " " . $lang->release->create, '', "class='btn btn-info'");?>
+ createLink('projectrelease', 'create'), " " . $lang->release->create, '', "class='btn btn-info'");?>
@@ -51,10 +43,9 @@
| release->id;?> |
release->name;?> |
+ release->product;?> |
+ executionCommon;?> |
release->build;?> |
- type) and $product->type != 'normal'):?>
- product->branch;?> |
-
release->date;?> |
release->status;?> |
id"), $release->name) . $flagIcon;
?>
+ productName?> |
+ executionName?> |
project) ? $release->buildName : html::a($this->createLink('build', 'view', "buildID=$release->buildID"), $release->buildName);?> |
- type) and $product->type != 'normal'):?>
- '>branch];?> |
-
date;?> |
processStatus('release', $release);?>
diff --git a/module/projectrelease/view/create.html.php b/module/projectrelease/view/create.html.php
index 8fddb38e36..bb4f7ff55b 100644
--- a/module/projectrelease/view/create.html.php
+++ b/module/projectrelease/view/create.html.php
@@ -33,7 +33,16 @@
|
| release->build;?> |
- | |
+ | |
+
+
+ | release->product;?> |
+
+
+
+ type != 'normal') echo html::select('branch', $branches, $branch, "class='form-control chosen control-branch'");?>
+
+ | |
| release->date;?> |