* Bug batchactivate
This commit is contained in:
@@ -113,9 +113,16 @@ $config->bug->form->resolve['comment'] = array('required' => false, 'type
|
||||
$config->bug->form->resolve['uid'] = array('required' => false, 'type' => 'string', 'default' => '');
|
||||
|
||||
$config->bug->form->activate = array();
|
||||
$config->bug->form->activate['assignedTo'] = array('required' => false, 'type' => 'string', 'default' => '');
|
||||
$config->bug->form->activate['assignedTo'] = array('required' => false, 'type' => 'string', 'default' => '');
|
||||
$config->bug->form->activate['openedBuild'] = array('required' => false, 'type' => 'array', 'default' => array());
|
||||
|
||||
$config->bug->form->batchActivate = array();
|
||||
$config->bug->form->batchActivate['bugIdList'] = array('type' => 'array', 'required' => true);
|
||||
$config->bug->form->batchActivate['statusList'] = array('type' => 'array', 'required' => false, 'default' => array());
|
||||
$config->bug->form->batchActivate['assignedToList'] = array('type' => 'array', 'required' => false, 'default' => array());
|
||||
$config->bug->form->batchActivate['openedBuildList'] = array('type' => 'array', 'required' => false, 'default' => array());
|
||||
$config->bug->form->batchActivate['commentList'] = array('type' => 'array', 'required' => false, 'default' => array());
|
||||
|
||||
$config->bug->form->batchCreate = array();
|
||||
$config->bug->form->batchCreate['modules'] = array('required' => false, 'type' => array(), 'default' => array());
|
||||
$config->bug->form->batchCreate['projects'] = array('required' => false, 'type' => array(), 'default' => array());
|
||||
|
||||
+19
-14
@@ -1125,35 +1125,40 @@ class bug extends control
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量激活bug。
|
||||
* Batch activate bugs.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @access public
|
||||
* @return void
|
||||
* @return viod
|
||||
*/
|
||||
public function batchActivate($productID, $branch = 0)
|
||||
public function batchActivate(int $productID, string $branch = '0')
|
||||
{
|
||||
if($this->post->statusList)
|
||||
{
|
||||
$activateBugs = $this->bug->batchActivate();
|
||||
foreach($activateBugs as $bugID => $bug) $this->action->create('bug', $bugID, 'Activated', $bug['comment']);
|
||||
/* Get acitvate form data and extend data. */
|
||||
$activateData = form::data($this->config->bug->form->batchActivate)->get();
|
||||
$postExtendData = array();
|
||||
$extendFields = $this->bug->getFlowExtendFields();
|
||||
foreach($extendFields as $extendField) $postExtendData[$extendField->field] = $this->post->{$extendField->field};
|
||||
|
||||
$activateBugs = $this->bug->batchActivate($activateData, $postExtendData);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$this->loadModel('score')->create('ajax', 'batchOther');
|
||||
return print(js::locate($this->session->bugList, 'parent'));
|
||||
}
|
||||
|
||||
if(!$this->post->bugIDList) return print(js::locate($this->session->bugList, 'parent'));
|
||||
|
||||
$bugIDList = array_unique($this->post->bugIDList);
|
||||
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where('id')->in($bugIDList)->fetchAll('id');
|
||||
$bugIdList = array_unique($this->post->bugIDList);
|
||||
|
||||
$this->qa->setMenu($this->products, $productID, $branch);
|
||||
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->batchActivate;
|
||||
$this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]);
|
||||
$this->view->position[] = $this->lang->bug->batchActivate;
|
||||
|
||||
$this->view->bugs = $bugs;
|
||||
$this->view->users = $this->user->getPairs();
|
||||
$this->view->builds = $this->loadModel('build')->getBuildPairs($productID, $branch, 'noempty,noreleased');
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->batchActivate;
|
||||
$this->view->bugs = $this->bug->getByIdList($bugIdList);
|
||||
$this->view->users = $this->user->getPairs();
|
||||
$this->view->builds = $this->loadModel('build')->getBuildPairs($productID, $branch, 'noempty,noreleased');
|
||||
|
||||
$this->display();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
table.form-batch-table tr td:first-child, table.form-batch-table tr th:first-child {display: none;}
|
||||
table.form-batch-table tr td:nth-child(2), table.form-batch-table tr th:nth-child(2) {display: none;}
|
||||
+21
-21
@@ -724,29 +724,28 @@ class bugModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量激活bug。
|
||||
* Batch active bugs.
|
||||
*
|
||||
* @param object $activateData
|
||||
* @param array $postExtendData
|
||||
* @access public
|
||||
* @return array
|
||||
* @return array|false
|
||||
*/
|
||||
public function batchActivate()
|
||||
public function batchActivate(object $activateData, array $postExtendData): array|false
|
||||
{
|
||||
$now = helper::now();
|
||||
$data = fixer::input('post')->get();
|
||||
|
||||
$activateBugs = array();
|
||||
$bugIDList = $data->bugIDList ? $data->bugIDList : array();
|
||||
$bugIdList = $activateData->bugIdList ? $activateData->bugIdList : array();
|
||||
if(empty($bugIdList)) return $activateBugs;
|
||||
|
||||
if(empty($bugIDList)) return $activateBugs;
|
||||
|
||||
$extendFields = $this->getFlowExtendFields();
|
||||
foreach($bugIDList as $bugID)
|
||||
$now = helper::now();
|
||||
foreach($bugIdList as $bugID)
|
||||
{
|
||||
if($data->statusList[$bugID] == 'active') continue;
|
||||
if($activateData->statusList[$bugID] == 'active') continue;
|
||||
|
||||
$activateBugs[$bugID]['assignedTo'] = $data->assignedToList[$bugID];
|
||||
$activateBugs[$bugID]['openedBuild'] = $data->openedBuildList[$bugID];
|
||||
$activateBugs[$bugID]['comment'] = $data->commentList[$bugID];
|
||||
$activateBugs[$bugID]['assignedTo'] = $activateData->assignedToList[$bugID];
|
||||
$activateBugs[$bugID]['openedBuild'] = $activateData->openedBuildList[$bugID];
|
||||
$activateBugs[$bugID]['comment'] = $activateData->commentList[$bugID];
|
||||
|
||||
$activateBugs[$bugID]['activatedDate'] = $now;
|
||||
$activateBugs[$bugID]['assignedDate'] = $now;
|
||||
@@ -763,13 +762,10 @@ class bugModel extends model
|
||||
$activateBugs[$bugID]['lastEditedBy'] = $this->app->user->account;
|
||||
$activateBugs[$bugID]['lastEditedDate'] = $now;
|
||||
|
||||
foreach($extendFields as $extendField)
|
||||
foreach($postExtendData as $field => $postFieldData)
|
||||
{
|
||||
$postFieldData = $this->post->{$extendField->field};
|
||||
|
||||
if(is_array($postFieldData[$bugID])) $postFieldData[$bugID] = implode(',', $postFieldData[$bugID]);
|
||||
|
||||
$activateBugs[$bugID][$extendField->field] = htmlSpecialString($postFieldData[$bugID]);
|
||||
$activateBugs[$bugID][$field] = htmlSpecialString($postFieldData[$bugID]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -777,10 +773,14 @@ class bugModel extends model
|
||||
foreach($activateBugs as $bugID => $bug)
|
||||
{
|
||||
$this->dao->update(TABLE_BUG)->data($bug, $skipFields = 'comment')->autoCheck()->where('id')->eq((int)$bugID)->exec();
|
||||
if(dao::isError()) return print(js::error('bug#' . $bugID . dao::getError(true)));
|
||||
if(dao::isError())
|
||||
{
|
||||
dao::$errors['message'][] = 'bug#' . $bugID . dao::getError(true);
|
||||
return false;
|
||||
}
|
||||
$this->loadModel('action')->create('bug', $bugID, 'Activated', $bug['comment']);
|
||||
|
||||
$this->dao->update(TABLE_BUG)->set('activatedCount = activatedCount + 1')->where('id')->eq((int)$bugID)->exec();
|
||||
|
||||
$this->executeHooks($bugID);
|
||||
}
|
||||
|
||||
|
||||
@@ -880,14 +880,15 @@ class bugTest
|
||||
* Test batch activate bugs.
|
||||
*
|
||||
* @param array $bugIDList
|
||||
* @param array $buildList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function batchActivateObject($bugIDList)
|
||||
public function batchActivateObject(array $bugIDList, array $buildList = array())
|
||||
{
|
||||
$statusList = array('1' => 'active', '53' => 'resolved', '82' => 'closed');
|
||||
$assignedToList = array('1' => 'admin', '53' => 'admin', '82' => 'admin');
|
||||
$openedBuildList = array('1' => 'trunk', '53' => 'trunk', '82' => 'trunk');
|
||||
$openedBuildList = $buildList ? $buildList : array('1' => 'trunk', '53' => 'trunk', '82' => 'trunk');
|
||||
$commentList = array('1' => '', '53' => '', '82' => '');
|
||||
|
||||
$batchActivateFields['bugIDList'] = $bugIDList;
|
||||
@@ -896,10 +897,7 @@ class bugTest
|
||||
$batchActivateFields['openedBuildList'] = $openedBuildList;
|
||||
$batchActivateFields['commentList'] = $commentList;
|
||||
|
||||
foreach($batchActivateFields as $field => $value) $_POST[$field] = $value;
|
||||
|
||||
$object = $this->objectModel->batchActivate();
|
||||
unset($_POST);
|
||||
$object = $this->objectModel->batchActivate((object)$batchActivateFields, array());
|
||||
|
||||
if(dao::isError())
|
||||
{
|
||||
|
||||
@@ -2,19 +2,35 @@
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . "/test/lib/init.php";
|
||||
include dirname(__FILE__, 2) . '/bug.class.php';
|
||||
su('admin');
|
||||
su('user1');
|
||||
|
||||
/**
|
||||
|
||||
title=测试bugModel->batchActivate();
|
||||
timeout=0
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试批量激活bug >> active;active
|
||||
- 测试激活bug一个第53条的status属性 @active
|
||||
|
||||
- 测试批量激活bug第82条的status属性 @active
|
||||
|
||||
- 测试激活bug一个,修改版本第53条的openedBuild属性 @11
|
||||
|
||||
- 测试批量激活bug,修改版本第82条的openedBuild属性 @11
|
||||
|
||||
*/
|
||||
|
||||
$bugIDList = array('1' => '1', '52' => '53', '82' => '82');
|
||||
$bug = zdTable('bug');
|
||||
$bug->product->range('1');
|
||||
$bug->gen(100);
|
||||
|
||||
zdTable('build')->gen(100);
|
||||
|
||||
$bugIDList = array('1' => '1', '53' => '53', '82' => '82');
|
||||
$buildList = array('53' => 11, '82' => 11);
|
||||
|
||||
$bug = new bugTest();
|
||||
r($bug->batchActivateObject($bugIDList)) && p('53:status;82:status') && e('active;active'); // 测试批量激活bug
|
||||
r($bug->batchActivateObject(array('53' => '53'))) && p('53:status') && e('active'); // 测试激活bug一个
|
||||
r($bug->batchActivateObject($bugIDList)) && p('82:status') && e('active'); // 测试批量激活bug
|
||||
r($bug->batchActivateObject(array('53' => '53'), array('53' => 11))) && p('53:openedBuild') && e('11'); // 测试激活bug一个,修改版本
|
||||
r($bug->batchActivateObject($bugIDList, $buildList)) && p('82:openedBuild') && e('11'); // 测试批量激活bug,修改版本
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* The batchactivate view file of bug module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @author zenggang <zenggang@easycorp.ltd>
|
||||
* @package bug
|
||||
* @link https://www.zentao.net
|
||||
*/
|
||||
namespace zin;
|
||||
|
||||
$bugData = array();
|
||||
foreach($bugs as $bug)
|
||||
{
|
||||
$bugData[] = array('bugIdList' => $bug->id, 'id' => $bug->id, 'title' => $bug->title, 'statusList' => $bug->status, 'assignedToList' => $bug->resolvedBy, 'openedBuildList' => $bug->openedBuild);
|
||||
}
|
||||
|
||||
$items = array();
|
||||
$items[] = array('name' => 'statusList', 'label' => '');
|
||||
$items[] = array('name' => 'bugIdList', 'label' => '');
|
||||
$items[] = array('name' => 'id', 'label' => $lang->idAB, 'control' => 'index', 'width' => '40px');
|
||||
$items[] = array('name' => 'title', 'label' => $lang->bug->title, 'control' => 'static', 'width' => '120px');
|
||||
$items[] = array('name' => 'assignedToList', 'label' => $lang->bug->assignedTo, 'control' => 'select', 'width' => '160px', 'items' => $users);
|
||||
$items[] = array('name' => 'openedBuildList', 'label' => $lang->bug->openedBuild, 'control' => 'select', 'multiple' => true, 'width' => '200px', 'items' => $builds);
|
||||
$items[] = array('name' => 'commentList', 'label' => $lang->bug->legendComment, 'control' => 'editor', 'width' => '1/3');
|
||||
|
||||
$extendFields = $this->bug->getFlowExtendFields();
|
||||
foreach($extendFields as $extendField)
|
||||
{
|
||||
$items[] = array('name' => $extendField->field, 'label' => $extendField->name, 'required' => strpos(",$extendField->rules,", ',1,') !== false);
|
||||
}
|
||||
|
||||
formBatchPanel
|
||||
(
|
||||
set::title($lang->bug->common . $lang->colon . $lang->bug->batchActivate),
|
||||
set::mode('edit'),
|
||||
set::items($items),
|
||||
set::data($bugData),
|
||||
);
|
||||
|
||||
render();
|
||||
|
||||
Reference in New Issue
Block a user