Improved tag widget.

This commit is contained in:
Martin Edenhofer 2016-09-13 00:14:10 +02:00
parent f0c4c2f68a
commit 6adae4ed6b
3 changed files with 32 additions and 11 deletions

View file

@ -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,14 +76,14 @@ 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) =>
if e
e.preventDefault()
item = @$('[name="new_tag"]').val().trim()
if !item
@ -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()

View file

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

View file

@ -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|
if element
element.send_keys(key)
else
instance.action.send_keys(key).perform
end
}
screenshot(browser: instance, comment: 'sendkey_after')
return
end
if element
element.send_keys(params[:value])
else
instance.action.send_keys(params[:value]).perform
end
if params[:slow]
sleep 1.5
else