Implemented issue search via api when adding new dependencies
This commit is contained in:
parent
20ed1e949e
commit
4d28a82632
|
|
@ -1590,6 +1590,7 @@ $(document).ready(function () {
|
||||||
initTeamSettings();
|
initTeamSettings();
|
||||||
initCtrlEnterSubmit();
|
initCtrlEnterSubmit();
|
||||||
initNavbarContentToggle();
|
initNavbarContentToggle();
|
||||||
|
initIssueList();
|
||||||
|
|
||||||
// Repo clone url.
|
// Repo clone url.
|
||||||
if ($('#repo-clone-url').length > 0) {
|
if ($('#repo-clone-url').length > 0) {
|
||||||
|
|
@ -2133,33 +2134,26 @@ function deleteDependencyModal(id, type) {
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildIssuesList() {
|
function initIssueList() {
|
||||||
// Get a list of issues
|
|
||||||
var repolink = $('#repolink').val();
|
var repolink = $('#repolink').val();
|
||||||
var issueIndex = $('#issueIndex').val();
|
$('.new-dependency-drop-list')
|
||||||
|
.dropdown({
|
||||||
|
apiSettings: {
|
||||||
|
url: '/api/v1/repos' + repolink + '/issues?q={query}',
|
||||||
|
onResponse: function(response) {
|
||||||
|
var filteredResponse = {'success': true, 'results': []};
|
||||||
|
// Parse the response from the api to work with our dropdown
|
||||||
|
$.each(response, function(index, issue) {
|
||||||
|
filteredResponse.results.push({
|
||||||
|
'name' : '#' + issue.number + ' ' + issue.title,
|
||||||
|
'value' : issue.id
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return filteredResponse;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
if(repolink !== undefined) {
|
fullTextSearch: true
|
||||||
$.getJSON('/api/v1/repos' + repolink + '/issues', function (data) {
|
})
|
||||||
|
;
|
||||||
$.each(data, function (i, issue) {
|
|
||||||
if (issue.number != issueIndex) {
|
|
||||||
$('.new-dependency-dropdown').append('<div class="item" data-value="' + issue.id + '"><b>#' + issue.number + '</b> ' + issue.title + '</div>');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.new-dependency-drop-list').dropdown({
|
|
||||||
fullTextSearch: true
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var buildIssuesListOnce = (function() {
|
|
||||||
var executed = false;
|
|
||||||
return function() {
|
|
||||||
if (!executed) {
|
|
||||||
executed = true;
|
|
||||||
buildIssuesList();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
|
||||||
|
|
@ -278,13 +278,11 @@
|
||||||
<form method="POST" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/dependency/add" id="addDependencyForm">
|
<form method="POST" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/dependency/add" id="addDependencyForm">
|
||||||
{{$.CsrfTokenHtml}}
|
{{$.CsrfTokenHtml}}
|
||||||
<div class="ui fluid action input">
|
<div class="ui fluid action input">
|
||||||
<div class="ui search selection dropdown new-dependency-drop-list" style="min-width: 13.9rem;border-radius: 4px 0 0 4px;border-right: 0;white-space: nowrap;" onclick="buildIssuesListOnce();">
|
<div class="ui search selection dropdown new-dependency-drop-list" style="min-width: 13.9rem;border-radius: 4px 0 0 4px;border-right: 0;white-space: nowrap;">
|
||||||
<input name="newDependency" type="hidden">
|
<input name="newDependency" type="hidden">
|
||||||
<i class="dropdown icon"></i>
|
<i class="dropdown icon"></i>
|
||||||
|
<input type="text" class="search">
|
||||||
<div class="default text">{{.i18n.Tr "repo.issues.dependency.add"}}</div>
|
<div class="default text">{{.i18n.Tr "repo.issues.dependency.add"}}</div>
|
||||||
<div class="menu new-dependency-dropdown">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<button class="ui green icon button">
|
<button class="ui green icon button">
|
||||||
<i class="plus icon"></i>
|
<i class="plus icon"></i>
|
||||||
|
|
@ -298,7 +296,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{if .CanCreateIssueDependencies}}
|
{{if .CanCreateIssueDependencies}}
|
||||||
<input type="hidden" id="repolink" value="{{$.RepoLink}}">
|
<input type="hidden" id="repolink" value="{{$.RepoLink}}">
|
||||||
<!-- I know, there is probably a better way to do this -->
|
<!-- I know, there is probably a better way to do this onclick="buildIssuesListOnce();" -->
|
||||||
<input type="hidden" id="issueIndex" value="{{.Issue.Index}}"/>
|
<input type="hidden" id="issueIndex" value="{{.Issue.Index}}"/>
|
||||||
|
|
||||||
<div class="ui basic modal remove-dependency">
|
<div class="ui basic modal remove-dependency">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user