* finish task #2361.

This commit is contained in:
wangyidong
2015-10-15 17:28:40 +08:00
parent ea93e3cc5b
commit c571a8a440
8 changed files with 131 additions and 60 deletions
+2
View File
@@ -0,0 +1,2 @@
ALTER TABLE `zt_action` CHANGE `extra` `extra` text COLLATE 'utf8_general_ci' NOT NULL AFTER `comment`;
ALTER TABLE `zt_release` ADD `leftBugs` text COLLATE 'utf8_general_ci' NOT NULL AFTER `bugs`;
+1 -1
View File
@@ -9,7 +9,7 @@ CREATE TABLE IF NOT EXISTS `zt_action` (
`action` varchar(30) NOT NULL default '',
`date` datetime NOT NULL,
`comment` text NOT NULL,
`extra` varchar(255) NOT NULL,
`extra` text NOT NULL,
`read` enum('0','1') NOT NULL default '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
+35
View File
@@ -851,6 +851,41 @@ class bugModel extends model
return $bugs;
}
/**
* Get product left bugs.
*
* @param int $build
* @param int $productID
* @access public
* @return array
*/
public function getProductLeftBugs($build, $productID)
{
$build = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->eq($build)->fetch();
if(empty($build->project)) return array();
$project = $this->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($build->project)->fetch();
$beforeBuilds = $this->dao->select('t1.id')->from(TABLE_BUILD)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t1.product')->eq($productID)
->andWhere('t2.status')->ne('done')
->andWhere('t2.deleted')->eq(0)
->andWhere('t1.deleted')->eq(0)
->andWhere('t1.date')->lt($project->begin)
->fetchPairs('id', 'id');
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where('deleted')->eq(0)
->andWhere('product')->eq($productID)
->andWhere('toStory')->eq(0)
->andWhere('openedDate')->ge($project->begin)
->andWhere('openedDate')->le($project->end)
->andWhere("(status = 'active' OR resolvedDate > {$project->end})")
->andWhere('openedBuild')->notin($beforeBuilds)
->fetchAll();
return $bugs;
}
/**
* get Product Bug Pairs
*
+26 -26
View File
@@ -126,6 +126,7 @@ class release extends control
{
if($type == 'story') $this->session->set('storyList', $this->app->getURI(true));
if($type == 'bug') $this->session->set('bugList', $this->app->getURI(true));
if($type == 'leftBug')$this->session->set('leftBugList', $this->app->getURI(true));
$this->loadModel('story');
$this->loadModel('bug');
@@ -139,19 +140,8 @@ class release extends control
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($release->bugs)->andWhere('deleted')->eq(0)->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'linkedBug');
$build = $this->loadModel('build')->getById($release->build);
$generatedBugs = array();
if($build->project)
{
$generatedBugs = $this->dao->select('*')->from(TABLE_BUG)->where('deleted')->eq(0)
->andWhere('product')->eq($release->product)
->andWhere("(project = '" . (int)$build->project . "'" . (empty($build->id) ? '' : " OR CONCAT(',', openedBuild, ',') like '%,$build->id,%'") . ")")
->andWhere('status')->eq('active')
->andWhere('toStory')->eq(0)
->orderBy('id_desc')->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'newBugs');
}
$leftBugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($release->leftBugs)->andWhere('deleted')->eq(0)->fetchAll();
$this->loadModel('common')->saveQueryCondition($this->dao->get(), 'newBugs');
$this->commonAction($release->product);
$products = $this->product->getPairs();
@@ -161,7 +151,7 @@ class release extends control
$this->view->release = $release;
$this->view->stories = $stories;
$this->view->bugs = $bugs;
$this->view->generatedBugs = $generatedBugs;
$this->view->leftBugs = $leftBugs;
$this->view->actions = $this->loadModel('action')->getList('release', $releaseID);
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->view->type = $type;
@@ -423,12 +413,12 @@ class release extends control
* @access public
* @return void
*/
public function linkBug($releaseID = 0, $browseType = '', $param = 0)
public function linkBug($releaseID = 0, $browseType = '', $param = 0, $type = 'bug')
{
if(!empty($_POST['bugs']))
{
$this->release->linkBug($releaseID);
die(js::locate(inlink('view', "releaseID=$releaseID&type=bug"), 'parent'));
$this->release->linkBug($releaseID, $type);
die(js::locate(inlink('view', "releaseID=$releaseID&type=$type"), 'parent'));
}
/* Set menu. */
@@ -440,7 +430,7 @@ class release extends control
$this->loadModel('bug');
$queryID = ($browseType == 'bysearch') ? (int)$param : 0;
unset($this->config->bug->search['fields']['product']);
$this->config->bug->search['actionURL'] = $this->createLink('release', 'view', "releaseID=$releaseID&type=bug&link=true&param=" . helper::safe64Encode('&browseType=bySearch&queryID=myQueryID'));
$this->config->bug->search['actionURL'] = $this->createLink('release', 'view', "releaseID=$releaseID&type=$type&link=true&param=" . helper::safe64Encode('&browseType=bySearch&queryID=myQueryID'));
$this->config->bug->search['queryID'] = $queryID;
$this->config->bug->search['style'] = 'simple';
$this->config->bug->search['params']['plan']['values'] = $this->loadModel('productplan')->getForProducts(array($release->product => $release->product));
@@ -450,21 +440,31 @@ class release extends control
$this->config->bug->search['params']['resolvedBuild']['values'] = $this->config->bug->search['params']['openedBuild']['values'];
$this->loadModel('search')->setSearchParams($this->config->bug->search);
$allBugs = array();
if($browseType == 'bySearch')
{
$allBugs = $this->bug->getBySearch($release->product, $queryID, 'id_desc');
}
else
elseif($build->project)
{
$allBugs = empty($build->project) ? array() : $this->bug->getReleaseBugs($build->id, $release->product);
if($type == 'bug')
{
$allBugs = $this->bug->getReleaseBugs($build->id, $release->product);
}
elseif($type == 'leftBug')
{
$allBugs = $this->bug->getProductLeftBugs($build->id, $release->product);
}
}
$releaseBugs = $type == 'bug' ? $release->bugs : $release->leftBugs;
$this->view->allBugs = $allBugs;
$this->view->releaseBugs = empty($release->bugs) ? array() : $this->bug->getByList($release->bugs);
$this->view->releaseBugs = empty($releaseBugs) ? array() : $this->bug->getByList($releaseBugs);
$this->view->release = $release;
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->view->browseType = $browseType;
$this->view->param = $param;
$this->view->type = $type;
$this->display();
}
@@ -476,9 +476,9 @@ class release extends control
* @access public
* @return void
*/
public function unlinkBug($releaseID, $bugID)
public function unlinkBug($releaseID, $bugID, $type = 'bug')
{
$this->release->unlinkBug($releaseID, $bugID);
$this->release->unlinkBug($releaseID, $bugID, $type);
/* if ajax request, send result. */
if($this->server->ajax)
@@ -505,9 +505,9 @@ class release extends control
* @access public
* @return void
*/
public function batchUnlinkBug($releaseID)
public function batchUnlinkBug($releaseID, $type = 'bug')
{
$this->release->batchUnlinkBug($releaseID);
die(js::locate($this->createLink('release', 'view', "releaseID=$releaseID&type=bug"), 'parent'));
$this->release->batchUnlinkBug($releaseID, $type);
die(js::locate($this->createLink('release', 'view', "releaseID=$releaseID&type=$type"), 'parent'));
}
}
+5 -3
View File
@@ -1,13 +1,15 @@
function showLink(releaseID, type, param)
{
var method = type == 'story' ? 'linkStory' : 'linkBug';
$.get(createLink('release', method, 'releaseID=' + releaseID + (typeof(param) == 'undefined' ? '' : param)), function(data)
if(typeof(param) == 'undefined') param = '&browseType=' + type + '&param=0';
if(type == 'leftBug') param += '&type=leftBug';
$.get(createLink('release', method, 'releaseID=' + releaseID + param), function(data)
{
var obj = type == 'story' ? '.tab-pane#stories .linkBox' : '.tab-pane#bugs .linkBox';
var obj = type == 'story' ? '.tab-pane#stories .linkBox' : (type == 'leftBug' ? '.tab-pane#leftBugs .linkBox' : '.tab-pane#bugs .linkBox');
$(obj).html(data);
$('#' + type + 'List').hide();
var formID = type == 'story' ? '#unlinkedStoriesForm' : '#unlinkedBugsForm';
var formID = type == 'story' ? '#unlinkedStoriesForm' : (type == 'leftBug' ? '#unlinkedLeftBugsForm' : '#unlinkedBugsForm');
fixTfootAction(formID);
});
}
+14 -11
View File
@@ -212,12 +212,13 @@ class releaseModel extends model
* @access public
* @return void
*/
public function linkBug($releaseID)
public function linkBug($releaseID, $type = 'bug')
{
$release = $this->getByID($releaseID);
$release->bugs .= ',' . join(',', $this->post->bugs);
$this->dao->update(TABLE_RELEASE)->set('bugs')->eq($release->bugs)->where('id')->eq((int)$releaseID)->exec();
$field = $type == 'bug' ? 'bugs' : 'leftBugs';
$release->$field .= ',' . join(',', $this->post->bugs);
$this->dao->update(TABLE_RELEASE)->set($field)->eq($release->$field)->where('id')->eq((int)$releaseID)->exec();
}
/**
@@ -228,11 +229,12 @@ class releaseModel extends model
* @access public
* @return void
*/
public function unlinkBug($releaseID, $bugID)
public function unlinkBug($releaseID, $bugID, $type = 'bug')
{
$release = $this->getByID($releaseID);
$release->bugs = trim(str_replace(",$bugID,", ',', ",$release->bugs,"), ',');
$this->dao->update(TABLE_RELEASE)->set('bugs')->eq($release->bugs)->where('id')->eq((int)$releaseID)->exec();
$field = $type == 'bug' ? 'bugs' : 'leftBugs';
$release->{$field} = trim(str_replace(",$bugID,", ',', ",{$release->$field},"), ',');
$this->dao->update(TABLE_RELEASE)->set($field)->eq($release->$field)->where('id')->eq((int)$releaseID)->exec();
}
/**
@@ -242,16 +244,17 @@ class releaseModel extends model
* @access public
* @return void
*/
public function batchUnlinkBug($releaseID)
public function batchUnlinkBug($releaseID, $type = 'bug')
{
$bugList = $this->post->unlinkBugs;
if(empty($bugList)) return true;
$release = $this->getByID($releaseID);
$release->bugs = ",$release->bugs,";
foreach($bugList as $bugID) $release->bugs = str_replace(",$bugID,", ',', $release->bugs);
$release->bugs = trim($release->bugs, ',');
$this->dao->update(TABLE_RELEASE)->set('bugs')->eq($release->bugs)->where('id')->eq((int)$releaseID)->exec();
$field = $type == 'bug' ? 'bugs' : 'leftBugs';
$release->$field = ",{$release->$field},";
foreach($bugList as $bugID) $release->$field = str_replace(",$bugID,", ',', $release->$field);
$release->$field = trim($release->$field, ',');
$this->dao->update(TABLE_RELEASE)->set($field)->eq($release->$field)->where('id')->eq((int)$releaseID)->exec();
}
}
+11 -7
View File
@@ -11,8 +11,12 @@
*/
?>
<div id='querybox' class='show'></div>
<div id='unlinkBugList'>
<form method='post' target='hiddenwin' id='unlinkedBugsForm' action='<?php echo $this->createLink('release', 'linkBug', "releaseID=$release->id&browseType=$browseType&param=$param")?>'>
<?php
$releaseBugs = $type == 'bug' ? $release->bugs : $release->leftBugs;
$formID = $type == 'leftBug' ? 'unlinkedLeftBugsForm' : 'unlinkedBugsForm';
?>
<div id='<?php echo $type == 'bug' ? 'unlinkBugList' : 'unlinkLeftBugList';?>'>
<form method='post' target='hiddenwin' id='<?php echo $formID?>' action='<?php echo $this->createLink('release', 'linkBug', "releaseID=$release->id&browseType=$browseType&param=$param&type=$type")?>'>
<table class='table table-condensed table-hover table-striped tablesorter table-fixed'>
<caption class='text-left text-special'><?php echo html::icon('unlink');?> &nbsp;<strong><?php echo $lang->productplan->unlinkedBugs;?></strong></caption>
<thead>
@@ -27,10 +31,10 @@
</thead>
<tbody>
<?php foreach($allBugs as $bug):?>
<?php if(strpos(",{$release->bugs},", ",$bug->id,") !== false) continue;?>
<?php if(strpos(",{$releaseBugs},", ",$bug->id,") !== false) continue;?>
<tr>
<td class='text-left'>
<input class='ml-10px' type='checkbox' name='bugs[<?php echo $bug->id?>]' value='<?php echo $bug->id;?>' <?php if($bug->status == 'resolved' or $bug->status == 'closed') echo "checked";?> />
<input class='ml-10px' type='checkbox' name='bugs[<?php echo $bug->id?>]' value='<?php echo $bug->id;?>' <?php if($type == 'leftBug' or $bug->status == 'resolved' or $bug->status == 'closed') echo "checked";?> />
<?php echo html::a($this->createLink('bug', 'view', "bugID=$bug->id"), $bug->id);?>
</td>
<td><span class='<?php echo 'pri' . zget($lang->bug->priList, $bug->pri, $bug->pri);?>'><?php echo zget($lang->bug->priList, $bug->pri, $bug->pri)?></span></td>
@@ -47,8 +51,8 @@
<?php if(count($allBugs))
{
echo "<div class='table-actions clearfix'>";
echo "<div class='btn-group'>" . html::selectAll('unlinkedBugsForm') . html::selectReverse('unlinkedBugsForm') . '</div>';
echo html::submitButton($lang->release->linkBug) . html::a(inlink('view', "releaseID=$release->id&type=bug"), $lang->goback, '', "class='btn'") . '</div>';
echo "<div class='btn-group'>" . html::selectAll($formID) . html::selectReverse($formID) . '</div>';
echo html::submitButton($lang->release->linkBug) . html::a(inlink('view', "releaseID=$release->id&type=$type"), $lang->goback, '', "class='btn'") . '</div>';
}
?>
</td>
@@ -57,4 +61,4 @@
</table>
</form>
</div>
<script>$(function(){ajaxGetSearchForm('#bugs .linkBox #querybox')})</script>
<script>$(function(){ajaxGetSearchForm('#<?php echo $type == 'bug' ? 'bugs' : 'leftBugs'?> .linkBox #querybox')})</script>
+37 -12
View File
@@ -57,12 +57,12 @@
<div class='col-main'>
<div class='main'>
<div class='tabs'>
<?php $countStories = count($stories); $countBugs = count($bugs); $countNewBugs = count($generatedBugs);?>
<?php $countStories = count($stories); $countBugs = count($bugs); $countLeftBugs = count($leftBugs);?>
<ul class='nav nav-tabs'>
<li <?php if($type == 'story') echo "class='active'"?>><a href='#stories' data-toggle='tab'><?php echo html::icon($lang->icons['story'], 'green') . ' ' . $lang->release->stories;?></a></li>
<li <?php if($type == 'bug') echo "class='active'"?>><a href='#bugs' data-toggle='tab'><?php echo html::icon($lang->icons['bug'], 'green') . ' ' . $lang->release->bugs;?></a></li>
<li <?php if($type == 'newbug') echo "class='active'"?>><a href='#newBugs' data-toggle='tab'><?php echo html::icon($lang->icons['bug'], 'red') . ' ' . $lang->release->generatedBugs;?></a></li>
<?php if($countStories or $countBugs or $countNewBugs):?>
<li <?php if($type == 'story') echo "class='active'"?>><a href='#stories' data-toggle='tab'><?php echo html::icon($lang->icons['story'], 'green') . ' ' . $lang->release->stories;?></a></li>
<li <?php if($type == 'bug') echo "class='active'"?>><a href='#bugs' data-toggle='tab'><?php echo html::icon($lang->icons['bug'], 'green') . ' ' . $lang->release->bugs;?></a></li>
<li <?php if($type == 'leftBug') echo "class='active'"?>><a href='#leftBugs' data-toggle='tab'><?php echo html::icon($lang->icons['bug'], 'red') . ' ' . $lang->release->generatedBugs;?></a></li>
<?php if($countStories or $countBugs or $countLeftBugs):?>
<li class='pull-right'><?php common::printIcon('release', 'export', '', '', 'button', '', '', "export");?></li>
<?php endif;?>
</ul>
@@ -185,8 +185,13 @@
</table>
</form>
</div>
<div class='tab-pane <?php if($type == 'newbug') echo 'active'?>' id='newBugs'>
<table class='table table-hover table-condensed table-striped tablesorter table-fixed'>
<div class='tab-pane <?php if($type == 'leftBug') echo 'active'?>' id='leftBugs'>
<?php if(common::hasPriv('release', 'linkBug')):?>
<div class='action'><?php echo html::a("javascript:showLink({$release->id}, \"leftBug\")", '<i class="icon-bug"></i> ' . $lang->release->linkBug, '', "class='btn btn-sm btn-primary'");?></div>
<div class='linkBox'></div>
<?php endif;?>
<form method='post' target='hiddenwin' action="<?php echo inLink('batchUnlinkBug', "releaseID=$release->id&type=leftBug");?>" id='linkedBugsForm'>
<table class='table table-hover table-condensed table-striped tablesorter table-fixed' id='leftBugList'>
<thead>
<tr>
<th class='w-id'><?php echo $lang->idAB;?></th>
@@ -195,29 +200,49 @@
<th class='w-100px'><?php echo $lang->bug->status;?></th>
<th class='w-user'><?php echo $lang->openedByAB;?></th>
<th class='w-150px'><?php echo $lang->bug->openedDateAB;?></th>
<th class='w-50px'><?php echo $lang->actions;?></th>
</tr>
</thead>
<?php foreach($generatedBugs as $bug):?>
<?php $canBatchUnlink = common::hasPriv('release', 'batchUnlinkBug');?>
<?php foreach($leftBugs as $bug):?>
<?php $bugLink = $this->createLink('bug', 'view', "bugID=$bug->id", '', true);?>
<tr class='text-center'>
<td><?php echo sprintf('%03d', $bug->id);?></td>
<td>
<?php if($canBatchUnlink):?>
<input class='ml-10px' type='checkbox' name='unlinkBugs[]' value='<?php echo $bug->id;?>'/>
<?php endif;?>
<?php echo sprintf('%03d', $bug->id);?>
</td>
<td><span class='severity<?php echo zget($lang->bug->severityList, $bug->severity, $bug->severity)?>'><?php echo zget($lang->bug->severityList, $bug->severity, $bug->severity);?></span></td>
<td class='text-left nobr'><?php echo html::a($bugLink, $bug->title, '', "class='preview'");?></td>
<td class='bug-<?php echo $bug->status?>'><?php echo $lang->bug->statusList[$bug->status];?></td>
<td><?php echo $users[$bug->openedBy];?></td>
<td><?php echo $bug->openedDate?></td>
<td>
<?php
if(common::hasPriv('release', 'unlinkBug'))
{
$unlinkURL = $this->createLink('release', 'unlinkBug', "releaseID=$release->id&bug=$bug->id&type=leftBug");
echo html::a("javascript:ajaxDelete(\"$unlinkURL\",\"leftBugList\",confirmUnlinkBug)", '<i class="icon-unlink"></i>', '', "class='btn-icon' title='{$lang->release->unlinkBug}'");
}
?>
</td>
</tr>
<?php endforeach;?>
<tfoot>
<tr>
<td colspan='6'>
<td colspan='7'>
<div class='table-actions clearfix'>
<div class='text'><?php echo sprintf($lang->release->createdBugs, $countNewBugs);?></div>
<div class='text'>
<?php if($countLeftBugs and $canBatchUnlink) echo "<div class='table-actions clearfix'><div class='btn-group'>" . html::selectAll('linkedBugsForm') . html::selectReverse('linkedBugsForm') . '</div>' . html::submitButton($lang->release->batchUnlink) . '</div>';?>
<?php echo sprintf($lang->release->createdBugs, $countLeftBugs);?>
</div>
</div>
</td>
</tr>
</tfoot>
</table>
</form>
</div>
</div>
</div>
@@ -272,7 +297,7 @@
</div>
</div>
<style>
.tabs .tab-content .tab-pane .action{position: absolute; right: <?php echo ($countStories or $countBugs or $countNewBugs) ? '110px' : '0px'?>; top: 0px;}
.tabs .tab-content .tab-pane .action{position: absolute; right: <?php echo ($countStories or $countBugs or $countLeftBugs) ? '110px' : '0px'?>; top: 0px;}
</style>
<?php js::set('param', helper::safe64Decode($param))?>
<?php js::set('link', $link)?>