diff options
-rw-r--r-- | app/assets/javascripts/search_dropdowns.js.coffee | 38 | ||||
-rw-r--r-- | app/views/search/_filter.html.haml | 40 | ||||
-rw-r--r-- | app/views/search/_form.html.haml | 4 |
3 files changed, 58 insertions, 24 deletions
diff --git a/app/assets/javascripts/search_dropdowns.js.coffee b/app/assets/javascripts/search_dropdowns.js.coffee index 37c5c94d8b0..747483d1d8b 100644 --- a/app/assets/javascripts/search_dropdowns.js.coffee +++ b/app/assets/javascripts/search_dropdowns.js.coffee @@ -3,4 +3,42 @@ class @SearchDropdowns $('.js-search-group-dropdown').glDropdown( selectable: true filterable: true + fieldName: 'group_id' + data: (term, callback) -> + Api.groups term, null, (data) -> + data.unshift( + name: 'Any' + ) + data.splice 1, 0, 'divider' + + callback(data) + id: (obj) -> + obj.id + text: (obj) -> + obj.name + clicked: => + @submitSearch() ) + + $('.js-search-project-dropdown').glDropdown( + selectable: true + filterable: true + fieldName: 'project_id' + data: (term, callback) -> + Api.projects term, 'id', (data) -> + data.unshift( + name_with_namespace: 'Any' + ) + data.splice 1, 0, 'divider' + + callback(data) + id: (obj) -> + obj.id + text: (obj) -> + obj.name_with_namespace + clicked: => + @submitSearch() + ) + + submitSearch: -> + $('.js-search-form').submit() diff --git a/app/views/search/_filter.html.haml b/app/views/search/_filter.html.haml index 091dae24f4c..a1562215e8b 100644 --- a/app/views/search/_filter.html.haml +++ b/app/views/search/_filter.html.haml @@ -1,3 +1,7 @@ +- if params[:group_id].present? + = hidden_field_tag :group_id, params[:group_id] +- if params[:project_id].present? + = hidden_field_tag :project_id, params[:project_id] .dropdown.append-right-5.prepend-left-5 %button.dropdown-toggle.btn.js-search-group-dropdown{ type: "button", data: { toggle: "dropdown" } } Group: @@ -12,19 +16,11 @@ %button.dropdown-title-button.dropdown-menu-close{ aria: { label: "Close" } } = icon('times') = dropdown_filter("Search groups") - .dropdown-content - %ul - %li - = link_to search_filter_path(group_id: nil), class: ("is-active" if !params[:group_id].present?) do - Any - %li.divider - - current_user.authorized_groups.sort_by(&:name).each do |group| - %li - = link_to search_filter_path(group_id: group.id, project_id: nil), class: ("is-active" if params[:group_id] == group.id.to_s) do - = group.name + = dropdown_content + = dropdown_loading .dropdown.project-filter.append-right-5.prepend-left-5 - %button.dropdown-toggle.btn{ type: "button", data: { toggle: "dropdown" } } + %button.dropdown-toggle.btn.js-search-project-dropdown{ type: "button", data: { toggle: "dropdown" } } Project: - if @project.present? %strong= @project.name_with_namespace @@ -37,13 +33,15 @@ %button.dropdown-title-button.dropdown-menu-close{aria: {label: "Close"}} = icon('times') = dropdown_filter("Search projects") - .dropdown-content - %ul - %li - = link_to search_filter_path(project_id: nil), class: ("is-active" if !params[:project_id].present?) do - Any - %li.divider - - current_user.authorized_projects.sort_by(&:name_with_namespace).each do |project| - %li - = link_to search_filter_path(project_id: project.id, group_id: nil), class: ("is-active" if params[:project_id] == project.id.to_s) do - = project.name_with_namespace + = dropdown_content + = dropdown_loading + -# .dropdown-content + -# %ul + -# %li + -# = link_to search_filter_path(project_id: nil), class: ("is-active" if !params[:project_id].present?) do + -# Any + -# %li.divider + -# - current_user.authorized_projects.sort_by(&:name_with_namespace).each do |project| + -# %li + -# = link_to search_filter_path(project_id: project.id, group_id: nil), class: ("is-active" if params[:project_id] == project.id.to_s) do + -# = project.name_with_namespace diff --git a/app/views/search/_form.html.haml b/app/views/search/_form.html.haml index b05e8d4d908..6e550cc7621 100644 --- a/app/views/search/_form.html.haml +++ b/app/views/search/_form.html.haml @@ -1,6 +1,4 @@ -= form_tag search_path, method: :get do |f| - = hidden_field_tag :project_id, params[:project_id] - = hidden_field_tag :group_id, params[:group_id] += form_tag search_path, method: :get, class: 'js-search-form' do |f| = hidden_field_tag :snippets, params[:snippets] = hidden_field_tag :scope, params[:scope] |