diff --git a/config/filter.php b/config/filter.php index 680245f08b..a4125b9da5 100644 --- a/config/filter.php +++ b/config/filter.php @@ -132,6 +132,7 @@ $filter->user->ajaxgetmore = new stdclass(); $filter->repo->ajaxsynccommit = new stdclass(); $filter->search->index = new stdclass(); $filter->gitlab->webhook = new stdclass(); +$filter->gitlab->importissue = new stdclass(); $filter->bug->batchcreate->cookie['preBranch'] = 'int'; $filter->bug->browse->cookie['bugModule'] = 'int'; @@ -315,3 +316,8 @@ $filter->gitlab->webhook->get['gitlab'] = 'int'; $filter->gitlab->webhook->get['product'] = 'int'; $filter->gitlab->webhook->get['project'] = 'int'; $filter->gitlab->webhook->get['token'] = 'reg::any'; + +$filter->gitlab->importissue->get['gitlab'] = 'int'; +$filter->gitlab->importissue->get['product'] = 'int'; +$filter->gitlab->importissue->get['project'] = 'int'; + diff --git a/module/gitlab/config.php b/module/gitlab/config.php index 5f699712cf..d4dfc228f9 100644 --- a/module/gitlab/config.php +++ b/module/gitlab/config.php @@ -96,3 +96,5 @@ $config->gitlab->objectTables->story = TABLE_STORY; $config->gitlab->objectTables->task = TABLE_TASK; $config->gitlab->objectTables->bug = TABLE_BUG; +$config->gitlab->objectTypes = array('', 'task', 'bug', 'story'); + diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 7de7b907d2..4ef8d58d8a 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -251,28 +251,32 @@ class gitlab extends control exit; } - public function transferIssue() + public function importIssue() { - //TODO(dingguodong) todo next. - if(!empty($this->post)) + if($_POST) { - $project; - $product; - $execution; - $objetcType; - $gitlab; - $gitlabProject; - $gitlabIssue; + $this->post->a(); } - - $this->view->programs = array('') + $this->loadModel('program')->getTopPairs('', 'noclosed'); - - $this->view->products = '$projects'; - $this->view->execution = '$projects'; - $this->view->objectTypes = '$projects'; - $this->view->gitlabs = '$projects'; - $this->view->gitlabProjects = '$projects'; - $this->view->gitlabIssues = '$projects'; + + $productID = $this->get->product; + $gitlabID = $this->get->gitlab; + $projectID = $this->get->project; + $relations = $this->gitlab->getExecutionsByProduct($productID); + + $executions = array(); + foreach($relations as $relation) + { + if($relation->execution) $executions[] = $this->loadModel("execution")->getByID($relation->execution)->name; + } + + $this->view->productName = $this->loadModel("product")->getByID($productID)->name; + $this->view->productID = $productID; + $this->view->gitlabID = $gitlabID; + $this->view->gitlabProjectID = $projectID; + $this->view->executions = $executions; + $this->view->objectTypes = $this->config->gitlab->objectTypes; + + $this->view->gitlabIssues = $this->gitlab->apiGetIssues($gitlabID, $projectID); $this->display(); } } diff --git a/module/gitlab/js/mapissue.js b/module/gitlab/js/mapissue.js new file mode 100644 index 0000000000..a8be522002 --- /dev/null +++ b/module/gitlab/js/mapissue.js @@ -0,0 +1,19 @@ +$(document).ready(function() +{ + $('[name^=gitlabID').change(function() + { + var gitlab = $(this); + host = gitlab.val(); + if(host == '') return false; + projects = ''; + url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host); + + $.get(url, function(response) + { + project = gitlab.parent().next().find('select'); + project.html('').append(response); + project.chosen().trigger("chosen:updated"); + }); + + }); +}); diff --git a/module/gitlab/lang/zh-cn.php b/module/gitlab/lang/zh-cn.php index 24226ad028..abe00b1b5e 100644 --- a/module/gitlab/lang/zh-cn.php +++ b/module/gitlab/lang/zh-cn.php @@ -6,6 +6,7 @@ $lang->gitlab->create = '添加gitlab'; $lang->gitlab->edit = '编辑gitlab'; $lang->gitlab->bindUser = '绑定用户'; $lang->gitlab->bindProduct = '关联产品'; +$lang->gitlab->importIssue = '关联议题'; $lang->gitlab->delete = '删除'; $lang->gitlab->confirmDelete = '确认删除该gitlab吗?'; $lang->gitlab->gitlabAccount = 'gitlab用户'; @@ -13,11 +14,13 @@ $lang->gitlab->zentaoAccount = '禅道用户'; $lang->gitlab->browseAction = 'gitlab列表'; $lang->gitlab->deleteAction = '删除gitlab'; -$lang->gitlab->gitlabProject = 'gitlab项目'; +$lang->gitlab->gitlabProject = "{$lang->gitlab->common}项目"; +$lang->gitlab->gitlabIssue = "{$lang->gitlab->common}议题"; $lang->gitlab->zentaoProduct = '禅道产品'; +$lang->gitlab->objectType = '类型'; // task, bug, story $lang->gitlab->id = 'ID'; -$lang->gitlab->name = '名称'; +$lang->gitlab->name = "{$lang->gitlab->common}名称"; $lang->gitlab->url = '服务地址'; $lang->gitlab->token = 'Token'; $lang->gitlab->defaultProject = '默认项目'; diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 26b568df36..0d1e7f9ccc 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -198,7 +198,24 @@ class gitlabModel extends model ->andWhere('product')->eq($productID) ->fetchGroup('AID'); } - + + /** + * Get executions by one product for gitlab module. + * + * @param int $productID + * @access public + * @return array + */ + public function getExecutionsByProduct($productID) + { + return $this->dao->select('distinct execution')->from(TABLE_RELATION) + ->where('relation')->eq('interrated') + ->andWhere('AType')->eq('gitlab') + ->andWhere('BType')->eq('gitlabProject') + ->andWhere('product')->eq($productID) + ->fetchAll('execution'); + } + /** * Get gitlabID and projectID. * @@ -326,6 +343,11 @@ class gitlabModel extends model return $allResults; } + public function apiGetIssues($gitlabID, $projectID) + { + + } + /** * Get hooks. * diff --git a/module/gitlab/view/importissue.html.php b/module/gitlab/view/importissue.html.php new file mode 100644 index 0000000000..16b8879841 --- /dev/null +++ b/module/gitlab/view/importissue.html.php @@ -0,0 +1,52 @@ + + * @package story + * @version $Id$ + * @link http://www.zentao.net + */ +?> + +
+
+

gitlab->importIssue;?>

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
product->common;?>execution->common;?>gitlab->gitlabIssue;?>gitlab->objectType;?>
+ save);?> + +
+
+
+
+ diff --git a/module/gitlab/view/transferissue.html.php b/module/gitlab/view/transferissue.html.php deleted file mode 100644 index 90e157f3cd..0000000000 --- a/module/gitlab/view/transferissue.html.php +++ /dev/null @@ -1,63 +0,0 @@ - - * @package story - * @version $Id$ - * @link http://www.zentao.net - */ -?> - -
-
-

