* 1.add link bug method for bug module.

* 2.hide toStory, toTask or toCase when not exit for bug.
This commit is contained in:
chenfeiCF
2016-03-11 07:13:47 +08:00
parent 1e22ef4ea7
commit 6f9b3d3e61
8 changed files with 228 additions and 7 deletions

View File

@@ -878,6 +878,110 @@ class bug extends control
$this->display();
}
/**
* Link related bugs.
*
* @param int $bugID
* @param string $bugs
* @param string $browseType
* @param int $param
* @access public
* @return void
*/
public function linkBugs($bugID, $bugs = '', $browseType = '', $param = 0)
{
/* Link bugs. */
if(!empty($_POST))
{
$bugs = $this->bug->linkBugs($bugID, $bugs);
if(isonlybody()) die(js::closeModal('parent.parent', '', "function(){parent.parent.loadLinkedBugs('$bugID', '$bugs')}"));
die(js::locate($this->createLink('bug', 'edit', "bugID=$bugID"), 'parent'));
}
/* Get bug, productID and queryID. */
$bug = $this->bug->getById($bugID);
$productID = $this->product->saveState($bug->product, $this->products);
$queryID = ($browseType == 'bysearch') ? (int)$param : 0;
/* Set the menu. */
$this->bug->setMenu($this->products, $productID, $bug->branch);
/* Build the search form. */
$actionURL = $this->createLink('bug', 'linkBugs', "bugID=$bugID&bugs=$bugs&browseType=bySearch&queryID=myQueryID", '', true);
$this->bug->buildSearchForm($productID, $this->products, $queryID, $actionURL);
$this->loadModel('search')->setSearchParams($this->config->bug->search);
/* Get bugs to link. */
$allBugs = array();
if($browseType == 'bySearch') $allBugs = $this->bug->getBySearch($bug->product, $quueryID, 'id', null);
/* Assign. */
$this->view->title = $this->lang->bug->linkBugs . "BUG #$bug->id $bug->title - " . $this->products[$productID];
$this->view->position[] = html::a($this->createLink('product', 'view', "productID=$productID"), $this->products[$productID]);
$this->view->position[] = html::a($this->createLink('bug', 'view', "bugID=$bugID"), $bug->title);
$this->view->position[] = $this->lang->bug->linkBugs;
$this->view->bug = $bug;
$this->view->allBugs = $allBugs;
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->display();
}
/**
* AJAX: get linked bugs.
*
* @param int $bugID
* @param string $linkedBugs
* @access public
* @return string
*/
public function ajaxGetLinkedBugs($bugID, $linkedBugs = '')
{
/* Get bug and linked bugs. */
$bug = $this->bug->getById($bugID);
$bugs = $this->bug->getLinkedBugs($linkedBugs);
/* Build linkBug list.*/
$output = "<ul class='list-unstyled'>";
$output .= html::a(inlink('linkBugs', "bugID=$bugID&bugs=$bug->linkBug", '', true), $this->lang->bug->linkBugs, '', "class='iframe' data-width='85%'");
foreach($bugs as $bugId => $title)
{
$output .= '<li>';
$output .= html::a(inlink('view', "bugID=$bugId"), "#$bugId " . $title);
$output .= html::a("javascript:deleteLinkedBug($bugID, $bugId)", '<i class="icon-remove"></i>', '', "title='{$this->lang->unlink}' style='float:right'");
$output .= '</li>';
}
$output .= '</ul>';
die($output);
}
/**
* AJAX: delete a linked bug.
*
* @param int $bugID
* @param int $deleteBug
* @access public
* @return string
*/
public function ajaxDeleteLinkedBug($bugID, $deleteBug)
{
/* Get bug and bugs. */
$bug = $this->bug->getById($bugID);
$bugs = $this->bug->deleteLinkedBug($bugID, $deleteBug);
/* Build linkBug list. */
$output = "<ul class='list-unstyled'>";
$output .= html::a(inlink('linkBugs', "bugID=$bugID&bugs=$bug->linkBug", '', true), $this->lang->bug->linkBugs, '', "class='iframe' data-width='85%'");
foreach($bugs as $bugId => $title)
{
$output .= '<li>' . html::a(inlink('view', "bugID=$bugId"), "#$bugId " . $title) . html::a("javascript:deleteLinkedBug($bugID, $bugId)", '<i class="icon-remove"></i>', '', "style='float:right'");
}
$output .= '</ul>';
die($output);
}
/**
* Batch close bugs.
*

View File

@@ -2,3 +2,4 @@
.col-side .chosen-container {width: 218px!important}
.col-side .chosen-container[id^="openedBuild"] {width: 172px!important}
.col-side .chosen-container[id^="resolvedBuild"] {width: 172px!important}
#linkBugBox > .list-unstyled > li {margin-left:-56px}

View File

@@ -54,3 +54,31 @@ function loadModuleRelated()
productID = $('#product').val();
setStories(moduleID, productID);
}
/**
* Delete a linked bug.
*
* @param int $bugID
* @param int $deleteBug
* @access public
* @return void
*/
function deleteLinkedBug(bugID, deleteBug)
{
deleteLink = createLink('bug', 'ajaxDeleteLinkedBug', 'bugID=' + bugID + '&deleteBug=' + deleteBug);
$('#linkBugBox').load(deleteLink);
}
/**
* Load linked bugs.
*
* @param int $bugID
* @param string $linkedBugs
* @access public
* @return void
*/
function loadLinkedBugs(bugID, linkedBugs)
{
bugLink = createLink('bug', 'ajaxGetLinkedBugs', 'bugID=' + bugID + '&linkedBugs=' + linkedBugs);
$('#linkBugBox').load(bugLink);
}

