Commit bb50edb1 authored by Phil Hughes's avatar Phil Hughes

Loads group & projects on search page with ajax

parent b3af3930
...@@ -3,4 +3,42 @@ class @SearchDropdowns ...@@ -3,4 +3,42 @@ class @SearchDropdowns
$('.js-search-group-dropdown').glDropdown( $('.js-search-group-dropdown').glDropdown(
selectable: true selectable: true
filterable: 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()
- 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 .dropdown.append-right-5.prepend-left-5
%button.dropdown-toggle.btn.js-search-group-dropdown{ type: "button", data: { toggle: "dropdown" } } %button.dropdown-toggle.btn.js-search-group-dropdown{ type: "button", data: { toggle: "dropdown" } }
Group: Group:
...@@ -12,19 +16,11 @@ ...@@ -12,19 +16,11 @@
%button.dropdown-title-button.dropdown-menu-close{ aria: { label: "Close" } } %button.dropdown-title-button.dropdown-menu-close{ aria: { label: "Close" } }
= icon('times') = icon('times')
= dropdown_filter("Search groups") = dropdown_filter("Search groups")
.dropdown-content = dropdown_content
%ul = dropdown_loading
%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.project-filter.append-right-5.prepend-left-5 .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: Project:
- if @project.present? - if @project.present?
%strong= @project.name_with_namespace %strong= @project.name_with_namespace
...@@ -37,13 +33,15 @@ ...@@ -37,13 +33,15 @@
%button.dropdown-title-button.dropdown-menu-close{aria: {label: "Close"}} %button.dropdown-title-button.dropdown-menu-close{aria: {label: "Close"}}
= icon('times') = icon('times')
= dropdown_filter("Search projects") = dropdown_filter("Search projects")
.dropdown-content = dropdown_content
%ul = dropdown_loading
%li -# .dropdown-content
= link_to search_filter_path(project_id: nil), class: ("is-active" if !params[:project_id].present?) do -# %ul
Any -# %li
%li.divider -# = link_to search_filter_path(project_id: nil), class: ("is-active" if !params[:project_id].present?) do
- current_user.authorized_projects.sort_by(&:name_with_namespace).each do |project| -# Any
%li -# %li.divider
= link_to search_filter_path(project_id: project.id, group_id: nil), class: ("is-active" if params[:project_id] == project.id.to_s) do -# - current_user.authorized_projects.sort_by(&:name_with_namespace).each do |project|
= project.name_with_namespace -# %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
= form_tag search_path, method: :get do |f| = form_tag search_path, method: :get, class: 'js-search-form' do |f|
= hidden_field_tag :project_id, params[:project_id]
= hidden_field_tag :group_id, params[:group_id]
= hidden_field_tag :snippets, params[:snippets] = hidden_field_tag :snippets, params[:snippets]
= hidden_field_tag :scope, params[:scope] = hidden_field_tag :scope, params[:scope]
......
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