diff --git a/module/gitlab/control.php b/module/gitlab/control.php index 7c8d75630e..0193f67792 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -349,4 +349,25 @@ class gitlab extends control } return $this->send($options); } + + /** + * AJAX: Get project branches. + * + * @param int $gitlabID + * @param int $projectID + * @access public + * @return object + */ + public function ajaxGetProjectBranches($gitlabID, $projectID) + { + if(!$gitlabID or !$projectID) return $this->send(array('message' => array())); + + $branches = $this->gitlab->apiGetBranches($gitlabID, $projectID); + $options = ""; + foreach($branches as $index =>$branch) + { + $options .= ""; + } + return $this->send($options); + } } diff --git a/module/gitlab/model.php b/module/gitlab/model.php index aa350199fb..087721d341 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -305,8 +305,8 @@ class gitlabModel extends model public function getRefOptions($gitlabID, $projectID) { $refList = array(); - $branches = $this->loadModel('gitlab')->apiGetBranches($gitlabID, $projectID); - $tags = $this->loadModel('gitlab')->apiGetTags($gitlabID, $projectID); + $branches = $this->apiGetBranches($gitlabID, $projectID); + $tags = $this->apiGetTags($gitlabID, $projectID); foreach($branches as $branch) $refList[] = "Branch::" . $branch->name; foreach($tags as $tag) $refList[] = "Tag::" . $tag->name; return $refList; diff --git a/module/mr/control.php b/module/mr/control.php index 18b1bca7c9..100d6928df 100644 --- a/module/mr/control.php +++ b/module/mr/control.php @@ -76,5 +76,29 @@ class mr extends control public function update() { } + + /** + * AJAX: Get forked projects. + * + * @param int $gitlabID + * @param int $projectID + * @access public + * @return void + */ + public function ajaxGetForkedProjects($gitlabID, $projectID) + { + $projects = $this->mr->apiGetForks($gitlabID, $projectID); + + if(!$projects) return $this->send(array('message' => array())); + $projectIdList = $projectIdList ? explode(',', $projectIdList) : null; + $options = ""; + foreach($projects as $project) + { + if(!empty($projectIdList) and $project and !in_array($project->id, $projectIdList)) continue; + $options .= ""; + } + + return $this->send($options); + } } diff --git a/module/mr/js/create.js b/module/mr/js/create.js index dc117c16f7..3ab3aa2b2f 100644 --- a/module/mr/js/create.js +++ b/module/mr/js/create.js @@ -3,8 +3,8 @@ $(function() $('#gitlabID').change(function() { host = $('#gitlabID').val(); - url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host); if(host == '') return false; + url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host); $.get(url, function(response) { @@ -17,6 +17,15 @@ $(function() { $option = $(this).find('option:selected'); $('#name').val($option.data('name')); + project = $('#sourceProject').val(); + url = createLink('gitlab', 'ajaxgetprojectbranches', "gitlabID=" + host + "&projectID=" + project); + $.get(url, function(response) + { + $('#sourceBranch').html('').append(response); + $('#sourceBranch').chosen().trigger("chosen:updated");; + }); + + $('#targetProject').chosen().trigger("chosen:updated");; }); }); diff --git a/module/mr/view/create.html.php b/module/mr/view/create.html.php index 1e4323582a..d05a6824db 100644 --- a/module/mr/view/create.html.php +++ b/module/mr/view/create.html.php @@ -22,7 +22,6 @@