diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2016-03-31 19:31:01 -0500 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-03-31 19:31:01 -0500 |
commit | 824fecb728ae7534b8ef56aaa6679814f3924cd5 (patch) | |
tree | e386ec3f8a50ae15fd0a2c39e3643db2bf5523bf /app/assets/javascripts/search_autocomplete.js.coffee | |
parent | ab42560ea6c2fade09b8436a893bf4a269e67c39 (diff) | |
download | gitlab-ce-824fecb728ae7534b8ef56aaa6679814f3924cd5.tar.gz |
Bring back search context when chosing the same project/group
Diffstat (limited to 'app/assets/javascripts/search_autocomplete.js.coffee')
-rw-r--r-- | app/assets/javascripts/search_autocomplete.js.coffee | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/app/assets/javascripts/search_autocomplete.js.coffee b/app/assets/javascripts/search_autocomplete.js.coffee index 2656c6e30a2..564fb265b9d 100644 --- a/app/assets/javascripts/search_autocomplete.js.coffee +++ b/app/assets/javascripts/search_autocomplete.js.coffee @@ -104,6 +104,8 @@ class @SearchAutocomplete lastCategory = suggestion.category data.push + id: "#{suggestion.category.toLowerCase()}-#{suggestion.id}" + category: suggestion.category text: suggestion.label url: suggestion.url @@ -271,8 +273,27 @@ class @SearchAutocomplete </ul>" @dropdownContent.html(html) - onClick: (item, e) -> + onClick: (item, $el, e) -> if location.pathname.indexOf(item.url) isnt -1 e.preventDefault() + if not @badgePresent + if item.category is 'Projects' + @projectInputEl.val(item.id) + @addLocationBadge( + value: 'This project' + ) + + if item.category is 'Groups' + @groupInputEl.val(item.id) + @addLocationBadge( + value: 'This group' + ) + + $el.removeClass('is-active') @disableAutocomplete() - @searchInput.val('') + @searchInput.val('').focus() + + # We need to wait because of @skipBlurEvent + setTimeout( => + @onSearchInputFocus() + , 200) |