Merge branch 'jihu'

This commit is contained in:
Guan Xiying
2021-07-14 09:48:58 +08:00
84 changed files with 3798 additions and 225 deletions
+1
View File
@@ -26,6 +26,7 @@ $config->task->editor->activate = array('id' => 'comment', 'tools' => 'simpleToo
$config->task->editor->cancel = array('id' => 'comment', 'tools' => 'simpleTools');
$config->task->editor->pause = array('id' => 'comment', 'tools' => 'simpleTools');
$config->task->removeFields = 'objectTypeList,productList,executionList,gitlabID,gitlabProjectID,product';
$config->task->exportFields = '
id, execution, module, story,
name, desc,
+50 -21
View File
@@ -92,12 +92,14 @@ class task extends control
setcookie('lastTaskModule', (int)$this->post->module, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, false);
if($this->post->execution) $executionID = (int)$this->post->execution;
/* Create task here. */
$tasksID = $this->task->create($executionID);
if(dao::isError())
{
$response['result'] = 'fail';
$response['message'] = dao::getError();
$this->send($response);
return $this->send($response);
}
/* if the count of tasksID is 1 then check exists. */
@@ -108,7 +110,7 @@ class task extends control
{
$response['locate'] = $this->createLink('task', 'view', "taskID={$taskID['id']}");
$response['message'] = sprintf($this->lang->duplicate, $this->lang->task->common);
$this->send($response);
return $this->send($response);
}
}
@@ -132,41 +134,41 @@ class task extends control
$this->executeHooks($taskID);
/* Return task id when call the API. */
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $taskID));
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $taskID));
/* If link from no head then reload. */
if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
if(isonlybody()) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
/* Locate the browser. */
if($this->app->getViewType() == 'xhtml')
{
$taskLink = $this->createLink('task', 'view', "taskID=$taskID");
$response['locate'] = $taskLink;
$this->send($response);
return $this->send($response);
}
if($this->post->after == 'continueAdding')
{
$response['message'] = $this->lang->task->successSaved . $this->lang->task->afterChoices['continueAdding'];
$response['locate'] = $this->createLink('task', 'create', "executionID=$executionID&storyID={$this->post->story}&moduleID=$moduleID");
$this->send($response);
return $this->send($response);
}
elseif($this->post->after == 'toTaskList')
{
setcookie('moduleBrowseParam', 0, 0, $this->config->webRoot, '', $this->config->cookieSecure, false);
$taskLink = $this->createLink('execution', 'task', "executionID=$executionID&status=unclosed&param=0&orderBy=id_desc");
$response['locate'] = $taskLink;
$this->send($response);
return $this->send($response);
}
elseif($this->post->after == 'toStoryList')
{
$response['locate'] = $storyLink;
$this->send($response);
return $this->send($response);
}
else
{
$response['locate'] = $taskLink;
$this->send($response);
return $this->send($response);
}
}
@@ -215,6 +217,12 @@ class task extends control
foreach(explode(',', $this->config->task->customCreateFields) as $field) $customFields[$field] = $this->lang->task->$field;
if($execution->type == 'ops') unset($customFields['story']);
$allGitlabs = $this->loadModel('gitlab')->getPairs();
$gitlabProjects = $this->loadModel('gitlab')->getProjectsByExecution($executionID);
foreach($allGitlabs as $id => $name) if($id and !isset($gitlabProjects[$id])) unset($allGitlabs[$id]);
$this->view->gitlabList = $allGitlabs;
$this->view->gitlabProjects = $gitlabProjects;
$this->view->customFields = $customFields;
$this->view->showFields = $this->config->task->custom->createFields;
$this->view->showAllModule = $showAllModule;
@@ -230,6 +238,7 @@ class task extends control
$this->view->members = $members;
$this->view->blockID = $blockID;
$this->view->moduleOptionMenu = $moduleOptionMenu;
$this->display();
}
@@ -285,17 +294,17 @@ class task extends control
if(!empty($_POST))
{
$mails = $this->task->batchCreate($executionID);
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$taskIDList = array();
foreach($mails as $mail) $taskIDList[] = $mail->taskID;
/* Return task id list when call the API. */
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $taskIDList));
if($this->viewType == 'json') return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'idList' => $taskIDList));
/* Locate the browser. */
if(!empty($iframe)) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $taskLink));
if(!empty($iframe)) return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => 'parent'));
return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $taskLink));
}
/* Set Custom*/
@@ -372,7 +381,7 @@ class task extends control
if($comment == false)
{
$changes = $this->task->update($taskID);
if(dao::isError()) die(js::error(dao::getError()));
if(dao::isError()) return print(js::error(dao::getError()));
$files = $this->loadModel('file')->saveUpload('task', $taskID);
}
@@ -399,9 +408,10 @@ class task extends control
}
}
}
if(defined('RUN_MODE') && RUN_MODE == 'api')
{
die(array('status' => 'success', 'data' => $taskID));
return $this->send(array('status' => 'success', 'data' => $taskID));
}
else
{
@@ -552,7 +562,10 @@ class task extends control
{
$this->loadModel('action');
$changes = $this->task->assign($taskID);
if($this->viewType == 'json') return $this->send(array('result' => 'fail', 'message' => dao::getError()));
if(dao::isError()) die(js::error(dao::getError()));
$actionID = $this->action->create('task', $taskID, 'Assigned', $this->post->comment, $this->post->assignedTo);
$this->action->logHistory($actionID, $changes);
@@ -564,6 +577,9 @@ class task extends control
$task = $this->task->getByID($taskID);
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
$this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
$members = $this->loadModel('user')->getTeamMemberPairs($executionID, 'execution', 'nodeleted');
/* Compute next assignedTo. */
@@ -743,7 +759,12 @@ class task extends control
{
$this->loadModel('action');
$changes = $this->task->start($taskID);
if(dao::isError()) die(js::error(dao::getError()));
if(dao::isError())
{
if($this->viewType == 'json') return $this->send(array('result' => 'fail', 'message' => dao::getError()));
die(js::error(dao::getError()));
}
if($this->post->comment != '' or !empty($changes))
{
@@ -898,7 +919,11 @@ class task extends control
{
$this->loadModel('action');
$changes = $this->task->finish($taskID);
if(dao::isError()) die(js::error(dao::getError()));
if(dao::isError())
{
if($this->viewType == 'json') return $this->send(array('result' => 'fail', 'message' => dao::getError()));
die(js::error(dao::getError()));
}
$files = $this->loadModel('file')->saveUpload('task', $taskID);
$task = $this->task->getById($taskID);
@@ -927,7 +952,7 @@ class task extends control
if(isonlybody()) die(js::closeModal('parent.parent', 'this'));
if(defined('RUN_MODE') && RUN_MODE == 'api')
{
die(array('status' => 'success', 'data' => $taskID));
return $this->send(array('result' => 'success', 'data' => $taskID));
}
else
{
@@ -1264,14 +1289,18 @@ class task extends control
public function delete($executionID, $taskID, $confirm = 'no')
{
$task = $this->task->getById($taskID);
if($task->parent < 0) die(js::alert($this->lang->task->cannotDeleteParent));
if($task->parent < 0) return print(js::alert($this->lang->task->cannotDeleteParent));
if($confirm == 'no')
{
die(js::confirm($this->lang->task->confirmDelete, inlink('delete', "executionID=$executionID&taskID=$taskID&confirm=yes")));
return print(js::confirm($this->lang->task->confirmDelete, inlink('delete', "executionID=$executionID&taskID=$taskID&confirm=yes")));
}
else
{
/* Delete related issue in gitlab. */
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->loadModel('gitlab')->deleteIssue('task', $taskID, $relation->issueID);
$this->task->delete(TABLE_TASK, $taskID);
if($task->parent > 0)
{
@@ -1283,7 +1312,7 @@ class task extends control
$this->executeHooks($taskID);
die(js::locate($this->session->taskList, 'parent'));
return print(js::locate($this->session->taskList, 'parent'));
}
}
+17
View File
@@ -479,6 +479,23 @@ $(document).ready(function()
$('#moduleIdBox #module').val(moduleID).attr('onchange', "setStories(this.value, " + executionID + ")").chosen();
});
});
$('#gitlab').change(function()
{
host = $('#gitlab').val();
if(host == '') return false;
projects = '';
$.each(gitlabProjects[host], function(id, obj){projects = projects + ',' + obj.gitlabProject});
url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host + "&projects=" + projects);
$.get(url, function(response)
{
$('#gitlabProject').html('').append(response);
$('#gitlabProject').chosen().trigger("chosen:updated");;
});
});
});
$(document).on('click', '#testStory_chosen,#story_chosen', function()
+1
View File
@@ -67,6 +67,7 @@ $lang->task->storyVersion = "{$lang->SRCommon}版本";
$lang->task->color = '标题颜色';
$lang->task->name = '任务名称';
$lang->task->type = '任务类型';
$lang->task->sync2Gitlab = '同步到Gitlab';
$lang->task->pri = '优先级';
$lang->task->mailto = '抄送给';
$lang->task->estimate = '最初预计';
+90 -3
View File
@@ -22,6 +22,7 @@ class taskModel extends model
*/
public function create($executionID)
{
if($this->post->estimate < 0)
{
dao::$errors[] = $this->lang->task->error->recordMinus;
@@ -64,7 +65,7 @@ class taskModel extends model
->cleanINT('execution,story,module')
->stripTags($this->config->task->editor->create['id'], $this->config->allowedTags)
->join('mailto', ',')
->remove('after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate')
->remove('after,files,labels,assignedTo,uid,storyEstimate,storyDesc,storyPri,team,teamEstimate,teamMember,multiple,teams,contactListMenu,selectTestStory,testStory,testPri,testEstStarted,testDeadline,testAssignedTo,testEstimate,sync')
->add('version', 1)
->get();
@@ -109,17 +110,21 @@ class taskModel extends model
/* Fix Bug #2466 */
if($this->post->multiple) $task->assignedTo = '';
$this->dao->insert(TABLE_TASK)->data($task)
$this->dao->insert(TABLE_TASK)->data($task, $skip = 'gitlab,gitlabProject')
->autoCheck()
->batchCheck($requiredFields, 'notempty')
->checkIF($task->estimate != '', 'estimate', 'float')
->checkIF(!helper::isZeroDate($task->deadline), 'deadline', 'ge', $task->estStarted)
->exec();
if(dao::isError()) return false;
$taskID = $this->dao->lastInsertID();
/* Sync this task to gitlab issue. */
$object = $this->getByID($taskID);
$this->loadModel('gitlab')->apiCreateIssue($this->post->gitlab, $this->post->gitlabProject, 'task', $taskID, $object);
/* Mark design version.*/
if(isset($task->design) && !empty($task->design))
{
@@ -379,6 +384,11 @@ class taskModel extends model
if(dao::isError()) return false;
$taskID = $this->dao->lastInsertID();
/* Sync this task to gitlab issue. */
$object = $this->getByID($taskID);
$this->loadModel('gitlab')->apiCreateIssue($this->post->gitlab, $this->post->gitlabProject,'task', $taskID, $object);
$taskSpec = new stdClass();
$taskSpec->task = $taskID;
$taskSpec->version = $task->version;
@@ -447,6 +457,37 @@ class taskModel extends model
return $mails;
}
/**
* Create task from gitlab issue.
*
* @param object $task
* @param int $executionID
* @access public
* @return int
*/
public function createTaskFromGitlabIssue($task, $executionID)
{
$task->version = 1;
$task->openedBy = $this->app->user->account;
$task->assignedDate = isset($task->assignedTo) ? helper::now() : 0;
$task->story = 0;
$task->module = 0;
$task->estimate = 0;
$task->estStarted = '0000-00-00';
$task->left = 1;
$task->type = 'devel';
$this->dao->insert(TABLE_TASK)->data($task, $skip = 'id,product')
->autoCheck()
->batchCheck($this->config->task->create->requiredFields, 'notempty')
->checkIF(!helper::isZeroDate($task->deadline), 'deadline', 'ge', $task->estStarted)
->exec();
if(dao::isError()) return false;
return $this->dao->lastInsertID();
}
/**
* Compute parent task working hours.
*
@@ -940,6 +981,10 @@ class taskModel extends model
->batchCheckIF($task->closedReason == 'cancel', 'finishedBy, finishedDate', 'empty')
->where('id')->eq((int)$taskID)->exec();
/* update task to gitlab issue. */
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
if(!dao::isError())
{
/* Mark design version.*/
@@ -1173,6 +1218,14 @@ class taskModel extends model
$tasks[$taskID] = $task;
}
$issues = $this->loadModel('gitlab')->getIssueListByObjects('task', $taskID);
foreach($tasks as $taskID => $task)
{
$issue = zget($issues, $taskID, 0);
if(!$issue) continue;
$this->loadModel('gitlab')->apiUpdateIssue($issue->gitlabID, $issue->projectID, $issue->issueID, $task);
}
/* Check field not empty. */
foreach($tasks as $taskID => $task)
{
@@ -1242,6 +1295,10 @@ class taskModel extends model
if($task->status == 'done') $this->loadModel('score')->create('task', 'finish', $taskID);
if($task->status == 'closed') $this->loadModel('score')->create('task', 'close', $taskID);
$allChanges[$taskID] = common::createChanges($oldTask, $task);
/* update task to gitlab issue. */
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
}
else
{
@@ -1327,6 +1384,10 @@ class taskModel extends model
->autoCheck()
->check('left', 'float')
->where('id')->eq($taskID)->exec();
$task = $this->getById($taskID);
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
if(!dao::isError()) return common::createChanges($oldTask, $task);
}
@@ -1663,6 +1724,13 @@ class taskModel extends model
->where('id')->eq((int)$taskID)
->exec();
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation))
{
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
}
if($oldTask->parent > 0) $this->updateParentStatus($taskID);
if($oldTask->story) $this->loadModel('story')->setStage($oldTask->story);
if($task->status == 'done' && !dao::isError()) $this->loadModel('score')->create('task', 'finish', $taskID);
@@ -1719,6 +1787,13 @@ class taskModel extends model
$this->dao->update(TABLE_TASK)->data($task)->autoCheck()->where('id')->eq((int)$taskID)->exec();
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation))
{
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'bug', $task, $taskID);
}
if(!dao::isError())
{
if($oldTask->parent > 0) $this->updateParentStatus($taskID);
@@ -1762,6 +1837,14 @@ class taskModel extends model
$this->dao->update(TABLE_TASK)->set('assignedTo=openedBy')->where('parent')->eq((int)$taskID)->exec();
}
if($oldTask->story) $this->loadModel('story')->setStage($oldTask->story);
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation))
{
$currentIssue = $this->loadModel('gitlab')->apiGetSingleIssue($relation->gitlabID, $relation->projectID, $relation->issueID);
if($currentIssue->state != 'closed') $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
}
if(!dao::isError()) return common::createChanges($oldTask, $task);
}
@@ -1826,6 +1909,10 @@ class taskModel extends model
$this->computeWorkingHours($taskID);
}
if($oldTask->story) $this->loadModel('story')->setStage($oldTask->story);
$relation = $this->loadModel('gitlab')->getRelationByObject('task', $taskID);
if(!empty($relation)) $this->loadModel('gitlab')->apiUpdateIssue($relation->gitlabID, $relation->projectID, $relation->issueID, 'task', $task, $taskID);
if(!dao::isError()) return common::createChanges($oldTask, $task);
}
+8
View File
@@ -15,6 +15,7 @@
<?php include '../../common/view/sortable.html.php';?>
<?php js::set('toTaskList', !empty($task->id));?>
<?php js::set('blockID', $blockID);?>
<?php js::set('gitlabProjects', $gitlabProjects);?>
<div id='mainContent' class='main-content'>
<div class='center-block'>
<div class='main-header'>
@@ -239,6 +240,13 @@
</td>
</tr>
<?php endif;?>
<?php if(!empty($gitlabProjects)):?>
<tr>
<th><?php echo $lang->task->sync2Gitlab;?></th>
<td><?php echo html::select('gitlab', $gitlabList, '', "class='form-control chosen'");?></td>
<td><?php echo html::select('gitlabProject', '', '', "class='form-control chosen'");?></td>
</tr>
<?php endif;?>
<tr id='after-tr'>
<th><?php echo $lang->task->afterSubmit;?></th>
<td colspan='3'><?php echo html::radio('after', $lang->task->afterChoices, !empty($task->id) ? 'toTaskList' : 'continueAdding');?></td>