|
@@ -15,7 +15,7 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|
|
'focus #global-search': 'searchFocus'
|
|
|
'blur #global-search': 'searchBlur'
|
|
|
'keyup #global-search': 'listNavigate'
|
|
|
- 'click .js-global-search-result': 'andClose'
|
|
|
+ 'click .js-global-search-result': 'emptyAndClose'
|
|
|
'click .js-details-link': 'openExtendedSearch'
|
|
|
'change .js-menu .js-switch input': 'switch'
|
|
|
|
|
@@ -156,31 +156,31 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|
|
type: 'personal'
|
|
|
)
|
|
|
|
|
|
- renderResult: (result = []) =>
|
|
|
+ renderResult: (result = [], noChange) =>
|
|
|
+ if noChange
|
|
|
+ return
|
|
|
|
|
|
- # remove result if not result exists
|
|
|
+ # show no results placeholder if no result exists
|
|
|
if _.isEmpty(result)
|
|
|
- @searchContainer.removeClass('open')
|
|
|
- @globalSearch.close()
|
|
|
- @searchResult.html('')
|
|
|
+ @searchContainer.addClass('no-match')
|
|
|
+ @searchResult.html(App.view('navigation/no_result')())
|
|
|
return
|
|
|
|
|
|
+ @searchContainer.removeClass('no-match')
|
|
|
+
|
|
|
# build markup
|
|
|
html = App.view('navigation/result')(
|
|
|
result: result
|
|
|
)
|
|
|
@searchResult.html(html)
|
|
|
|
|
|
- # show result list
|
|
|
- @searchContainer.addClass('open')
|
|
|
-
|
|
|
# start ticket popups
|
|
|
@ticketPopups()
|
|
|
|
|
|
# start user popups
|
|
|
@userPopups()
|
|
|
|
|
|
- # start oorganization popups
|
|
|
+ # start organization popups
|
|
|
@organizationPopups()
|
|
|
|
|
|
render: ->
|
|
@@ -205,26 +205,22 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|
|
|
|
|
searchFocus: (e) =>
|
|
|
@query = '' # reset query cache
|
|
|
- @searchContainer.addClass('focused')
|
|
|
@anyPopoversDestroy()
|
|
|
- @search()
|
|
|
+ @searchContainer.addClass('focused')
|
|
|
|
|
|
searchBlur: (e) =>
|
|
|
-
|
|
|
# delay to be able to click x
|
|
|
update = =>
|
|
|
query = @searchInput.val().trim()
|
|
|
if !query
|
|
|
@emptyAndClose()
|
|
|
return
|
|
|
- @searchContainer.removeClass('focused')
|
|
|
|
|
|
@delay(update, 100, 'removeFocused')
|
|
|
|
|
|
listNavigate: (e) =>
|
|
|
if e.keyCode is 27 # close on esc
|
|
|
@emptyAndClose()
|
|
|
- @searchInput.blur()
|
|
|
return
|
|
|
else if e.keyCode is 38 # up
|
|
|
@nudge(e, -1)
|
|
@@ -233,14 +229,13 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|
|
@nudge(e, 1)
|
|
|
return
|
|
|
else if e.keyCode is 13 # enter
|
|
|
- if @$('.global-search-menu .js-details-link.is-hover').get(0)
|
|
|
- @openExtendedSearch()
|
|
|
- return
|
|
|
+ @searchInput.blur()
|
|
|
href = @$('.global-search-result .nav-tab.is-hover').attr('href')
|
|
|
- return if !href
|
|
|
- @navigate(href)
|
|
|
+ if href
|
|
|
+ @navigate(href)
|
|
|
+ else
|
|
|
+ @openExtendedSearch()
|
|
|
@emptyAndClose()
|
|
|
- @searchInput.blur()
|
|
|
return
|
|
|
|
|
|
# on other keys, show result
|
|
@@ -284,25 +279,33 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|
|
@scrollToIfNeeded(prev, false)
|
|
|
|
|
|
emptyAndClose: =>
|
|
|
+ @query = ''
|
|
|
@searchInput.val('')
|
|
|
- @searchContainer.removeClass('filled').removeClass('open').removeClass('focused')
|
|
|
+ @searchContainer.removeClass('focused filled open no-match')
|
|
|
@globalSearch.close()
|
|
|
-
|
|
|
- # remove not needed popovers
|
|
|
@delay(@anyPopoversDestroy, 100, 'removePopovers')
|
|
|
|
|
|
andClose: =>
|
|
|
+ @query = ''
|
|
|
@searchInput.blur()
|
|
|
- @searchContainer.removeClass('open')
|
|
|
+ @searchContainer.removeClass('open no-match')
|
|
|
@globalSearch.close()
|
|
|
@delay(@anyPopoversDestroy, 100, 'removePopovers')
|
|
|
|
|
|
search: =>
|
|
|
query = @searchInput.val().trim()
|
|
|
- return if !query
|
|
|
- return if query is @query
|
|
|
+ @searchContainer.toggleClass('filled', !!query)
|
|
|
+ # if we started a new search and already typed something in
|
|
|
+ if @query == '' and query != ''
|
|
|
+ @searchContainer.addClass('open no-match')
|
|
|
+ @searchResult.html(App.view('navigation/search_placeholder')())
|
|
|
+
|
|
|
@query = query
|
|
|
- @searchContainer.toggleClass('filled', !!@query)
|
|
|
+
|
|
|
+ if @query == ''
|
|
|
+ @searchContainer.removeClass('open')
|
|
|
+ return
|
|
|
+
|
|
|
@globalSearch.search(query: @query)
|
|
|
|
|
|
filterNavbar: (values, user, parent = null) ->
|
|
@@ -402,11 +405,11 @@ class App.Navigation extends App.ControllerWidgetPermanent
|
|
|
url = params.url
|
|
|
type = params.type
|
|
|
if type is 'menu'
|
|
|
- @$('.js-menu .is-active, .js-details-link.is-active').removeClass('is-active')
|
|
|
+ @$('.js-menu .is-active').removeClass('is-active')
|
|
|
else
|
|
|
@$('.is-active').removeClass('is-active')
|
|
|
return if !url || url is '#'
|
|
|
- @$("[href=\"#{url}\"]").addClass('is-active')
|
|
|
+ @$(".js-menu [href=\"#{url}\"], .tasks [href=\"#{url}\"]").addClass('is-active')
|
|
|
|
|
|
recentViewNavbarItemsRebuild: =>
|
|
|
|