Limit autocomplete to currently selected items
This commit is contained in:
parent
3de1e71c8b
commit
d54b88260c
|
|
@ -51,6 +51,11 @@
|
|||
if (!GitLab.GfmAutoComplete.dataLoaded) {
|
||||
return this.at;
|
||||
} else {
|
||||
if (value.indexOf("unlabel") !== -1) {
|
||||
GitLab.GfmAutoComplete.input.atwho('load', '~', GitLab.GfmAutoComplete.cachedData.unlabels);
|
||||
} else {
|
||||
GitLab.GfmAutoComplete.input.atwho('load', '~', GitLab.GfmAutoComplete.cachedData.labels);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
@ -352,3 +357,4 @@
|
|||
};
|
||||
|
||||
}).call(this);
|
||||
|
||||
|
|
|
|||
|
|
@ -144,13 +144,15 @@ class ProjectsController < Projects::ApplicationController
|
|||
|
||||
autocomplete = ::Projects::AutocompleteService.new(@project, current_user)
|
||||
participants = ::Projects::ParticipantsService.new(@project, current_user).execute(noteable)
|
||||
unlabels = autocomplete.unlabels(noteable)
|
||||
|
||||
@suggestions = {
|
||||
emojis: Gitlab::AwardEmoji.urls,
|
||||
issues: autocomplete.issues,
|
||||
milestones: autocomplete.milestones,
|
||||
mergerequests: autocomplete.merge_requests,
|
||||
labels: autocomplete.labels,
|
||||
labels: autocomplete.labels - unlabels,
|
||||
unlabels: unlabels,
|
||||
members: participants,
|
||||
commands: autocomplete.commands(noteable, params[:type])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,14 @@ module Projects
|
|||
end
|
||||
|
||||
def labels
|
||||
LabelsFinder.new(current_user, project_id: project.id).execute.select([:title, :color])
|
||||
LabelsFinder.new(current_user, project_id: project.id).execute.
|
||||
pluck(:title, :color).map { |l| { title: l.first, color: l.second } }
|
||||
end
|
||||
|
||||
def unlabels(noteable)
|
||||
return [] unless noteable && noteable.respond_to?(:labels)
|
||||
|
||||
noteable.labels.pluck(:title, :color).map { |l| { title: l.first, color: l.second } }
|
||||
end
|
||||
|
||||
def commands(noteable, type)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Limit autocomplete to currently selected items for unlabel slash command
|
||||
merge_request: 22680
|
||||
author: Akram Fares
|
||||
Loading…
Reference in New Issue