* Fix error message can not pop up the problem.

This commit is contained in:
tianshujie
2023-11-06 14:29:28 +08:00
parent e732eda34c
commit 86c02ca46e
3 changed files with 23 additions and 5 deletions
+2
View File
@@ -340,6 +340,8 @@ class execution extends control
{
$postData = form::batchData($this->config->execution->form->importBug)->get();
$tasks = $this->executionZen->buildTasksForImportBug($execution, $postData);
if(dao::isError()) return $this->sendError(dao::getError());
$this->execution->importBug($tasks);
if(dao::isError()) return $this->sendError(dao::getError());
+19 -1
View File
@@ -7,6 +7,24 @@ $(document).off('click', '.import-bug-btn').on('click', '.import-bug-btn', funct
const formData = new FormData($("#importForm")[0]);
checkedList.forEach((id) => formData.append(`id[${id}]`, id));
$.ajaxSubmit({url: $('#importForm').attr('action'), data: formData});
$.ajaxSubmit({url: $('#importForm').attr('action'), data: formData, onFail: printError});
return false;
});
/**
* Print error message.
*
* @param error $error
* @access public
* @return void
*/
function printError(result)
{
Object.entries(result.message).forEach(([name, msg]) => {
if (Array.isArray(msg)) {
msg = msg.join('');
}
zui.Modal.alert(msg);
})
}
+2 -4
View File
@@ -708,8 +708,6 @@ class executionZen extends execution
$task->openedBy = $this->app->user->account;
if($task->estimate !== '') $task->left = $task->estimate;
if(strpos($requiredFields, 'estStarted') !== false && helper::isZeroDate($task->estStarted)) $task->estStarted = '';
if(strpos($requiredFields, 'deadline') !== false && helper::isZeroDate($task->deadline)) $task->deadline = '';
if(!empty($task->assignedTo)) $task->assignedDate = $now;
/* Check task required fields. */
@@ -721,13 +719,13 @@ class executionZen extends execution
if($field == 'estimate' and strlen(trim($task->estimate)) != 0) continue;
dao::$errors['message'][] = sprintf($this->lang->error->notempty, $this->lang->task->$field);
dao::$errors["{$field}[{$bugID}]"] = 'ID: ' . $bugID . sprintf($this->lang->error->notempty, $this->lang->task->$field);
return false;
}
if(!preg_match("/^[0-9]+(.[0-9]{1,3})?$/", (string)$task->estimate) and !empty($task->estimate))
{
dao::$errors['message'][] = $this->lang->task->error->estimateNumber;
dao::$errors["{$field}[{$bugID}]"] = 'ID: ' . $bugID . $this->lang->task->error->estimateNumber;
return false;
}