From 7e1b25468f7f9180a64cd7227b66bc36e20acf1d Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 6 Mar 2018 06:30:12 +0100 Subject: [PATCH] Use direct click in personal navigation area if only one entry exists. --- .../javascripts/app/controllers/_default_navbar.coffee | 2 +- .../javascripts/app/controllers/navigation.coffee | 6 ++++++ .../javascripts/app/views/navigation/personal.jst.eco | 10 +++++----- test/browser/abb_one_group_test.rb | 2 +- ...gent_ticket_create_reset_customer_selection_test.rb | 4 ++-- test/browser/agent_ticket_text_module_test.rb | 2 +- test/browser/agent_user_manage_test.rb | 4 ++-- test/browser/customer_ticket_create_test.rb | 2 +- test/browser/taskbar_task_test.rb | 6 +++--- test/browser/user_switch_cache_test.rb | 4 ++-- test/browser_test_helper.rb | 3 +++ 11 files changed, 27 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_default_navbar.coffee b/app/assets/javascripts/app/controllers/_default_navbar.coffee index 2cf205da8..27ad1cfc6 100644 --- a/app/assets/javascripts/app/controllers/_default_navbar.coffee +++ b/app/assets/javascripts/app/controllers/_default_navbar.coffee @@ -11,7 +11,7 @@ App.Config.set('User', { }, 'NavBarRight' ) App.Config.set('Admin', { prio: 9000, parent: '', name: 'Admin', translate: true, target: '#manage', icon: 'cog', permission: ['admin.*'] }, 'NavBarRight') -App.Config.set('New', { prio: 20000, parent: '', name: 'New', translate: true, target: '#new', class: 'add' }, 'NavBarRight') +App.Config.set('New', { prio: 20000, parent: '', name: 'New', translate: true, target: '#new', class: 'add', icon: 'plus' }, 'NavBarRight') App.Config.set('Misc', { prio: 90000, parent: '', name: 'Tools', translate: true, target: '#tools', child: true, class: 'tools' }, 'NavBar') # only for testing #App.Config.set('Misc1', { prio: 1600, parent: '#tools', name: 'Test 1', target: '#test1', permission: ['admin'] }, 'NavBar') diff --git a/app/assets/javascripts/app/controllers/navigation.coffee b/app/assets/javascripts/app/controllers/navigation.coffee index 77d959896..db6b0ed86 100644 --- a/app/assets/javascripts/app/controllers/navigation.coffee +++ b/app/assets/javascripts/app/controllers/navigation.coffee @@ -130,6 +130,12 @@ class App.Navigation extends App.ControllerWidgetPermanent @recentViewNavbarItemsRebuild() items = @getItems(navbar: @Config.get('NavBarRight')) + # if only one child exists, use direct access + for item in items + if item && item.child && item.child.length is 1 + item.target = item.child[0].target + delete item.child + # get open tabs to repopen on rerender openTab = {} @$('.open').children('a').each( (i,d) -> diff --git a/app/assets/javascripts/app/views/navigation/personal.jst.eco b/app/assets/javascripts/app/views/navigation/personal.jst.eco index 22377fe81..6e52b5cfd 100644 --- a/app/assets/javascripts/app/views/navigation/personal.jst.eco +++ b/app/assets/javascripts/app/views/navigation/personal.jst.eco @@ -1,12 +1,12 @@ <% for item in @items: %> - <% if item.child: %> + <% if !_.isEmpty(item.child): %>
  • - + <% if item.class is 'user': %> <% else: %> - <%- @Icon('plus', 'user-menu-icon') %> + <%- @Icon(item.icon, 'user-menu-icon') %> <% end %>