Rewrite of navigation controller to reduce re-render counter.
This commit is contained in:
parent
4f531f2ad2
commit
7ff8fe7b48
1 changed files with 59 additions and 28 deletions
|
@ -5,7 +5,8 @@ class App.Navigation extends App.Controller
|
||||||
|
|
||||||
# rerender view
|
# rerender view
|
||||||
@bind 'ui:rerender', (data) =>
|
@bind 'ui:rerender', (data) =>
|
||||||
@render()
|
@renderMenu()
|
||||||
|
@renderPrivate()
|
||||||
|
|
||||||
# update selected item
|
# update selected item
|
||||||
@bind 'navupdate', (data) =>
|
@bind 'navupdate', (data) =>
|
||||||
|
@ -21,14 +22,10 @@ class App.Navigation extends App.Controller
|
||||||
|
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
# remember ticket overview data
|
|
||||||
@bind 'navupdate_ticket_overview', (data) =>
|
|
||||||
App.Store.write( 'navupdate_ticket_overview', data )
|
|
||||||
|
|
||||||
# rebuild recent viewed data
|
# rebuild recent viewed data
|
||||||
@bind 'update_recent_viewed', (data) =>
|
@bind 'update_recent_viewed', (data) =>
|
||||||
@recent_viewed_build(data)
|
@recent_viewed_build(data)
|
||||||
@render()
|
@renderPrivate()
|
||||||
|
|
||||||
# bell on / bell off
|
# bell on / bell off
|
||||||
@bind 'bell', (data) =>
|
@bind 'bell', (data) =>
|
||||||
|
@ -42,6 +39,53 @@ class App.Navigation extends App.Controller
|
||||||
else
|
else
|
||||||
@el.find('.bell').removeClass('show')
|
@el.find('.bell').removeClass('show')
|
||||||
|
|
||||||
|
renderMenu: =>
|
||||||
|
items = @getItems( navbar: @Config.get( 'NavBar' ) )
|
||||||
|
|
||||||
|
# get open tabs to repopen on rerender
|
||||||
|
open_tab = {}
|
||||||
|
@el.find('.open').children('a').each( (i,d) =>
|
||||||
|
href = $(d).attr('href')
|
||||||
|
open_tab[href] = true
|
||||||
|
)
|
||||||
|
|
||||||
|
# get active tabs to reactivate on rerender
|
||||||
|
active_tab = {}
|
||||||
|
@el.find('.active').children('a').each( (i,d) =>
|
||||||
|
href = $(d).attr('href')
|
||||||
|
active_tab[href] = true
|
||||||
|
)
|
||||||
|
@el.find('.navbar-items-left').html App.view('navigation/menu')(
|
||||||
|
items: items
|
||||||
|
open_tab: open_tab
|
||||||
|
active_tab: active_tab
|
||||||
|
)
|
||||||
|
|
||||||
|
renderPrivate: =>
|
||||||
|
items = @getItems( navbar: @Config.get( 'NavBarRight' ) )
|
||||||
|
|
||||||
|
# get open tabs to repopen on rerender
|
||||||
|
open_tab = {}
|
||||||
|
@el.find('.open').children('a').each( (i,d) =>
|
||||||
|
href = $(d).attr('href')
|
||||||
|
open_tab[href] = true
|
||||||
|
)
|
||||||
|
|
||||||
|
# get active tabs to reactivate on rerender
|
||||||
|
active_tab = {}
|
||||||
|
@el.find('.active').children('a').each( (i,d) =>
|
||||||
|
href = $(d).attr('href')
|
||||||
|
active_tab[href] = true
|
||||||
|
)
|
||||||
|
|
||||||
|
@el.find('.navbar-items-right .navbar-private').remove()
|
||||||
|
|
||||||
|
@el.find('.navbar-items-right').append App.view('navigation/private')(
|
||||||
|
items: items
|
||||||
|
open_tab: open_tab
|
||||||
|
active_tab: active_tab
|
||||||
|
)
|
||||||
|
|
||||||
renderResult: (result = []) =>
|
renderResult: (result = []) =>
|
||||||
el = @el.find('#global-search-result')
|
el = @el.find('#global-search-result')
|
||||||
|
|
||||||
|
@ -73,38 +117,25 @@ class App.Navigation extends App.Controller
|
||||||
@organizationPopups('left')
|
@organizationPopups('left')
|
||||||
|
|
||||||
render: () ->
|
render: () ->
|
||||||
user = App.Session.all()
|
|
||||||
nav_left = @getItems( navbar: @Config.get( 'NavBar' ) )
|
|
||||||
nav_right = @getItems( navbar: @Config.get( 'NavBarRight' ) )
|
|
||||||
|
|
||||||
# remove old popovers
|
# remove old popovers
|
||||||
$('.popover').remove()
|
$('.popover').remove()
|
||||||
|
|
||||||
# get open tabs to repopen on rerender
|
# remember old search query
|
||||||
open_tab = {}
|
|
||||||
@el.find('.open').children('a').each( (i,d) =>
|
|
||||||
href = $(d).attr('href')
|
|
||||||
open_tab[href] = true
|
|
||||||
)
|
|
||||||
|
|
||||||
# get active tabs to reactivate on rerender
|
|
||||||
active_tab = {}
|
|
||||||
@el.find('.active').children('a').each( (i,d) =>
|
|
||||||
href = $(d).attr('href')
|
|
||||||
active_tab[href] = true
|
|
||||||
)
|
|
||||||
|
|
||||||
search = @el.find('#global-search').val()
|
search = @el.find('#global-search').val()
|
||||||
|
|
||||||
|
user = App.Session.all()
|
||||||
@html App.view('navigation')(
|
@html App.view('navigation')(
|
||||||
navbar_left: nav_left
|
|
||||||
navbar_right: nav_right
|
|
||||||
open_tab: open_tab
|
|
||||||
active_tab: active_tab
|
|
||||||
user: user
|
user: user
|
||||||
result: @result || []
|
|
||||||
search: search
|
search: search
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# renderMenu
|
||||||
|
@renderMenu()
|
||||||
|
|
||||||
|
# renderPrivate
|
||||||
|
@renderPrivate()
|
||||||
|
|
||||||
# set focus to search box
|
# set focus to search box
|
||||||
if @searchFocus
|
if @searchFocus
|
||||||
@searchFocusSet = true
|
@searchFocusSet = true
|
||||||
|
|
Loading…
Reference in a new issue