Merge pull request '* Rebuild delete function of control.' (#49) from daitingting_rebuild_control_delete into master
Reviewed-on: https://git.zcorp.cc/easycorp/zentaopms/pulls/49
This commit is contained in:
+20
-39
@@ -1542,55 +1542,36 @@ class bug extends control
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 bug。
|
||||
* Delete a bug.
|
||||
*
|
||||
* @param int $bugID
|
||||
* @param string $confirm yes|no
|
||||
* @param string $bugID
|
||||
* @param string $confirm yes|no
|
||||
* @param string $from taskkanban
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function delete($bugID, $confirm = 'no', $from = '')
|
||||
public function delete(string $bugID, string $confirm = 'no', string $from = '')
|
||||
{
|
||||
$bug = $this->bug->getById($bugID);
|
||||
if($confirm == 'no')
|
||||
if($confirm == 'no') return $this->send(array('result' => 'success', 'load' => array('confirm' => $this->lang->bug->confirmDelete, 'confirmed' =>inlink('delete', "bugID=$bugID&confirm=yes&from=$from"))));
|
||||
|
||||
$bug = $this->bug->getByID($bugID);
|
||||
|
||||
$this->bug->delete(TABLE_BUG, $bugID);
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
/* 如果 bug 转任务,删除 bug 时确认是否更新任务状态。*/
|
||||
/* If the bug has been transfered to a task, confirm to update task when delete the bug. */
|
||||
if($bug->toTask)
|
||||
{
|
||||
return print(js::confirm($this->lang->bug->confirmDelete, inlink('delete', "bugID=$bugID&confirm=yes&from=$from")));
|
||||
$result = $this->bugZen->confirm2UpdateTask($bugID, $bug->toTask);
|
||||
if(is_array($result)) return $this->send($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->bug->delete(TABLE_BUG, $bugID);
|
||||
if($bug->toTask != 0)
|
||||
{
|
||||
$task = $this->task->getById($bug->toTask);
|
||||
if(!$task->deleted)
|
||||
{
|
||||
$confirmURL = $this->createLink('task', 'view', "taskID=$bug->toTask");
|
||||
unset($_GET['onlybody']);
|
||||
$cancelURL = $this->createLink('bug', 'view', "bugID=$bugID");
|
||||
return print(js::confirm(sprintf($this->lang->bug->remindTask, $bug->toTask), $confirmURL, $cancelURL, 'parent', 'parent.parent'));
|
||||
}
|
||||
}
|
||||
|
||||
$this->executeHooks($bugID);
|
||||
$this->executeHooks($bugID);
|
||||
|
||||
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess));
|
||||
|
||||
if(isonlybody()) return print(js::reload('parent.parent'));
|
||||
|
||||
if($from == 'taskkanban')
|
||||
{
|
||||
$laneType = $this->session->executionLaneType ? $this->session->executionLaneType : 'all';
|
||||
$groupBy = $this->session->executionGroupBy ? $this->session->executionGroupBy : 'default';
|
||||
$taskSearchValue = $this->session->taskSearchValue ? $this->session->taskSearchValue : '';
|
||||
$kanbanData = $this->loadModel('kanban')->getExecutionKanban($bug->execution, $laneType, $groupBy, $taskSearchValue);
|
||||
$kanbanType = $laneType == 'all' ? 'bug' : key($kanbanData);
|
||||
$kanbanData = json_encode($kanbanData[$kanbanType]);
|
||||
return print(js::closeModal('parent', '', "parent.updateKanban(\"bug\", $kanbanData)"));
|
||||
}
|
||||
|
||||
$locateLink = $this->session->bugList ? $this->session->bugList : inlink('browse', "productID={$bug->product}");
|
||||
return print(js::locate($locateLink, 'parent'));
|
||||
}
|
||||
return $this->send($this->bugZen->responseAfterDelete($bug, $from));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -967,6 +967,60 @@ class bugZen extends bug
|
||||
return $assignedToPairs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认是否更新 bug 状态。
|
||||
* Confirm to update task.
|
||||
*
|
||||
* @param int $bugID
|
||||
* @param int $taskID
|
||||
* @access protected
|
||||
* @return array|true
|
||||
*/
|
||||
protected function confirm2UpdateTask(int $bugID, int $taskID): array
|
||||
{
|
||||
$task = $this->task->getByID($taskID);
|
||||
if($task->deleted) return true;
|
||||
|
||||
$confirmURL = $this->createLink('task', 'view', "taskID=$bug->toTask");
|
||||
unset($_GET['onlybody']);
|
||||
$cancelURL = $this->createLink('bug', 'view', "bugID=$bugID");
|
||||
return array('result' => 'success', 'load' => array('confirm' => $this->lang->bug->remindTask, 'confirmed' => $confirmURL, 'canceled' => $cancelURL));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除 bug 后不同的返回结果。
|
||||
* respond after deleting.
|
||||
*
|
||||
* @param object $bug
|
||||
* @param string $from
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function responseAfterDelete(object $bug, string $from): array
|
||||
{
|
||||
if($this->viewType == 'json') return array('result' => 'success', 'message' => $this->lang->saveSuccess);
|
||||
|
||||
/* 在弹窗中删除 bug 时的返回。*/
|
||||
/* Respond when delete bug in modal.。*/
|
||||
if(isonlybody()) return array('result' => 'success', 'load' => true);
|
||||
|
||||
/* 在任务看板中删除 bug 时的返回。*/
|
||||
/* Respond when delete in task kanban. */
|
||||
if($from == 'taskkanban')
|
||||
{
|
||||
$laneType = $this->session->executionLaneType ?: 'all';
|
||||
$groupBy = $this->session->executionGroupBy ?: 'default';
|
||||
$searchValue = $this->session->taskSearchValue ?: '';
|
||||
$kanbanData = $this->loadModel('kanban')->getExecutionKanban($bug->execution, $laneType, $groupBy, $searchValue);
|
||||
$kanbanType = $laneType == 'all' ? 'bug' : key($kanbanData);
|
||||
$kanbanData = json_encode($kanbanData[$kanbanType]);
|
||||
|
||||
return array('result' => 'success', 'closeModal' => true, 'callback' => "updateKanban(\"bug\", $kanbanData)");
|
||||
}
|
||||
|
||||
return array('result' => 'success', 'load' => $this->session->bugList ?: inlink('browse', "productID={$bug->product}"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果不是弹窗,调用该方法为查看bug设置导航。
|
||||
* If it's not a iframe, call this method to set menu for view bug page.
|
||||
|
||||
Reference in New Issue
Block a user