Improved tag widget.
This commit is contained in:
parent
f0c4c2f68a
commit
6adae4ed6b
3 changed files with 32 additions and 11 deletions
|
@ -8,8 +8,8 @@ class App.WidgetTag extends App.Controller
|
|||
|
||||
events:
|
||||
'click .js-newTagLabel': 'showInput'
|
||||
'blur .js-newTagInput': 'hideOrAddInput'
|
||||
'click .js-newTagInput': 'onAddTag'
|
||||
'blur .js-newTagInput': 'hideAndAddInput'
|
||||
'keyup .js-newTagInput': 'addInput'
|
||||
'submit form': 'onAddTag'
|
||||
'click .js-delete': 'onRemoveTag'
|
||||
'click .js-tag': 'searchTag'
|
||||
|
@ -26,6 +26,10 @@ class App.WidgetTag extends App.Controller
|
|||
|
||||
@fetch()
|
||||
|
||||
addInput: (e) =>
|
||||
return if e.keyCode isnt 9 # tab
|
||||
@hideAndAddInput()
|
||||
|
||||
fetch: =>
|
||||
@pendingRefresh = false
|
||||
@ajax(
|
||||
|
@ -72,15 +76,15 @@ class App.WidgetTag extends App.Controller
|
|||
@newTagInput.removeClass('hide').focus()
|
||||
@editMode = true
|
||||
|
||||
hideOrAddInput: (e) =>
|
||||
e.preventDefault()
|
||||
hideAndAddInput: =>
|
||||
@newTagLabel.removeClass('hide')
|
||||
@newTagInput.addClass('hide')
|
||||
@onAddTag(e)
|
||||
@onAddTag()
|
||||
@editMode = false
|
||||
|
||||
onAddTag: (e) =>
|
||||
e.preventDefault()
|
||||
if e
|
||||
e.preventDefault()
|
||||
item = @$('[name="new_tag"]').val().trim()
|
||||
if !item
|
||||
if @pendingRefresh
|
||||
|
@ -118,7 +122,6 @@ class App.WidgetTag extends App.Controller
|
|||
@remove(item)
|
||||
|
||||
remove: (item) =>
|
||||
|
||||
@localTags = _.filter(@localTags, (tagItem) -> return tagItem if tagItem isnt item)
|
||||
@render()
|
||||
|
||||
|
|
|
@ -451,6 +451,7 @@ class AgentTicketTagTest < TestCase
|
|||
body: 'some body 223äöü - tags no new 1',
|
||||
},
|
||||
)
|
||||
sleep 2
|
||||
|
||||
click(css: '.active .sidebar .js-newTagLabel')
|
||||
set(
|
||||
|
@ -459,6 +460,7 @@ class AgentTicketTagTest < TestCase
|
|||
)
|
||||
sleep 2
|
||||
sendkey(value: :tab)
|
||||
sleep 1
|
||||
click(css: '.active .sidebar .js-newTagLabel')
|
||||
set(
|
||||
css: '.active .sidebar .js-newTagInput',
|
||||
|
@ -466,6 +468,7 @@ class AgentTicketTagTest < TestCase
|
|||
)
|
||||
sleep 2
|
||||
sendkey(value: :tab)
|
||||
sleep 1
|
||||
click(css: '.active .sidebar .js-newTagLabel')
|
||||
set(
|
||||
css: '.active .sidebar .js-newTagInput',
|
||||
|
@ -473,6 +476,7 @@ class AgentTicketTagTest < TestCase
|
|||
)
|
||||
sleep 2
|
||||
sendkey(value: :tab)
|
||||
sleep 1
|
||||
click(css: '.active .sidebar .js-newTagLabel')
|
||||
set(
|
||||
css: '.active .sidebar .js-newTagInput',
|
||||
|
@ -480,6 +484,7 @@ class AgentTicketTagTest < TestCase
|
|||
)
|
||||
sleep 2
|
||||
sendkey(value: :tab)
|
||||
sleep 1
|
||||
|
||||
# verify tags
|
||||
tags_verify(
|
||||
|
|
|
@ -589,7 +589,7 @@ class TestCase < Test::Unit::TestCase
|
|||
css: '.some_class',
|
||||
value: true,
|
||||
slow: false,
|
||||
blur: true,
|
||||
blur: true, # default false
|
||||
clear: true, # todo | default: true
|
||||
no_click: true,
|
||||
)
|
||||
|
@ -793,7 +793,7 @@ class TestCase < Test::Unit::TestCase
|
|||
sendkey(
|
||||
browser: browser1,
|
||||
value: :enter,
|
||||
slow: false,
|
||||
slow: false, # default false
|
||||
)
|
||||
|
||||
=end
|
||||
|
@ -803,15 +803,28 @@ class TestCase < Test::Unit::TestCase
|
|||
log('sendkey', params)
|
||||
|
||||
instance = params[:browser] || @browser
|
||||
element = nil
|
||||
if params[:css]
|
||||
element = instance.find_elements(css: params[:css])[0]
|
||||
end
|
||||
screenshot(browser: instance, comment: 'sendkey_before')
|
||||
if params[:value].class == Array
|
||||
params[:value].each { |key|
|
||||
instance.action.send_keys(key).perform
|
||||
if element
|
||||
element.send_keys(key)
|
||||
else
|
||||
instance.action.send_keys(key).perform
|
||||
end
|
||||
}
|
||||
screenshot(browser: instance, comment: 'sendkey_after')
|
||||
return
|
||||
end
|
||||
instance.action.send_keys(params[:value]).perform
|
||||
|
||||
if element
|
||||
element.send_keys(params[:value])
|
||||
else
|
||||
instance.action.send_keys(params[:value]).perform
|
||||
end
|
||||
if params[:slow]
|
||||
sleep 1.5
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue