* testtask: refactor the activate method.

This commit is contained in:
liugang
2023-09-12 10:11:35 +08:00
parent 220dde930a
commit 82226a51c5
+11 -16
View File
@@ -788,8 +788,8 @@ class testtask extends control
$this->loadModel('qa')->setMenu($this->products, $productID, $testtask->branch, $taskID);
$this->view->title = $testtask->name . $this->lang->colon . $this->lang->testtask->start;
$this->view->users = $this->loadModel('user')->getPairs('nodeleted', $testtask->owner);
$this->view->actions = $this->loadModel('action')->getList('testtask', $taskID);
$this->view->users = $this->loadModel('user')->getPairs('nodeleted', $testtask->owner);
$this->view->testtask = $testtask;
$this->display();
}
@@ -801,23 +801,18 @@ class testtask extends control
* @access public
* @return void
*/
public function activate($taskID)
public function activate(int $taskID)
{
if(!empty($_POST))
{
$changes = $this->testtask->activate($taskID);
$task = $this->testtaskZen->buildTaskForActivate($taskID);
$this->testtask->activate($task);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
if($this->post->comment != '' or !empty($changes))
{
$actionID = $this->loadModel('action')->create('testtask', $taskID, 'Activated', $this->post->comment);
$this->action->logHistory($actionID, $changes);
}
$message = $this->executeHooks($taskID) ?: $this->lang->saveSuccess;
$message = $this->executeHooks($taskID);
if($message) $this->lang->saveSuccess = $message;
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true, 'closeModal' => true));
return $this->send(array('result' => 'success', 'message' => $message, 'closeModal' => true, 'load' => true));
}
/* Get task info. */
@@ -827,10 +822,10 @@ class testtask extends control
/* Set menu. */
$this->loadModel('qa')->setMenu($this->products, $productID, $testtask->branch, $taskID);
$this->view->testtask = $testtask;
$this->view->title = $testtask->name . $this->lang->colon . $this->lang->testtask->start;
$this->view->users = $this->loadModel('user')->getPairs('nodeleted', $testtask->owner);
$this->view->actions = $this->loadModel('action')->getList('testtask', $taskID);
$this->view->title = $testtask->name . $this->lang->colon . $this->lang->testtask->activate;
$this->view->actions = $this->loadModel('action')->getList('testtask', $taskID);
$this->view->users = $this->loadModel('user')->getPairs('nodeleted', $testtask->owner);
$this->view->testtask = $testtask;
$this->display();
}