View File

@@ -60,6 +60,7 @@ $lang->bug->duplicateBug = 'Duplicate';
$lang->bug->lastEditedBy = 'Last Edited By';
$lang->bug->lastEditedDate = 'Last Edited Date';
$lang->bug->linkBug = 'Related';
$lang->bug->linkBugs = 'Link bugs';
$lang->bug->case = 'Case';
$lang->bug->files = 'Files';
$lang->bug->keywords = 'Keywords';
@@ -359,6 +360,8 @@ $lang->bug->action->tostory = array('main' => '$date, To story by <stro
$lang->bug->action->totask = array('main' => '$date, To task by <strong>$actor</strong>, ID is <strong>$extra</strong>.');
$lang->bug->action->linked2plan = array('main' => '$date, Link to plan by <strong>$actor</strong>,ID is <strong>$extra</strong>。');
$lang->bug->action->unlinkedfromplan = array('main' => '$date, Unlink from plan <strong>$extra</strong> by <strong>$actor</strong>.');
$lang->bug->action->linked2bug = array('main' => '$date, linked related bugs <strong>$extra</strong> by <strong>$actor</strong>.');
$lang->bug->action->unlinkedbug = array('main' => '$date, removed related bugs <strong>$extra</strong> by <strong>$actor</strong>.');
$lang->bug->placeholder = new stdclass();
$lang->bug->placeholder->chooseBuilds = 'Choose builds...';

View File

@@ -60,6 +60,7 @@ $lang->bug->duplicateBug = '重复ID';
$lang->bug->lastEditedBy = '最后修改者';
$lang->bug->lastEditedDate = '最后修改日期';
$lang->bug->linkBug = '相关Bug';
$lang->bug->linkBugs = '关联Bug';
$lang->bug->case = '相关用例';
$lang->bug->files = '附件';
$lang->bug->keywords = '关键词';
@@ -359,6 +360,8 @@ $lang->bug->action->tostory = array('main' => '$date, 由 <strong>$acto
$lang->bug->action->totask = array('main' => '$date, 由 <strong>$actor</strong> 导入为<strong>任务</strong>,编号为 <strong>$extra</strong>。');
$lang->bug->action->linked2plan = array('main' => '$date, 由 <strong>$actor</strong> 关联到计划 <strong>$extra</strong>。');
$lang->bug->action->unlinkedfromplan = array('main' => '$date, 由 <strong>$actor</strong> 从计划 <strong>$extra</strong> 移除。');
$lang->bug->action->linked2bug = array('main' => '$date, 由 <strong>$actor</strong> 关联相关Bug <strong>$extra</strong>。');
$lang->bug->action->unlinkedbug = array('main' => '$date, 由 <strong>$actor</strong> 移除相关Bug <strong>$extra</strong>。');
$lang->bug->placeholder = new stdclass();
$lang->bug->placeholder->chooseBuilds = '选择相关版本...';

View File

@@ -794,6 +794,64 @@ class bugModel extends model
$this->dao->update(TABLE_BUG)->data($bug)->autoCheck()->where('id')->eq((int)$bugID)->exec();
}
/**
* Link bugs.
*
* @param int $bugID
* @param string $bugs
* @access public
* @return string
*/
public function linkBugs($bugID, $bugs = '')
{
if($this->post->bugs == false) return $bugs;
$bugs = implode(',', $this->post->bugs) . ',' . trim($bugs, ',');
$this->dao->update(TABLE_BUG)->set('linkBug')->eq(trim($bugs, ','))->where('id')->eq($bugID)->exec();
if(dao::isError()) die(js::error(dao::getError()));
$this->loadModel('action')->create('bug', $bugID, 'linked2Bug', '', implode(',', $this->post->bugs));
return $bugs;
}
/**
* Delete a linked bug.
*
* @param int $bugID
* @param int $deleteBug
* @access public
* @return array
*/
public function deleteLinkedBug($bugID, $deleteBug = 0)
{
$bug = $this->getById($bugID);
$bugs = explode(',', trim($bug->linkBug, ','));
foreach($bugs as $key => $bugId)
{
if($bugId == $deleteBug) unset($bugs[$key]);
}
$bugs = implode(',', $bugs);
$this->dao->update(TABLE_BUG)->set('linkBug')->eq($bugs)->where('id')->eq($bugID)->exec();
if(dao::isError()) die(js::error(dao::getError()));
$this->loadModel('action')->create('bug', $bugID, 'unLinkedBug', '', $deleteBug);
return $this->getLinkedBugs($bugs);
}
/**
* Get linked bugs.
*
* @param string $bugs
* @access public
* @return array
*/
public function getLinkedBugs($bugs)
{
return $this->dao->select('id, title')->from(TABLE_BUG)->where('id')->in($bugs)->fetchPairs();
}
/**
* Build search form.
*

View File

@@ -230,9 +230,25 @@ js::set('oldResolvedBuild' , $bug->resolvedBuild);
<fieldset>
<legend><?php echo $lang->bug->legendMisc;?></legend>
<table class='table table-form'>
<tr>
<tr class='text-top'>
<th class='w-80px'><?php echo $lang->bug->linkBug;?></th>
<td><?php echo html::input('linkBug', $bug->linkBug, 'class="form-control"');?></td>
<td id='linkBugBox'>
<ul class='list-unstyled'>
<?php echo html::a($this->createLink('bug', 'linkBugs', "bugID=$bug->id&bugs=$bug->linkBug", '', true), $lang->bug->linkBugs, '', "class='iframe' data-width='85%'");?>
<?php
if(isset($bug->linkBugTitles))
{
foreach($bug->linkBugTitles as $linkBugID => $linkBugTitle)
{
echo '<li>';
echo html::a(inlink('view', "bugID=$linkBugID"), "#$linkBugID " . $linkBugTitle);
echo html::a("javascript:deleteLinkedBug($bug->id, $linkBugID)", '<i class="icon-remove"></i>', '', "title='{$lang->unlink}' style='float:right'");
echo '</li>';
}
}
?>
</ul>
</td>
</tr>
<?php if($bug->case):?>
<tr>

View File

@@ -279,10 +279,13 @@
</div>
<div class='tab-pane' id='legendMisc'>
<table class='table table-data table-condensed table-borderless table-fixed'>
<?php if($bug->case):?>
<tr>
<th class='w-60px'><?php echo $lang->bug->fromCase;?></th>
<td><?php if($bug->case) echo html::a($this->createLink('testcase', 'view', "caseID=$bug->case"), "#$bug->case $bug->caseTitle", '_blank');?></td>
<td><?php echo html::a($this->createLink('testcase', 'view', "caseID=$bug->case"), "#$bug->case $bug->caseTitle", '_blank');?></td>
</tr>
<?php endif;?>
<?php if($bug->toCases):?>
<tr>
<th><?php echo $lang->bug->toCase;?></th>
<td>
@@ -294,8 +297,9 @@
?>
</td>
</tr>
<tr>
<th><?php echo $lang->bug->linkBug;?></th>
<?php endif;?>
<tr class='text-top'>
<th class='w-60px'><?php echo $lang->bug->linkBug;?></th>
<td>
<?php
if(isset($bug->linkBugTitles))
@@ -308,14 +312,18 @@
?>
</td>
</tr>
<?php if($bug->toStory != 0):?>
<tr>
<th><?php echo $lang->bug->toStory;?></th>
<td><?php if($bug->toStory != 0) echo html::a($this->createLink('story', 'view', "storyID=$bug->toStory"), "#$bug->toStory $bug->toStoryTitle", '_blank');?></td>
<td><?php echo html::a($this->createLink('story', 'view', "storyID=$bug->toStory"), "#$bug->toStory $bug->toStoryTitle", '_blank');?></td>
</tr>
<?php endif;?>
<?php if($bug->toTask != 0):?>
<tr>
<th><?php echo $lang->bug->toTask;?></th>
<td><?php if($bug->toTask != 0) echo html::a($this->createLink('task', 'view', "taskID=$bug->toTask"), "#$bug->toTask $bug->toTaskTitle", '_blank');?></td>
<td><?php echo html::a($this->createLink('task', 'view', "taskID=$bug->toTask"), "#$bug->toTask $bug->toTaskTitle", '_blank');?></td>
</tr>
<?php endif;?>
</table>
</div>
</div>