Skip to content

Commit

Permalink
Cancel Ajax call when there are only duplicated issues
Browse files Browse the repository at this point in the history
Also prevent error when issues are not present in the action's params.

Fixes #8872
  • Loading branch information
Dany Marcoux committed Dec 16, 2019
1 parent 11e0321 commit e99244e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/api/app/assets/javascripts/webui/patchinfo.js
Expand Up @@ -14,10 +14,6 @@ function addIssuesAjaxBefore() {
return false;
}

var element = $(this);
element.children('i.fas.fa-plus-circle').addClass('d-none');
element.children('i.fas.fa-spin').removeClass('d-none');

issues = $.unique(issues.replace(/ /g, '').split(','));

var currentIssues = $('[name="patchinfo[issueid][]"]').map(function(_, element) {
Expand All @@ -33,6 +29,14 @@ function addIssuesAjaxBefore() {
return currentIssues.indexOf(issue) === -1;
});

if (issues.length === 0) {
$('#issue_ids').val('');
return false;
}

var element = $(this);
element.children('i.fas.fa-plus-circle').addClass('d-none');
element.children('i.fas.fa-spin').removeClass('d-none');
element.data('params', { issues: issues, project: element.data('project') });
});
}
Expand Down
1 change: 1 addition & 0 deletions src/api/app/controllers/webui/patchinfo_controller.rb
Expand Up @@ -89,6 +89,7 @@ def new_tracker
error = ''
invalid_format = ''
# params[:issues] = list of new issues to add
params[:issues] ||= []
params[:issues].each do |new_issue|
issue = IssueTracker::IssueTrackerHelper.new(new_issue)
if issue.valid?
Expand Down

0 comments on commit e99244e

Please sign in to comment.