diff --git a/app/assets/javascripts/app/controllers/navigation.js.coffee b/app/assets/javascripts/app/controllers/navigation.js.coffee index fd2758962..a119fabf3 100644 --- a/app/assets/javascripts/app/controllers/navigation.js.coffee +++ b/app/assets/javascripts/app/controllers/navigation.js.coffee @@ -10,7 +10,8 @@ class App.Navigation extends App.Controller # rerender view @bind 'ui:rerender', (data) => - @render() + @renderMenu() + @renderPersonal() # update selected item @bind 'navupdate', (data) => @@ -26,14 +27,10 @@ class App.Navigation extends App.Controller @render() - # remember ticket overview data - @bind 'navupdate_ticket_overview', (data) => - App.Store.write( 'navupdate_ticket_overview', data ) - # rebuild recent viewed data @bind 'update_recent_viewed', (data) => @recent_viewed_build(data) - @render() + @renderPersonal() # bell on / bell off @bind 'bell', (data) => @@ -47,6 +44,51 @@ class App.Navigation extends App.Controller else @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-menu').html App.view('navigation/menu')( + items: items + open_tab: open_tab + active_tab: active_tab + ) + + renderPersonal: => + 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-personal').html App.view('navigation/personal')( + items: items + open_tab: open_tab + active_tab: active_tab + ) + renderResult: (result = []) => el = @el.find('#global-search-result') @@ -78,38 +120,25 @@ class App.Navigation extends App.Controller @organizationPopups() render: () -> - user = App.Session.all() - nav_left = @getItems( navbar: @Config.get( 'NavBar' ) ) - nav_right = @getItems( navbar: @Config.get( 'NavBarRight' ) ) # remove old popovers $('.popover').remove() - # 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 - ) - + # remember old search query search = @el.find('#global-search').val() + + user = App.Session.all() @html App.view('navigation')( - navbar_left: nav_left - navbar_right: nav_right - open_tab: open_tab - active_tab: active_tab user: user - result: @result || [] search: search ) + # renderMenu + @renderMenu() + + # renderPersonal + @renderPersonal() + # set focus to search box if @searchFocus @searchFocusSet = true @@ -334,7 +363,7 @@ class App.Navigation extends App.Controller delete NavBarRight[key] # add new views - items = data.recent_viewed + items = data.recent_viewed || [] items = @prepareForObjectList(items) prio = 8000 for item in items diff --git a/app/assets/javascripts/app/views/navigation.jst.eco b/app/assets/javascripts/app/views/navigation.jst.eco index 32bb26f56..2fc7d29dc 100644 --- a/app/assets/javascripts/app/views/navigation.jst.eco +++ b/app/assets/javascripts/app/views/navigation.jst.eco @@ -6,106 +6,15 @@ - + - +
<% if !_.isEmpty(@user): %> - -<% else: %> - -<% end %> + +<% end %> \ No newline at end of file diff --git a/app/assets/javascripts/app/views/navigation/menu.jst.eco b/app/assets/javascripts/app/views/navigation/menu.jst.eco new file mode 100644 index 000000000..c8824fe7d --- /dev/null +++ b/app/assets/javascripts/app/views/navigation/menu.jst.eco @@ -0,0 +1,31 @@ +<% for item in @items: %> + <% if item.child: %> + + <% else: %> +
  • + + + + + + <%- @T( item.name ) %> + + +
  • + <% end %> +<% end %> \ No newline at end of file diff --git a/app/assets/javascripts/app/views/navigation/personal.jst.eco b/app/assets/javascripts/app/views/navigation/personal.jst.eco new file mode 100644 index 000000000..a4475ba0a --- /dev/null +++ b/app/assets/javascripts/app/views/navigation/personal.jst.eco @@ -0,0 +1,39 @@ +<% for item in @items: %> + <% if item.child: %> +
  • + + + <% if item.class is 'user': %> + + <% else: %> + + + <% end %> + + +
  • + <% else: %> +
  • + + + + +
  • + <% end %> +<% end %> \ No newline at end of file diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 4c699a15a..433237f6e 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -21,7 +21,7 @@ class ApplicationModel < ActiveRecord::Base after_create :activity_stream_create after_update :activity_stream_update - after_destroy :activity_stream_destroy + before_destroy :activity_stream_destroy after_create :history_create after_update :history_update @@ -31,7 +31,7 @@ class ApplicationModel < ActiveRecord::Base after_update :search_index_update after_destroy :search_index_destroy - after_destroy :recent_view_destroy + before_destroy :recent_view_destroy # create instance accessor class << self diff --git a/app/models/recent_view.rb b/app/models/recent_view.rb index e670d6f4b..201274f6d 100644 --- a/app/models/recent_view.rb +++ b/app/models/recent_view.rb @@ -22,9 +22,10 @@ class RecentView < ApplicationModel end def self.log_destroy( requested_object, requested_object_id ) + return if requested_object == 'RecentView' RecentView.where( :recent_view_object_id => ObjectLookup.by_name( requested_object ) ). - where( :o_id => requested_object_id ). - destroy_all + where( :o_id => requested_object_id ). + destroy_all end def self.user_log_destroy( user )