Commit 522ef575 authored by Fatih Acet's avatar Fatih Acet

Refactor search autocomplete to support groups category contents.

parent 7df512d5
...@@ -68,8 +68,6 @@ class @SearchAutocomplete ...@@ -68,8 +68,6 @@ class @SearchAutocomplete
_this = @ _this = @
unless term unless term
return unless @hasLocationBadge()
if contents = @getCategoryContents() if contents = @getCategoryContents()
@searchInput.data('glDropdown').filter.options.callback contents @searchInput.data('glDropdown').filter.options.callback contents
@enableAutocomplete() @enableAutocomplete()
...@@ -132,17 +130,21 @@ class @SearchAutocomplete ...@@ -132,17 +130,21 @@ class @SearchAutocomplete
getCategoryContents: -> getCategoryContents: ->
userId = gon.current_user_id userId = gon.current_user_id
projectName = 'Dashboard' { utils, projectOptions, groupOptions, dashboardOptions } = gl
projectSlug = gl.utils.getProjectSlug()
projectOptions = gl.projectOptions?[projectSlug]
if projectSlug and projectOptions if utils.isInGroupsPage() and groupOptions
{ issuesPath, mrPath, projectName } = projectOptions options = groupOptions[utils.getGroupSlug()]
else
{ issuesPath, mrPath } = gl.dashboardOptions else if utils.isInProjectPage() and projectOptions
options = projectOptions[utils.getProjectSlug()]
else if dashboardOptions
options = dashboardOptions
return [ { issuesPath, mrPath, name } = options
{ header: "Go to in #{projectName}" }
items = [
{ header: "#{name}" }
{ text: 'Issues assigned to me', url: "#{issuesPath}/?assignee_id=#{userId}" } { text: 'Issues assigned to me', url: "#{issuesPath}/?assignee_id=#{userId}" }
{ text: "Issues I've created", url: "#{issuesPath}/?author_id=#{userId}" } { text: "Issues I've created", url: "#{issuesPath}/?author_id=#{userId}" }
'separator' 'separator'
...@@ -150,6 +152,10 @@ class @SearchAutocomplete ...@@ -150,6 +152,10 @@ class @SearchAutocomplete
{ text: "Merge requests I've created", url: "#{mrPath}/?author_id=#{userId}" } { text: "Merge requests I've created", url: "#{mrPath}/?author_id=#{userId}" }
] ]
items.splice 0, 1 unless name
return items
serializeState: -> serializeState: ->
{ {
...@@ -238,8 +244,7 @@ class @SearchAutocomplete ...@@ -238,8 +244,7 @@ class @SearchAutocomplete
@isFocused = true @isFocused = true
@wrap.addClass('search-active') @wrap.addClass('search-active')
if @hasLocationBadge() and @getValue() is '' @getData() if @getValue() is ''
@getData()
getValue: -> return @searchInput.val() getValue: -> return @searchInput.val()
......
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