* Optimize responseAfterOperate function.
This commit is contained in:
+10
-5
@@ -293,7 +293,8 @@ class bug extends control
|
||||
}
|
||||
|
||||
/* Get response after editing bug. */
|
||||
return $this->bugZen->responseAfterOperate($bugID, $changes, $kanbanGroup);
|
||||
$message = $this->executeHooks($bugID);
|
||||
return $this->bugZen->responseAfterOperate($bugID, $changes, $kanbanGroup, 0, $message);
|
||||
}
|
||||
|
||||
$this->bugZen->checkBugExecutionPriv($oldBug);
|
||||
@@ -385,8 +386,9 @@ class bug extends control
|
||||
$this->bug->confirm($bug, $kanbanData);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$message = $this->executeHooks($bugID);
|
||||
$regionID = zget($kanbanData, 'regionID', 0);
|
||||
return $this->bugZen->responseAfterOperate($bugID, array(), '', $regionID);
|
||||
return $this->bugZen->responseAfterOperate($bugID, array(), '', $regionID, $message);
|
||||
}
|
||||
|
||||
$this->qa->setMenu($this->products, $oldBug->product, $oldBug->branch);
|
||||
@@ -436,8 +438,9 @@ class bug extends control
|
||||
if($oldBug->status != 'closed') $this->bug->resolve($bug, $output);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$message = $this->executeHooks($bugID);
|
||||
$regionID = zget($output, 'regionID', 0);
|
||||
return $this->bugZen->responseAfterOperate($bugID, array(), '', $regionID);
|
||||
return $this->bugZen->responseAfterOperate($bugID, array(), '', $regionID, $message);
|
||||
}
|
||||
|
||||
/* Remove 'Convert to story' from the solution list. */
|
||||
@@ -488,8 +491,9 @@ class bug extends control
|
||||
$this->bug->activate($bug, $kanbanParams);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$message = $this->executeHooks($bugID);
|
||||
$regionID = zget($kanbanParams, 'regionID', 0);
|
||||
return $this->bugZen->responseAfterOperate($bugID, array(), '', $regionID);
|
||||
return $this->bugZen->responseAfterOperate($bugID, array(), '', $regionID, $message);
|
||||
}
|
||||
|
||||
$productID = $oldBug->product;
|
||||
@@ -528,8 +532,9 @@ class bug extends control
|
||||
$this->bug->close($bug, $output);
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
$message = $this->executeHooks($bugID);
|
||||
$regionID = zget($output, 'regionID', 0);
|
||||
return $this->bugZen->responseAfterOperate($bugID, array(), '', $regionID);
|
||||
return $this->bugZen->responseAfterOperate($bugID, array(), '', $regionID, $message);
|
||||
}
|
||||
|
||||
$this->view->bug = $oldBug;
|
||||
|
||||
+13
-11
@@ -1823,13 +1823,14 @@ class bugZen extends bug
|
||||
* @param array $changes
|
||||
* @param string $kanbanGroup
|
||||
* @param int $regionID
|
||||
* @param string $message
|
||||
* @access protected
|
||||
* @return array
|
||||
* @return bool
|
||||
*/
|
||||
protected function responseAfterOperate(int $bugID, array $changes = array(), string $kanbanGroup = '', int $regionID = 0): array
|
||||
protected function responseAfterOperate(int $bugID, array $changes = array(), string $kanbanGroup = '', int $regionID = 0, string $message = ''): bool
|
||||
{
|
||||
$message = $this->executeHooks($bugID);
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success', 'data' => $bugID));
|
||||
if(!$message) $message = $this->lang->saveSuccess;
|
||||
if(defined('RUN_MODE') && RUN_MODE == 'api') return $this->send(array('status' => 'success', 'message' => $message, 'data' => $bugID));
|
||||
|
||||
/* 如果 bug 转任务并且 bug 的状态发生变化,提示是否更新任务状态。*/
|
||||
/* This bug has been converted to a task, update the status of the related task or not. */
|
||||
@@ -1842,16 +1843,15 @@ class bugZen extends bug
|
||||
{
|
||||
$confirmedURL = $this->createLink('task', 'view', "taskID=$bug->toTask");
|
||||
$canceledURL = $this->server->http_referer;
|
||||
return $this->send(array('result' => 'success', 'load' => array('confirm' => $this->lang->bug->remindTask, 'confirmed' => $confirmedURL, 'canceled' => $canceledURL)));
|
||||
return $this->send(array('result' => 'success', 'message' => $message, 'load' => array('confirm' => $this->lang->bug->remindTask, 'confirmed' => $confirmedURL, 'canceled' => $canceledURL)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 在弹窗里编辑 bug 时的返回。*/
|
||||
/* Respond after updating in modal. */
|
||||
if(isonlybody()) return $this->responseInModal($bug->execution, $kanbanGroup, $regionID);
|
||||
if(isonlybody()) return $this->responseInModal($bug->execution, $kanbanGroup, $regionID, $message);
|
||||
|
||||
if(!$message) $message = $this->lang->saveSuccess;
|
||||
return $this->send(array('result' => 'success', 'message' => $message, 'closeModal' => true, 'load' => $this->createLink('bug', 'view', "bugID=$bugID")));
|
||||
}
|
||||
|
||||
@@ -1862,13 +1862,15 @@ class bugZen extends bug
|
||||
* @param int $executionID
|
||||
* @param string $kanbanGroup
|
||||
* @param int $regionID
|
||||
* @param string $message
|
||||
* @access protected
|
||||
* @return array
|
||||
* @return bool
|
||||
*/
|
||||
protected function responseInModal(int $executionID, string $kanbanGroup = '', int $regionID = 0): array
|
||||
protected function responseInModal(int $executionID, string $kanbanGroup = '', int $regionID = 0, string $message = ''): bool
|
||||
{
|
||||
/* 在执行应用下,编辑看板中的 bug 数据时,更新看板数据。*/
|
||||
/* Update kanban data after updating bug in kanban. */
|
||||
if(!$message) $message = $this->lang->saveSuccess;
|
||||
if($this->app->tab == 'execution')
|
||||
{
|
||||
$this->loadModel('kanban');
|
||||
@@ -1885,7 +1887,7 @@ class bugZen extends bug
|
||||
$rdSearchValue = $this->session->rdSearchValue ? $this->session->rdSearchValue : '';
|
||||
$kanbanData = $this->kanban->getRDKanban($executionID, $laneType, 'id_desc', $regionID, $groupBy, $rdSearchValue);
|
||||
$kanbanData = json_encode($kanbanData);
|
||||
return $this->send(array('result' => 'success', 'closeModal' => true, 'callback' => "updateKanban($kanbanData)"));
|
||||
return $this->send(array('result' => 'success', 'message' => $message, 'closeModal' => true, 'callback' => "updateKanban($kanbanData)"));
|
||||
}
|
||||
|
||||
/* 执行中的看板。*/
|
||||
@@ -1897,7 +1899,7 @@ class bugZen extends bug
|
||||
return $this->send(array('result' => 'success', 'closeModal' => true, 'callback' => "updateKanban(\"bug\", $kanbanData)"));
|
||||
}
|
||||
|
||||
return $this->send(array('result' => 'success', 'closeModal' => true, 'load' => true));
|
||||
return $this->send(array('result' => 'success', 'message' => $message, 'closeModal' => true, 'load' => true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user