gitlab->transferIssue;?>

-
-
-
- - - - - - - - - - zentaoAccount)) continue;?> - - - - - - - - zentaoAccount)) continue;?> - - - - - - - - - - - - -
gitlab->gitlabAccount;?>gitlab->zentaoAccount;?>
avatar, "height=40");?> - realname;?> -
account . " <" . $gitlabUser->email . ">"; ?> -
id]", $userPairs, '', "class='form-control select chosen'" );?>
avatar, "height=40");?> - realname;?> -
account . " <" . $gitlabUser->email . ">";?> -
id]", $userPairs, $gitlabUser->zentaoAccount, "class='form-control select chosen'" );?>
- save);?> - -
-
-
-
- diff --git a/module/repo/view/maintain.html.php b/module/repo/view/maintain.html.php index e7a0e9391d..2c2da5b64a 100644 --- a/module/repo/view/maintain.html.php +++ b/module/repo/view/maintain.html.php @@ -49,6 +49,7 @@ id&objectID=$objectID", '', 'list', 'edit'); + common::printIcon('gitlab', 'importissue', "product={$repo->product}&gitlab={$repo->gitlab}&project={$repo->project}", '', 'list', 'link'); if(common::hasPriv('repo', 'delete')) echo html::a($this->createLink('repo', 'delete', "repoID=$repo->id&objectID=$objectID"), '', 'hiddenwin', "title='{$lang->repo->delete}' class='btn'"); ?>