* finish task #2398.

This commit is contained in:
wangyidong
2015-11-12 09:54:00 +08:00
parent d5916dac13
commit 6f12e34d25
5 changed files with 25 additions and 33 deletions
+15 -19
View File
@@ -70,23 +70,21 @@ class buildModel extends model
if(strpos($params, 'noempty') === false) $sysBuilds = array('' => '');
if(strpos($params, 'notrunk') === false) $sysBuilds = $sysBuilds + array('trunk' => 'Trunk');
$projectBuilds = $this->dao->select('t1.id, t1.name, t3.status as releaseStatus')->from(TABLE_BUILD)->alias('t1')
$projectBuilds = $this->dao->select('t1.id, t1.name, t4.name as branchName')->from(TABLE_BUILD)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->leftJoin(TABLE_RELEASE)->alias('t3')->on('t1.id = t3.build')
->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id')
->where('t1.project')->eq((int)$projectID)
->beginIF($productID)->andWhere('t1.product')->eq((int)$productID)->fi()
->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi()
->beginIF(strpos($params, 'nodone') !== false)->andWhere('t2.status')->ne('done')->fi()
->beginIF(strpos($params, 'noterminate') !== false)->andWhere('t3.status')->ne('terminate')->fi()
->andWhere('t1.deleted')->eq(0)
->orderBy('t1.date desc, t1.id desc')->fetchAll('id');
/* Set builds and filter terminate releases. */
$builds = array();
foreach($projectBuilds as $buildID => $build)
{
if((strpos($params, 'noterminate') !== false) and ($build->releaseStatus === 'terminate')) continue;
$builds[$buildID] = $build->name;
}
foreach($projectBuilds as $buildID => $build) $builds[$buildID] = $build->name;
if(!$builds) return $sysBuilds;
/* if the build has been released, replace build name with release name. */
@@ -114,33 +112,31 @@ class buildModel extends model
if(strpos($params, 'noempty') === false) $sysBuilds = array('' => '');
if(strpos($params, 'notrunk') === false) $sysBuilds = $sysBuilds + array('trunk' => 'Trunk');
$productBuilds = $this->dao->select('t1.id, t1.name, t1.project, t2.status as projectStatus, t3.status as releaseStatus')->from(TABLE_BUILD)->alias('t1')
$productBuilds = $this->dao->select('t1.id, t1.name, t1.project, t4.name as branchName')->from(TABLE_BUILD)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')
->leftJoin(TABLE_RELEASE)->alias('t3')->on('t1.id = t3.build')
->leftJoin(TABLE_BRANCH)->alias('t4')->on('t1.branch = t4.id')
->where('t1.product')->in($products)
->beginIF($branch)->andWhere('t1.branch')->eq($branch)->fi()
->beginIF(strpos($params, 'nodone') !== false)->andWhere('t2.status')->ne('none')->fi()
->beginIF(strpos($params, 'noterminate') !== false)->andWhere('t3.status')->ne('terminate')->fi()
->andWhere('t1.deleted')->eq(0)
->orderBy('t1.date desc, t1.id desc')->fetchAll('id');
/* Set builds and filter done projects and terminate releases. */
$builds = array();
foreach($productBuilds as $key => $build)
{
if((strpos($params, 'nodone') !== false) and ($build->projectStatus === 'done')) continue;
if((strpos($params, 'noterminate') !== false) and ($build->releaseStatus === 'terminate')) continue;
$builds[$key] = $build->name;
}
foreach($productBuilds as $key => $build) $builds[$key] = ((strpos($params, 'withbranch') !== false and $build->branchName) ? $build->branchName . '/' : '') . $build->name;
if(!$builds) return $sysBuilds;
/* if the build has been released and replace is true, replace build name with release name. */
$releases = $this->dao->select('build, name')->from(TABLE_RELEASE)
->where('build')->in(array_keys($builds))
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
->andWhere('deleted')->eq(0)
->fetchPairs('');
if($replace)
{
foreach($releases as $buildID => $releaseName) $builds[$buildID] = $releaseName;
$releases = $this->dao->select('build, name')->from(TABLE_RELEASE)
->where('build')->in(array_keys($builds))
->beginIF($branch)->andWhere('branch')->in("0,$branch")->fi()
->andWhere('deleted')->eq(0)
->fetchPairs();
foreach($releases as $buildID => $releaseName) $builds[$buildID] = ((strpos($params, 'withbranch') !== false and $productBuilds[$buildID]->branchName) ? $productBuilds[$buildID]->branchName . '/' : '') . $releaseName;
}
return $sysBuilds + $builds;
+2 -2
View File
@@ -64,7 +64,7 @@ class release extends control
die(js::locate(inlink('view', "releaseID=$releaseID"), 'parent'));
}
$builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch);
$builds = $this->loadModel('build')->getProductBuildPairs($productID, $branch, 'notrunk|withbranch', false);
$releaseBuilds = $this->release->getReleaseBuilds($productID, $branch);
foreach($releaseBuilds as $build) unset($builds[$build]);
unset($builds['trunk']);
@@ -114,7 +114,7 @@ class release extends control
$this->view->position[] = $this->lang->release->edit;
$this->view->release = $release;
$this->view->build = $build;
$this->view->builds = $this->loadModel('build')->getProductBuildPairs($release->product, $release->branch, 'notrunk', false);
$this->view->builds = $this->loadModel('build')->getProductBuildPairs($release->product, $release->branch, 'notrunk|withbranch', false);
$this->display();
}
+8
View File
@@ -116,8 +116,11 @@ class releaseModel extends model
$buildID = $this->dao->lastInsertID();
}
$branch = 0;
if($this->post->build) $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq($this->post->build)->fetch('branch');
$release = fixer::input('post')
->add('product', (int)$productID)
->add('branch', (int)$branch)
->setDefault('stories', '')
->join('stories', ',')
->join('bugs', ',')
@@ -149,7 +152,12 @@ class releaseModel extends model
public function update($releaseID)
{
$oldRelease = $this->getByID($releaseID);
$branch = $oldRelease->branch;
if($oldRelease->build != $this->post->build) $branch = $this->dao->select('branch')->from(TABLE_BUILD)->where('id')->eq($this->post->build)->fetch('branch');
$release = fixer::input('post')->stripTags($this->config->release->editor->edit['id'], $this->config->allowedTags)
->add('branch', (int)$branch)
->remove('files,labels,allchecker')
->get();
$release = $this->loadModel('file')->processEditor($release, $this->config->release->editor->edit['id']);
-6
View File
@@ -26,12 +26,6 @@ js::set('page' , 'create');
</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->product->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-110px'><?php echo $lang->release->name;?></th>
<td class='w-p25-f'>
-6
View File
@@ -28,12 +28,6 @@ js::set('oldReleasedBuild' , $release->build);
</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->product->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>