diff --git a/module/bug/control.php b/module/bug/control.php index 0dabb253a3..84d137d9f0 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -557,6 +557,13 @@ class bug extends control $this->view->customFields = $customFields; $this->view->showFields = $this->config->bug->custom->createFields; + /* Set gitlabProjects. */ + $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->title = $this->products[$productID] . $this->lang->colon . $this->lang->bug->create; $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]); $this->view->position[] = $this->lang->bug->create; diff --git a/module/bug/js/create.js b/module/bug/js/create.js index b602586a0a..45e46052d7 100644 --- a/module/bug/js/create.js +++ b/module/bug/js/create.js @@ -155,3 +155,23 @@ $(function() $(window).unload(function(){ if(blockID) window.parent.refreshBlock($('#block' + blockID)); }); + +$(document).ready(function() +{ + $('#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");; + }); + + }); + +}); diff --git a/module/bug/lang/zh-cn.php b/module/bug/lang/zh-cn.php index 7dfd1e848b..82912a0c71 100644 --- a/module/bug/lang/zh-cn.php +++ b/module/bug/lang/zh-cn.php @@ -24,6 +24,7 @@ $lang->bug->storyVersion = "{$lang->SRCommon}版本"; $lang->bug->color = '标题颜色'; $lang->bug->task = '相关任务'; $lang->bug->title = 'Bug标题'; +$lang->bug->sync2gitlab = '同步gitlab'; $lang->bug->severity = '严重程度'; $lang->bug->severityAB = '级别'; $lang->bug->pri = '优先级'; diff --git a/module/bug/model.php b/module/bug/model.php index b9e9f11ef5..c3e2283689 100644 --- a/module/bug/model.php +++ b/module/bug/model.php @@ -84,10 +84,14 @@ class bugModel extends model /* Use classic mode to replace required project. */ if($this->config->systemMode == 'classic' and strpos($this->config->bug->create->requiredFields, 'project') !== false) $this->config->bug->create->requiredFields = str_replace('project', 'execution', $this->config->bug->create->requiredFields); - $this->dao->insert(TABLE_BUG)->data($bug)->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec(); + $this->dao->insert(TABLE_BUG)->data($bug, $skip = 'gitlab,gitlabProject')->autoCheck()->batchCheck($this->config->bug->create->requiredFields, 'notempty')->exec(); if(!dao::isError()) { $bugID = $this->dao->lastInsertID(); + + /* Sync this bug to gitlab issue. */ + $this->loadModel('gitlab')->syncBug($bugID, $this->post->gitlab, $this->post->gitlabProject); + $this->file->updateObjectID($this->post->uid, $bugID, 'bug'); $this->file->saveUpload('bug', $bugID); empty($bug->case) ? $this->loadModel('score')->create('bug', 'create', $bugID) : $this->loadModel('score')->create('bug', 'createFormCase', $bug->case); diff --git a/module/bug/view/create.html.php b/module/bug/view/create.html.php index a742898300..951d25b4fb 100644 --- a/module/bug/view/create.html.php +++ b/module/bug/view/create.html.php @@ -26,6 +26,7 @@ js::set('isStepsTemplate', $isStepsTemplate); js::set('oldProjectID', $projectID); js::set('blockID', $blockID); js::set('moduleID', $moduleID); +js::set('gitlabProjects', $gitlabProjects); ?>