Improved live search.
This commit is contained in:
parent
b2f2839b97
commit
2fe7fe4bfd
3 changed files with 41 additions and 54 deletions
|
@ -15,20 +15,15 @@ class App.Navigation extends App.Controller
|
||||||
@bind 'auth', (user) =>
|
@bind 'auth', (user) =>
|
||||||
@log 'Navigation', 'notice', 'navbar rebuild', user
|
@log 'Navigation', 'notice', 'navbar rebuild', user
|
||||||
|
|
||||||
if !_.isEmpty( user )
|
|
||||||
cache = App.Store.get( 'navupdate_ticket_overview' )
|
|
||||||
@ticket_overview_build( cache ) if cache
|
|
||||||
|
|
||||||
if !_.isEmpty( user )
|
if !_.isEmpty( user )
|
||||||
cache = App.Store.get( 'update_recent_viewed' )
|
cache = App.Store.get( 'update_recent_viewed' )
|
||||||
@recent_viewed_build( cache ) if cache
|
@recent_viewed_build( cache ) if cache
|
||||||
|
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
# rebuild ticket overview data
|
# remember ticket overview data
|
||||||
@bind 'navupdate_ticket_overview', (data) =>
|
@bind 'navupdate_ticket_overview', (data) =>
|
||||||
@ticket_overview_build(data)
|
App.Store.write( 'navupdate_ticket_overview', data )
|
||||||
@render()
|
|
||||||
|
|
||||||
# rebuild recent viewed data
|
# rebuild recent viewed data
|
||||||
@bind 'update_recent_viewed', (data) =>
|
@bind 'update_recent_viewed', (data) =>
|
||||||
|
@ -47,6 +42,33 @@ class App.Navigation extends App.Controller
|
||||||
else
|
else
|
||||||
@el.find('.bell').removeClass('show')
|
@el.find('.bell').removeClass('show')
|
||||||
|
|
||||||
|
renderResult: (result = []) =>
|
||||||
|
el = @el.find('#global-search-result')
|
||||||
|
|
||||||
|
# remove result if not result exists
|
||||||
|
if _.isEmpty( result )
|
||||||
|
@el.find('#global-search').parents('li').removeClass('open')
|
||||||
|
el.html( '' )
|
||||||
|
return
|
||||||
|
|
||||||
|
# show result list
|
||||||
|
@el.find('#global-search').parents('li').addClass('open')
|
||||||
|
|
||||||
|
# build markup
|
||||||
|
html = App.view('navigation/result')(
|
||||||
|
result: result
|
||||||
|
)
|
||||||
|
el.html( html )
|
||||||
|
|
||||||
|
# start ticket popups
|
||||||
|
@ticketPopups('left')
|
||||||
|
|
||||||
|
# start user popups
|
||||||
|
@userPopups('left')
|
||||||
|
|
||||||
|
# start oorganization popups
|
||||||
|
@organizationPopups('left')
|
||||||
|
|
||||||
render: () ->
|
render: () ->
|
||||||
user = App.Session.all()
|
user = App.Session.all()
|
||||||
nav_left = @getItems( navbar: @Config.get( 'NavBar' ) )
|
nav_left = @getItems( navbar: @Config.get( 'NavBar' ) )
|
||||||
|
@ -77,15 +99,6 @@ class App.Navigation extends App.Controller
|
||||||
search: search
|
search: search
|
||||||
)
|
)
|
||||||
|
|
||||||
# start ticket popups
|
|
||||||
@ticketPopups('left')
|
|
||||||
|
|
||||||
# start user popups
|
|
||||||
@userPopups('left')
|
|
||||||
|
|
||||||
# start oorganization popups
|
|
||||||
@organizationPopups('left')
|
|
||||||
|
|
||||||
# set focus to search box
|
# set focus to search box
|
||||||
if @searchFocus
|
if @searchFocus
|
||||||
@searchFocusSet = true
|
@searchFocusSet = true
|
||||||
|
@ -107,8 +120,8 @@ class App.Navigation extends App.Controller
|
||||||
# load assets
|
# load assets
|
||||||
App.Collection.loadAssets( data.assets )
|
App.Collection.loadAssets( data.assets )
|
||||||
|
|
||||||
@result = data.result
|
result = data.result
|
||||||
for area in @result
|
for area in result
|
||||||
if area.name is 'Ticket'
|
if area.name is 'Ticket'
|
||||||
area.result = []
|
area.result = []
|
||||||
for id in area.ids
|
for id in area.ids
|
||||||
|
@ -141,8 +154,7 @@ class App.Navigation extends App.Controller
|
||||||
url: organization.uiUrl()
|
url: organization.uiUrl()
|
||||||
area.result.push data
|
area.result.push data
|
||||||
|
|
||||||
if @result
|
@renderResult(result)
|
||||||
@render(user)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# observer search box
|
# observer search box
|
||||||
|
@ -163,8 +175,7 @@ class App.Navigation extends App.Controller
|
||||||
@delay(
|
@delay(
|
||||||
=>
|
=>
|
||||||
@searchFocus = false
|
@searchFocus = false
|
||||||
@result = []
|
@renderResult()
|
||||||
@render(user)
|
|
||||||
320
|
320
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -274,29 +285,6 @@ class App.Navigation extends App.Controller
|
||||||
@el.find('li').removeClass('active')
|
@el.find('li').removeClass('active')
|
||||||
@el.find("[href=\"#{url}\"]").parents('li').addClass('active')
|
@el.find("[href=\"#{url}\"]").parents('li').addClass('active')
|
||||||
|
|
||||||
ticket_overview_build: (data) =>
|
|
||||||
App.Store.write( 'navupdate_ticket_overview', data )
|
|
||||||
return
|
|
||||||
|
|
||||||
# remove old views
|
|
||||||
NavBar = @Config.get( 'NavBar' ) || {}
|
|
||||||
for key of NavBar
|
|
||||||
if NavBar[key].parent is '#ticket/view'
|
|
||||||
delete NavBar[key]
|
|
||||||
|
|
||||||
# add new views
|
|
||||||
for item in data
|
|
||||||
NavBar['TicketOverview' + item.link] = {
|
|
||||||
prio: item.prio,
|
|
||||||
parent: '#ticket_view',
|
|
||||||
name: item.name,
|
|
||||||
count: item.count,
|
|
||||||
target: '#ticket_view/' + item.link,
|
|
||||||
# role: ['Agent', 'Customer'],
|
|
||||||
}
|
|
||||||
|
|
||||||
@Config.set( 'NavBar', NavBar )
|
|
||||||
|
|
||||||
recent_viewed_build: (data) =>
|
recent_viewed_build: (data) =>
|
||||||
|
|
||||||
App.Store.write( 'update_recent_viewed', data )
|
App.Store.write( 'update_recent_viewed', data )
|
||||||
|
|
|
@ -27,18 +27,11 @@
|
||||||
<% if !_.isEmpty(@user): %>
|
<% if !_.isEmpty(@user): %>
|
||||||
<ul class="nav navbar-nav pull-right">
|
<ul class="nav navbar-nav pull-right">
|
||||||
|
|
||||||
<li class="dropdown <% if @result[0] : %>open<% end %>">
|
<li class="dropdown">
|
||||||
<form class="navbar-form">
|
<form class="navbar-form">
|
||||||
<input id="global-search" class="form-control" type="search" value="<%= @search %>" placeholder="<%- @Ti( 'Search' ) %>" autocomplete="off"/>
|
<input id="global-search" class="form-control" type="search" value="<%= @search %>" placeholder="<%- @Ti( 'Search' ) %>" autocomplete="off"/>
|
||||||
</form>
|
</form>
|
||||||
<ul class="dropdown-menu">
|
<ul id="global-search-result" class="dropdown-menu"></ul>
|
||||||
<% for area in @result: %>
|
|
||||||
<li class="divider" style="padding: 2px 10px; height: auto; margin: 4px 0px;"><%- @T( area.name ) %></li>
|
|
||||||
<% for item in area.result: %>
|
|
||||||
<li><a href="<%- item.url %>" class="<%= item.class %>" data-id="<%= item.id %>"><%= item.display %></a></li>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="bell"><a href="#bell" class="glyphicon glyphicon-bell"></a></li>
|
<li class="bell"><a href="#bell" class="glyphicon glyphicon-bell"></a></li>
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<% for area in @result: %>
|
||||||
|
<li class="divider" style="padding: 2px 10px; height: auto; margin: 4px 0px;"><%- @T( area.name ) %></li>
|
||||||
|
<% for item in area.result: %>
|
||||||
|
<li><a href="<%- item.url %>" class="<%= item.class %>" data-id="<%= item.id %>"><%= item.display %></a></li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
Loading…
Reference in a new issue