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 )
|
||||
|
||||
remove: (e) =>
|
||||
remove: (e, key = false, force = false) =>
|
||||
e.preventDefault()
|
||||
key = $(e.target).parent().data('key')
|
||||
if !key
|
||||
key = $(e.target).parent().data('key')
|
||||
if !key
|
||||
throw "No such key attributes found for task item"
|
||||
|
||||
# check if input has changed
|
||||
worker = App.TaskManager.worker( key )
|
||||
if worker && worker.changed
|
||||
if !force && worker && 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
|
||||
currentTask = App.TaskManager.get( key )
|
||||
|
@ -162,4 +167,26 @@ class App.TaskWidget extends App.Controller
|
|||
level1.push item
|
||||
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' )
|
||||
|
|
|
@ -76,11 +76,15 @@ class AgentUserManageTest < TestCase
|
|||
:execute => 'click',
|
||||
:css => '.taskbar span[data-type="close"]',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
:value => 1,
|
||||
},
|
||||
|
||||
# accept task close warning
|
||||
{
|
||||
:execute => 'accept',
|
||||
:element => :alert,
|
||||
:execute => 'click',
|
||||
:css => '.modal .submit',
|
||||
},
|
||||
{
|
||||
:execute => 'wait',
|
||||
|
|
|
@ -160,8 +160,8 @@ class TestCase < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def browser_element_action(test, action, instance)
|
||||
#puts "NOTICE: " + action.inspect
|
||||
if action[:css]
|
||||
# puts "NOTICE: css #{ action[:css] }"
|
||||
begin
|
||||
if action[:range] == 'all'
|
||||
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]}" )
|
||||
end
|
||||
elsif action[:element] == :alert
|
||||
puts "laalal"
|
||||
element = instance.switch_to.alert
|
||||
elsif action[:execute] == 'close_all_tasks'
|
||||
while true
|
||||
|
@ -215,16 +214,12 @@ puts "laalal"
|
|||
dropdown = Selenium::WebDriver::Support::Select.new(element)
|
||||
dropdown.select_by(:text, action[:value])
|
||||
elsif action[:execute] == 'click'
|
||||
|
||||
# ignore alert clicks on safari / not supported
|
||||
if action[:element] != :alert || ( action[:element] == :alert && ENV['BROWSER'] !~ /safari/i )
|
||||
if element.class == Array
|
||||
element.each {|item|
|
||||
item.click
|
||||
}
|
||||
else
|
||||
element.click
|
||||
end
|
||||
if element.class == Array
|
||||
element.each {|item|
|
||||
item.click
|
||||
}
|
||||
else
|
||||
element.click
|
||||
end
|
||||
elsif action[:execute] == 'accept'
|
||||
element.accept
|
||||
|
|
Loading…
Reference in a new issue