Skip to content

Commit

Permalink
Use autocomplete search for requests index creator filter
Browse files Browse the repository at this point in the history
  • Loading branch information
krauselukas committed Dec 13, 2024
1 parent fb72462 commit c980c8e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/api/app/controllers/concerns/webui/requests_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def set_filters
@filter_action_type = params[:action_type].presence || []
@filter_action_type = @filter_action_type.intersection(BsRequestAction::TYPES)

@filter_creators = params[:creators].presence || []
@filter_creators = params[:creators].present? ? params[:creators].compact_blank! : []
end

def set_selected_filter
Expand Down
2 changes: 0 additions & 2 deletions src/api/app/controllers/webui/users/bs_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ def index
format.html do
filter_requests

# TODO: Temporarily disable list of creators due to performance issues
# @bs_requests_creators = @bs_requests.distinct.pluck(:creator)
@bs_requests = @bs_requests.order('number DESC').page(params[:page])
@bs_requests = @bs_requests.includes(:bs_request_actions, :comments, :reviews)
@bs_requests = @bs_requests.includes(:labels) if Flipper.enabled?(:labels, User.session)
Expand Down
17 changes: 0 additions & 17 deletions src/api/app/views/webui/shared/bs_requests/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,3 @@
clearTimeout(submitFiltersTimeout);
submitFiltersTimeout = setTimeout(submitRequestFilters, 2000);
});

$(document).on("input", "#request-creator-search", function(event) {
var searchInput = event.target;
var filterValue = searchInput.value.toLowerCase();
var dropdown = document.getElementById("request-creator-dropdown");
var dropdownInputFields = dropdown.getElementsByTagName("input");

for (i = 1; i < dropdownInputFields.length; i++) {
dropdownInputValue = dropdownInputFields[i].value;

if (dropdownInputValue.toLowerCase().indexOf(filterValue) > -1) {
dropdownInputFields[i].closest(".dropdown-item-text").style.display = "";
} else {
dropdownInputFields[i].closest(".dropdown-item-text").style.display = "none";
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,23 @@
label_icon: action_type_icon('submit'),
checked: selected_filter[:action_type]&.include?('submit')}

-# TODO: Temporarily disable list of creators due to performance issues
.mt-2.mb-2.accordion-item.border-0
%h6.px-3.py-2.accordion-button.no-style{ data: { 'bs-toggle': 'collapse', 'bs-target': '#request-filter-creator' },
aria: { expanded: 'true', controls: 'request-filter-creator' } }
%b Creator
.px-4.pb-2.accordion-collapse.collapse.show#request-filter-creator
#request-creator-dropdown
= text_field_tag('request-creator-search', nil, autocomplete: 'off', placeholder: 'Search creators...', class: 'form-control mb-2')
= render partial: 'webui/shared/autocomplete', locals: { html_id: 'creators[]', label: 'Creators:',
required: false,
data: { source: autocomplete_users_path } }

- if creators.include?(User.session.login)
- if selected_filter[:creators].include?(User.session.login)
.dropdown-item-text
= render partial: 'webui/shared/check_box', locals: { label: "#{User.session.login} (me)",
key: "creators[#{User.session.login}]", name: 'creators[]',
value: User.session.login,
checked: selected_filter[:creators]&.include?(User.session.login) }
- creators.each do |creator|
- selected_filter[:creators].each do |creator|
- next if creator == User.session.login
.dropdown-item-text
= render partial: 'webui/shared/check_box', locals: { label: creator,
Expand Down

0 comments on commit c980c8e

Please sign in to comment.