Don't list an issue on its own dependency list UI. (#5658)

Fixes: #4684.
This commit is contained in:
Harshit Bansal 2019-01-16 03:01:35 +05:30 committed by techknowlogick
parent 270fa6d63b
commit 1ac8f6fb83
2 changed files with 8 additions and 2 deletions

View File

@ -2810,14 +2810,19 @@ function deleteDependencyModal(id, type) {
function initIssueList() { function initIssueList() {
var repolink = $('#repolink').val(); var repolink = $('#repolink').val();
$('.new-dependency-drop-list') $('#new-dependency-drop-list')
.dropdown({ .dropdown({
apiSettings: { apiSettings: {
url: suburl + '/api/v1/repos/' + repolink + '/issues?q={query}', url: suburl + '/api/v1/repos/' + repolink + '/issues?q={query}',
onResponse: function(response) { onResponse: function(response) {
var filteredResponse = {'success': true, 'results': []}; var filteredResponse = {'success': true, 'results': []};
var currIssueId = $('#new-dependency-drop-list').data('issue-id');
// Parse the response from the api to work with our dropdown // Parse the response from the api to work with our dropdown
$.each(response, function(index, issue) { $.each(response, function(index, issue) {
// Don't list current issue in the dependency list.
if(issue.id === currIssueId) {
return;
}
filteredResponse.results.push({ filteredResponse.results.push({
'name' : '#' + issue.number + ' ' + htmlEncode(issue.title), 'name' : '#' + issue.number + ' ' + htmlEncode(issue.title),
'value' : issue.id 'value' : issue.id
@ -2825,6 +2830,7 @@ function initIssueList() {
}); });
return filteredResponse; return filteredResponse;
}, },
cache: false,
}, },
fullTextSearch: true fullTextSearch: true

View File

@ -321,7 +321,7 @@
<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;"> <div class="ui search selection dropdown" id="new-dependency-drop-list" data-issue-id="{{.Issue.ID}}" 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"> <input type="text" class="search">