Use direct click in personal navigation area if only one entry exists.

This commit is contained in:
Martin Edenhofer 2018-03-06 06:30:12 +01:00
parent b91fceff08
commit 7e1b25468f
11 changed files with 27 additions and 18 deletions

View file

@ -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')

View file

@ -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) ->

View file

@ -1,12 +1,12 @@
<% for item in @items: %>
<% if item.child: %>
<% if !_.isEmpty(item.child): %>
<li class="<% if item.class: %><%- item.class %><% end %> dropup <% if @openTab[item.target] : %>open<% end %>">
<a class="list-button dropdown-toggle js-action" data-toggle="dropdown" href="<%= item.target %>" title="<% if item.translate: %><%- @Ti(item.name) %><% else: %><%= item.name %><% end %>">
<span class="dropdown-nose"></span>
<% if item.class is 'user': %>
<span class="js-avatar"></span>
<% else: %>
<%- @Icon('plus', 'user-menu-icon') %>
<%- @Icon(item.icon, 'user-menu-icon') %>
<% end %>
</a>
<ul class="dropdown-menu dropdown-menu--light" role="menu">

View file

@ -151,7 +151,7 @@ class AgentTicketActionLevel0Test < TestCase
)
# customer ticket create
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#customer_ticket_new"]')
watch_for(

View file

@ -11,7 +11,7 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
)
tasks_close_all()
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#ticket/create"]')
sleep 2
@ -92,7 +92,7 @@ class AgentTicketCreateResetCustomerSelectionTest < TestCase
)
tasks_close_all()
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#ticket/create"]')
sleep 2

View file

@ -31,7 +31,7 @@ class AgentTicketTextModuleTest < TestCase
)
# try to use them
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#ticket/create"]')
sleep 2

View file

@ -19,7 +19,7 @@ class AgentUserManageTest < TestCase
sleep 1
# create customer
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#ticket/create"]')
click(css: '.active .newTicket [name="customer_id_completion"]')
@ -75,7 +75,7 @@ class AgentUserManageTest < TestCase
# call new ticket screen again
tasks_close_all()
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#ticket/create"]')
sleep 2

View file

@ -11,7 +11,7 @@ class CustomerTicketCreateTest < TestCase
)
# customer ticket create
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#customer_ticket_new"]')
sleep 2

View file

@ -12,7 +12,7 @@ class TaskbarTaskTest < TestCase
tasks_close_all()
# persistant task
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#ticket/create"]', wait: 0.8)
set(
css: '.active .newTicket input[name="title"]',
@ -52,7 +52,7 @@ class TaskbarTaskTest < TestCase
)
tasks_close_all()
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#ticket/create"]', wait: 0.8)
set(
css: '.active .newTicket input[name="title"]',
@ -64,7 +64,7 @@ class TaskbarTaskTest < TestCase
)
sleep 2
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#ticket/create"]', wait: 0.8)
set(
css: '.active .newTicket input[name="title"]',

View file

@ -29,7 +29,7 @@ class UserSwitchCache < TestCase
password: 'test',
url: browser_url,
)
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#customer_ticket_new"]')
sleep 4
@ -58,7 +58,7 @@ class UserSwitchCache < TestCase
password: 'test',
url: browser_url,
)
click(css: 'a[href="#new"]')
click(css: 'a[href="#new"]', only_if_exists: true)
click(css: 'a[href="#customer_ticket_new"]')
sleep 4

View file

@ -420,6 +420,7 @@ class TestCase < Test::Unit::TestCase
begin
element = instance.find_elements(css: params[:css])[0]
return if !element && params[:only_if_exists] == true
#if element
# instance.mouse.move_to(element)
#end
@ -430,6 +431,7 @@ class TestCase < Test::Unit::TestCase
# just try again
log('click', { rescure: true })
element = instance.find_elements(css: params[:css])[0]
return if !element && params[:only_if_exists] == true
#if element
# instance.mouse.move_to(element)
#end
@ -1829,6 +1831,7 @@ wait untill text in selector disabppears
browser: instance,
css: 'a[href="#new"]',
mute_log: true,
only_if_exists: true,
)
click(
browser: instance,