diff --git a/module/story/control.php b/module/story/control.php index 7a47d54b07..869e0c053a 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -295,6 +295,13 @@ class story extends control $this->view->customFields = $customFields; $this->view->showFields = $this->config->story->custom->createFields; + $allGitlabs = $this->loadModel('gitlab')->getPairs(); + $executionID = $objectID; + $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 = $product->name . $this->lang->colon . $this->lang->story->create; $this->view->position[] = html::a($this->createLink('product', 'browse', "product=$productID&branch=$branch"), $product->name); $this->view->position[] = $this->lang->story->common; diff --git a/module/story/js/create.js b/module/story/js/create.js index 473c38bd5f..4f410a918b 100644 --- a/module/story/js/create.js +++ b/module/story/js/create.js @@ -34,3 +34,22 @@ function refreshPlan() $(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/story/lang/zh-cn.php b/module/story/lang/zh-cn.php index c32023f07a..5bd7dde722 100644 --- a/module/story/lang/zh-cn.php +++ b/module/story/lang/zh-cn.php @@ -405,3 +405,5 @@ $lang->story->categoryList['safe'] = '安全'; $lang->story->categoryList['experience'] = '体验'; $lang->story->categoryList['improve'] = '改进'; $lang->story->categoryList['other'] = '其他'; + +$lang->story->sync2Gitlab = '同步到Gitlab'; diff --git a/module/story/model.php b/module/story/model.php index 707c9b0fe7..194ab52831 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -233,7 +233,7 @@ class storyModel extends model $requiredFields = trim($requiredFields, ','); - $this->dao->insert(TABLE_STORY)->data($story, 'spec,verify')->autoCheck()->batchCheck($requiredFields, 'notempty')->exec(); + $this->dao->insert(TABLE_STORY)->data($story, 'spec,verify,gitlab,gitlabProject')->autoCheck()->batchCheck($requiredFields, 'notempty')->exec(); if(!dao::isError()) { $storyID = $this->dao->lastInsertID(); @@ -339,6 +339,9 @@ class storyModel extends model /* Callback the callable method to process the related data for object that is transfered to story. */ if($from && is_callable(array($this, $this->config->story->fromObjects[$from]['callback']))) call_user_func(array($this, $this->config->story->fromObjects[$from]['callback']), $storyID); + /* sync this story to gitlab issue */ + $this->loadModel('gitlab')->syncStory($storyID, $this->post->gitlab, $this->post->gitlabProject); + return array('status' => 'created', 'id' => $storyID); } return false; diff --git a/module/story/view/create.html.php b/module/story/view/create.html.php index 147187c88c..7c272cfd97 100644 --- a/module/story/view/create.html.php +++ b/module/story/view/create.html.php @@ -17,6 +17,7 @@ story->placeholder); ?> + @@ -251,6 +252,14 @@ + + + story->sync2Gitlab;?> + + + + +