Commit c193af79 authored by Toon Claes's avatar Toon Claes

Use helper method to set filtered search input attributes

The list of attributes for the filtered search input was getting long, so use a
helper method to fill that hash.

Also, for multiple issue assignees, a helper is more convenient because it would
allow EE to override the behavior if MIA is supported.
parent 7182e9e2
......@@ -26,9 +26,11 @@ class FilteredSearchTokenKeysIssuesEE extends gl.FilteredSearchTokenKeys {
static get() {
const tokenKeys = Array.from(super.get());
// Enable multiple assignees
const assigneeTokenKey = tokenKeys.find(tk => tk.key === 'assignee');
if (this.availableFeatures && this.availableFeatures.multipleAssignees) assigneeTokenKey.type = 'array';
// Enable multiple assignees when available
if (this.availableFeatures && this.availableFeatures.multipleAssignees) {
const assigneeTokenKey = tokenKeys.find(tk => tk.key === 'assignee');
assigneeTokenKey.type = 'array';
}
tokenKeys.push(weightTokenKey);
return tokenKeys;
......
module EE
module SearchHelper
def search_filter_input_options(type)
options = super
options[:data][:'multiple-assignees'] = 'true' if (type == :issues) && @project.feature_available?(:multiple_issue_assignees)
options
end
end
end
module SearchHelper
prepend EE::SearchHelper
def search_autocomplete_opts(term)
return unless current_user
......@@ -134,6 +136,18 @@ module SearchHelper
search_path(options)
end
def search_filter_input_options(type)
{
id: "filtered-search-#{type}",
placeholder: 'Search or filter results...',
data: {
'project-id' => @project.id,
'username-params' => @users.to_json(only: [:id, :username]),
'base-endpoint' => project_path(@project)
}
}
end
# Sanitize a HTML field for search display. Most tags are stripped out and the
# maximum length is set to 200 characters.
def search_md_sanitize(object, field)
......
- type = local_assigns.fetch(:type)
- board = local_assigns.fetch(:board, nil)
- block_css_class = type != :boards_modal ? 'row-content-block second-block' : ''
- can_multiple_assignees = @project.feature_available?(:"multiple_#{type.to_s}_assignees")
.issues-filters
.issues-details-filters.filtered-search-block{ class: block_css_class, "v-pre" => type == :boards_modal }
......@@ -28,7 +27,7 @@
.scroll-container
%ul.tokens-container.list-unstyled
%li.input-token
%input.form-control.filtered-search{ id: "filtered-search-#{type.to_s}", placeholder: 'Search or filter results...', data: { 'project-id' => @project.id, 'username-params' => @users.to_json(only: [:id, :username]), 'base-endpoint' => project_path(@project), 'multiple-assignees' => can_multiple_assignees } }
%input.form-control.filtered-search{ search_filter_input_options(type) }
= icon('filter')
#js-dropdown-hint.filtered-search-input-dropdown-menu.dropdown-menu.hint-dropdown
%ul{ data: { dropdown: true } }
......
......@@ -15,6 +15,9 @@ import '~/filtered_search/filtered_search_token_keys_issues_ee';
let tokenKeys;
beforeEach(() => {
gl.FilteredSearchTokenKeysIssuesEE.init({
multipleAssignees: true,
});
tokenKeys = gl.FilteredSearchTokenKeysIssuesEE.get();
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment