summaryrefslogtreecommitdiffstats
path: root/public/js/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/index.js')
-rw-r--r--public/js/index.js51
1 files changed, 49 insertions, 2 deletions
diff --git a/public/js/index.js b/public/js/index.js
index 93ac6a2178..af31418371 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -2135,6 +2135,52 @@ function initWipTitle() {
});
}
+function initTemplateSearch() {
+ const $repoTemplate = $("#repo_template");
+ const checkTemplate = function() {
+ const $templateUnits = $("#template_units");
+ const $nonTemplate = $("#non_template");
+ if ($repoTemplate.val() !== "") {
+ $templateUnits.show();
+ $nonTemplate.hide();
+ } else {
+ $templateUnits.hide();
+ $nonTemplate.show();
+ }
+ };
+ $repoTemplate.change(checkTemplate);
+ checkTemplate();
+
+ const changeOwner = function() {
+ $("#repo_template_search")
+ .dropdown({
+ apiSettings: {
+ url: suburl + '/api/v1/repos/search?q={query}&template=true&priority_owner_id=' + $("#uid").val(),
+ onResponse: function(response) {
+ const filteredResponse = {'success': true, 'results': []};
+ filteredResponse.results.push({
+ 'name': '',
+ 'value': ''
+ });
+ // Parse the response from the api to work with our dropdown
+ $.each(response.data, function(_r, repo) {
+ filteredResponse.results.push({
+ 'name' : htmlEncode(repo.full_name) ,
+ 'value' : repo.id
+ });
+ });
+ return filteredResponse;
+ },
+ cache: false,
+ },
+
+ fullTextSearch: true
+ });
+ };
+ $("#uid").change(changeOwner);
+ changeOwner();
+}
+
$(document).ready(function () {
csrf = $('meta[name=_csrf]').attr("content");
suburl = $('meta[name=_suburl]').attr("content");
@@ -2377,6 +2423,7 @@ $(document).ready(function () {
initWipTitle();
initPullRequestReview();
initRepoStatusChecker();
+ initTemplateSearch();
// Repo clone url.
if ($('#repo-clone-url').length > 0) {
@@ -3294,7 +3341,7 @@ function initIssueList() {
$('#new-dependency-drop-list')
.dropdown({
apiSettings: {
- url: issueSearchUrl,
+ url: issueSearchUrl,
onResponse: function(response) {
const filteredResponse = {'success': true, 'results': []};
const currIssueId = $('#new-dependency-drop-list').data('issue-id');
@@ -3305,7 +3352,7 @@ function initIssueList() {
return;
}
filteredResponse.results.push({
- 'name' : '#' + issue.number + ' ' + htmlEncode(issue.title) +
+ 'name' : '#' + issue.number + ' ' + htmlEncode(issue.title) +
'<div class="text small dont-break-out">' + htmlEncode(issue.repository.full_name) + '</div>',
'value' : issue.id
});