Moved from confirm() to modal dialog to support safari.
This commit is contained in:
parent
4d321a996c
commit
da25d45db4
3 changed files with 44 additions and 18 deletions
|
@ -99,17 +99,22 @@ class App.TaskWidget extends App.Controller
|
||||||
|
|
||||||
@el.find( '.taskbar' ).sortable( dndOptions )
|
@el.find( '.taskbar' ).sortable( dndOptions )
|
||||||
|
|
||||||
remove: (e) =>
|
remove: (e, key = false, force = false) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
key = $(e.target).parent().data('key')
|
if !key
|
||||||
|
key = $(e.target).parent().data('key')
|
||||||
if !key
|
if !key
|
||||||
throw "No such key attributes found for task item"
|
throw "No such key attributes found for task item"
|
||||||
|
|
||||||
# check if input has changed
|
# check if input has changed
|
||||||
worker = App.TaskManager.worker( key )
|
worker = App.TaskManager.worker( key )
|
||||||
if worker && worker.changed
|
if !force && worker && worker.changed
|
||||||
if worker.changed()
|
if worker.changed()
|
||||||
return if !window.confirm( App.i18n.translateInline('Tab has changed, you really want to close it?') )
|
new Remove(
|
||||||
|
key: key
|
||||||
|
ui: @
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
# check if active task is closed
|
# check if active task is closed
|
||||||
currentTask = App.TaskManager.get( key )
|
currentTask = App.TaskManager.get( key )
|
||||||
|
@ -162,4 +167,26 @@ class App.TaskWidget extends App.Controller
|
||||||
level1.push item
|
level1.push item
|
||||||
level1
|
level1
|
||||||
|
|
||||||
|
class Remove extends App.ControllerModal
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
@render()
|
||||||
|
|
||||||
|
render: ->
|
||||||
|
# return if !window.confirm( App.i18n.translateInline('Tab has changed, you really want to close it?') )
|
||||||
|
@html App.view('modal')(
|
||||||
|
title: 'Confirm'
|
||||||
|
message: 'Tab has changed, you really want to close it?'
|
||||||
|
close: true
|
||||||
|
button: 'Close'
|
||||||
|
)
|
||||||
|
@modalShow(
|
||||||
|
backdrop: true,
|
||||||
|
keyboard: true,
|
||||||
|
)
|
||||||
|
|
||||||
|
submit: (e) =>
|
||||||
|
@modalHide()
|
||||||
|
@ui.remove(e, @key, true)
|
||||||
|
|
||||||
App.Config.set( 'task', App.TaskWidget, 'Widgets' )
|
App.Config.set( 'task', App.TaskWidget, 'Widgets' )
|
||||||
|
|
|
@ -76,11 +76,15 @@ class AgentUserManageTest < TestCase
|
||||||
:execute => 'click',
|
:execute => 'click',
|
||||||
:css => '.taskbar span[data-type="close"]',
|
:css => '.taskbar span[data-type="close"]',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
:execute => 'wait',
|
||||||
|
:value => 1,
|
||||||
|
},
|
||||||
|
|
||||||
# accept task close warning
|
# accept task close warning
|
||||||
{
|
{
|
||||||
:execute => 'accept',
|
:execute => 'click',
|
||||||
:element => :alert,
|
:css => '.modal .submit',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
:execute => 'wait',
|
:execute => 'wait',
|
||||||
|
|
|
@ -160,8 +160,8 @@ class TestCase < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
def browser_element_action(test, action, instance)
|
def browser_element_action(test, action, instance)
|
||||||
|
#puts "NOTICE: " + action.inspect
|
||||||
if action[:css]
|
if action[:css]
|
||||||
# puts "NOTICE: css #{ action[:css] }"
|
|
||||||
begin
|
begin
|
||||||
if action[:range] == 'all'
|
if action[:range] == 'all'
|
||||||
element = instance.find_elements( { :css => action[:css] } )
|
element = instance.find_elements( { :css => action[:css] } )
|
||||||
|
@ -183,7 +183,6 @@ class TestCase < Test::Unit::TestCase
|
||||||
assert( false, "(#{test[:name]}) url #{instance.current_url} is not matching #{action[:result]}" )
|
assert( false, "(#{test[:name]}) url #{instance.current_url} is not matching #{action[:result]}" )
|
||||||
end
|
end
|
||||||
elsif action[:element] == :alert
|
elsif action[:element] == :alert
|
||||||
puts "laalal"
|
|
||||||
element = instance.switch_to.alert
|
element = instance.switch_to.alert
|
||||||
elsif action[:execute] == 'close_all_tasks'
|
elsif action[:execute] == 'close_all_tasks'
|
||||||
while true
|
while true
|
||||||
|
@ -215,16 +214,12 @@ puts "laalal"
|
||||||
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
||||||
dropdown.select_by(:text, action[:value])
|
dropdown.select_by(:text, action[:value])
|
||||||
elsif action[:execute] == 'click'
|
elsif action[:execute] == 'click'
|
||||||
|
if element.class == Array
|
||||||
# ignore alert clicks on safari / not supported
|
element.each {|item|
|
||||||
if action[:element] != :alert || ( action[:element] == :alert && ENV['BROWSER'] !~ /safari/i )
|
item.click
|
||||||
if element.class == Array
|
}
|
||||||
element.each {|item|
|
else
|
||||||
item.click
|
element.click
|
||||||
}
|
|
||||||
else
|
|
||||||
element.click
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
elsif action[:execute] == 'accept'
|
elsif action[:execute] == 'accept'
|
||||||
element.accept
|
element.accept
|
||||||
|
|
Loading…
Reference in a new issue