* Rewrite story review. Code for task #102975.

This commit is contained in:
wangyidong
2023-09-27 17:13:40 +08:00
parent 1cf3a1a518
commit aa648fd594
6 changed files with 128 additions and 32 deletions
+5 -7
View File
@@ -78,7 +78,7 @@ class story extends control
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $message, 'id' => $storyID));
/* Get response when create in modal. */
$response = $this->storyZen->responseAfterCreateInModal($message);
$response = $this->storyZen->getResponseInModal($message);
if($response) return $this->send($response);
$response = array('result' => 'success', 'message' => $message);
@@ -156,7 +156,7 @@ class story extends control
}
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $stories));
if(isonlybody()) return $this->send($this->storyZen->responseAfterCreateInModal($this->lang->saveSuccess, $executionID));
if(isonlybody()) return $this->send($this->storyZen->getResponseInModal($this->lang->saveSuccess, $executionID));
$locateLink = $this->storyZen->getAfterBatchCreateLocation($productID, $branch, $executionID, $storyID, $storyType);
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $locateLink));
@@ -270,7 +270,7 @@ class story extends control
if(empty($message)) $message = $this->lang->saveSuccess;
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success', 'data' => $storyID));
$response = $this->storyZen->responseAfterCreateInModal($message);
$response = $this->storyZen->getResponseInModal($message);
if($response) return $this->send($response);
$params = $this->app->rawModule == 'story' ? "storyID=$storyID&version=0&param=0&storyType=$storyType" : "storyID=$storyID";
@@ -381,7 +381,7 @@ class story extends control
if(empty($message)) $message = $this->lang->saveSuccess;
if(defined('RUN_MODE') and RUN_MODE == 'api') return $this->send(array('status' => 'success', 'data' => $storyID));
$response = $this->storyZen->responseAfterCreateInModal($message);
$response = $this->storyZen->getResponseInModal($message);
if($response) return $this->send($response);
$location = $this->storyZen->getAfterChangeLocation($storyID, $storyType);
@@ -581,9 +581,7 @@ class story extends control
if(isonlybody())
{
if($this->app->tab == 'execution') $this->loadModel('kanban')->updateLane($this->session->execution, 'story', $storyID);
$response = $this->storyZen->responseAfterCreateInModal($message);
if($response) return $this->send($response);
return $this->send($this->storyZen->getResponseInModal($message));
}
if(defined('RUN_MODE') and RUN_MODE == 'api') return $this->send(array('status' => 'success', 'data' => $storyID));
+3 -1
View File
@@ -1053,13 +1053,15 @@ class storyModel extends model
{
$oldStory = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch();
$now = helper::now();
$account = $this->app->user->account;
if(!str_contains(",{$oldStory->reviewedBy},", ",{$account}")) $story->reviewedBy = $oldStory->reviewedBy . ',' . $account;
$this->dao->update(TABLE_STORYREVIEW)
->set('result')->eq($story->result)
->set('reviewDate')->eq($now)
->where('story')->in($storyID . ($oldStory->twins ? ",{$oldStory->twins}" : ''))
->andWhere('version')->eq($oldStory->version)
->andWhere('reviewer')->eq($this->app->user->account)
->andWhere('reviewer')->eq($account)
->exec();
$story = $this->updateStoryByReview($storyID, $oldStory, $story);
+58
View File
@@ -0,0 +1,58 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/story.class.php';
su('admin');
$story = zdTable('story');
$story->product->range(1);
$story->plan->range('0,1,0{100}');
$story->duplicateStory->range('0,4,0{100}');
$story->linkStories->range('0,6,0{100}');
$story->linkRequirements->range('3,0{100}');
$story->childStories->range('0,8,0{100}');
$story->toBug->range('0{9},1,0{100}');
$story->parent->range('0{17},`-1`,0,18,0{100}');
$story->twins->range('``{27},30,``,28');
$story->version->range('1');
$story->gen(30);
$storyReview = zdTable('storyreview');
$storyReview->story->range('1-30');
$storyReview->reviewer->range('admin');
$storyReview->version->range('1');
$storyReview->gen(20);
/**
title=测试 storyModel->recordReviewAction();
cid=1
pid=1
*/
$story = new storyTest();
$storyData = new stdclass();
$storyData->id = '1';
$storyData->result = 'pass';
$storyData->assignedTo = 'admin';
$storyData->closedReason = '';
$storyData->pri = '2';
r($story->recordReviewActionTest($storyData)) && p('action') && e('reviewed');
$storyData->finalResult = 'pass';
r($story->recordReviewActionTest($storyData)) && p('action') && e('reviewpassed');
$storyData->finalResult = 'reject';
r($story->recordReviewActionTest($storyData)) && p('action') && e('reviewrejected');
$storyData->finalResult = 'clarify';
r($story->recordReviewActionTest($storyData)) && p('action') && e('reviewclarified');
$storyData->finalResult = 'revert';
r($story->recordReviewActionTest($storyData)) && p('action') && e('reviewreverted');
$story->objectModel->app->user->account = 'admin';
$story->objectModel->app->rawModule = 'story';
$story->objectModel->app->rawMethod = 'review';
$story->objectModel->config->story->superReviewers = 'admin';
r($story->recordReviewActionTest($storyData)) && p('action') && e('reviewed');
+31 -12
View File
@@ -4,26 +4,45 @@ include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/story.class.php';
su('admin');
$story = zdTable('story');
$story->product->range(1);
$story->plan->range('0,1,0{100}');
$story->duplicateStory->range('0,4,0{100}');
$story->linkStories->range('0,6,0{100}');
$story->linkRequirements->range('3,0{100}');
$story->childStories->range('0,8,0{100}');
$story->toBug->range('0{9},1,0{100}');
$story->parent->range('0{17},`-1`,0,18,0{100}');
$story->twins->range('``{27},30,``,28');
$story->version->range('1');
$story->gen(30);
$storyReview = zdTable('storyreview');
$storyReview->story->range('1-30');
$storyReview->reviewer->range('admin');
$storyReview->version->range('1');
$storyReview->gen(20);
/**
title=测试 storyModel->review();
cid=1
pid=1
评审ID为2的需求,不传入评审意见,给出没有选择评审意见的提示 >> 必须选择评审意见
评审一个草稿的需求,传入评审意见为通过,状态变为激活 >> active
评审一个草稿的需求,传入评审意见为拒绝,状态变为关闭 >> closed
*/
$story = new storyTest();
$pass['result'] = 'pass';
$reject['result'] = 'reject';
$review1 = $story->reviewTest(2, array());
$review2 = $story->reviewTest(302, $pass);
$review3 = $story->reviewTest(304, $reject);
$storyData = new stdclass();
$storyData->result = 'pass';
$storyData->assignedTo = 'admin';
$storyData->closedReason = '';
$storyData->pri = '2';
r($story->reviewTest(1, $storyData)) && p('status') && e('active'); // 评审一个草稿的需求,传入评审意见为通过,状态变为激活
r($review1[0]) && p() && e('必须选择评审意见'); // 评审ID为2的需求,不传入评审意见,给出没有选择评审意见的提示
r($review2) && p('status') && e('active'); // 评审一个草稿的需求,传入评审意见为通过,状态变为激活
r($review3) && p('status') && e('closed'); // 评审一个草稿的需求,传入评审意见为拒绝,状态变为关闭
$storyData = new stdclass();
$storyData->result = 'reject';
$storyData->assignedTo = 'admin';
$storyData->closedReason = '';
$storyData->pri = '2';
r($story->reviewTest(5, $storyData)) && p('status') && e('closed'); // 评审一个草稿的需求,传入评审意见为通过,状态变为激活
+28 -9
View File
@@ -355,18 +355,13 @@ class storyTest
* Test review story.
*
* @param int $storyID
* @param array $params
* @param object $data
* @access public
* @return void
* @return object
*/
public function reviewTest($storyID, $params)
public function reviewTest($storyID, $data): object
{
$_POST = $params;
$changes = $this->objectModel->review($storyID);
unset($_POST);
if(dao::isError()) return dao::getError();
$this->objectModel->review($storyID, $data);
return $this->objectModel->getByID($storyID);
}
@@ -985,9 +980,33 @@ class storyTest
return $this->objectModel->dao->select('*')->from(TABLE_RELATION)->where('AType')->eq('requirement')->andWhere('BType')->eq('story')->andWhere('relation')->eq('subdivideinto')->andWhere('AID')->eq(3)->andWhere('BID')->eq($storyID)->fetch();
}
/**
* 测试 syncTwins 方法。
* Test syncTwins method
*
* @param int $storyID
* @param string $twins
* @param array $changes
* @access public
* @return array
*/
public function syncTwinsTest(int $storyID, string $twins, array $changes): array
{
$this->objectModel->syncTwins($storyID, $twins, $changes, 'changed');
return $this->objectModel->dao->select('*')->from(TABLE_STORY)->where('id')->in($twins)->orderBy('id')->fetchAll();
}
/**
* 测试 recordReviewAction 方法
* Test recordReviewAction method
*
* @param object $story
* @access public
* @return object
*/
public function recordReviewActionTest(object $story): object
{
$actionID = $this->objectModel->recordReviewAction($story);
return $this->objectModel->dao->select('*')->from(TABLE_ACTION)->where('id')->in($actionID)->fetch();
}
}
+3 -3
View File
@@ -1444,15 +1444,15 @@ class storyZen extends story
}
/**
* 如果是在弹窗中创建需求,获取创建后的跳转地址。
* Get response when after create story in modal.
* 如果是在弹窗中打开页面,获取跳转地址。
* Get response when open in modal.
*
* @param string $message
* @param int $executionID
* @access protected
* @return array|false
*/
protected function responseAfterCreateInModal(string $message, int $executionID = 0): array|false
protected function getResponseInModal(string $message, int $executionID = 0): array|false
{
if(!isonlybody()) return false;
if($this->app->tab != 'execution') return array('result' => 'success', 'message' => $message, 'load' => true, 'closeModal' => true);