Improved ctrl+alt+y shortcut (2 times + subject, 3 times + subject and url).
This commit is contained in:
parent
5e090a8976
commit
075db8873a
5 changed files with 81 additions and 23 deletions
|
@ -5,10 +5,10 @@ class App.TicketZoomTitle extends App.ObserverController
|
||||||
title: true
|
title: true
|
||||||
|
|
||||||
events:
|
events:
|
||||||
'blur .ticket-title-update': 'update'
|
'blur .js-objectTitle': 'update'
|
||||||
|
|
||||||
renderPost: (object) =>
|
renderPost: (object) =>
|
||||||
@$('.ticket-title-update').ce({
|
@$('.js-objectTitle').ce({
|
||||||
mode: 'textonly'
|
mode: 'textonly'
|
||||||
multiline: false
|
multiline: false
|
||||||
maxlength: 250
|
maxlength: 250
|
||||||
|
|
|
@ -24,6 +24,12 @@ class App.KeyboardShortcutWidget extends Spine.Module
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
@observerKeys()
|
@observerKeys()
|
||||||
|
@lastKey = undefined
|
||||||
|
|
||||||
|
$(document).keyup((e) =>
|
||||||
|
return if e.keyCode isnt 27
|
||||||
|
@lastKey = undefined
|
||||||
|
)
|
||||||
|
|
||||||
observerKeys: =>
|
observerKeys: =>
|
||||||
navigationHotkeys = 'alt+ctrl'
|
navigationHotkeys = 'alt+ctrl'
|
||||||
|
@ -41,9 +47,17 @@ class App.KeyboardShortcutWidget extends Spine.Module
|
||||||
modifier += shortcut.key
|
modifier += shortcut.key
|
||||||
if shortcut.callback
|
if shortcut.callback
|
||||||
@log 'debug', 'bind for', modifier
|
@log 'debug', 'bind for', modifier
|
||||||
$(document).bind('keydown', modifier, (e) ->
|
$(document).bind('keydown', modifier, (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
shortcut.callback()
|
if @lastKey && @lastKey.modifier is modifier && @lastKey.time + 5500 > new Date().getTime()
|
||||||
|
@lastKey.count += 1
|
||||||
|
@lastKey.time = new Date().getTime()
|
||||||
|
else
|
||||||
|
@lastKey =
|
||||||
|
modifier: modifier
|
||||||
|
count: 1
|
||||||
|
time: new Date().getTime()
|
||||||
|
shortcut.callback(shortcut, @lastKey, modifier)
|
||||||
)
|
)
|
||||||
|
|
||||||
App.Event.bind('global-shortcut', (e) ->
|
App.Event.bind('global-shortcut', (e) ->
|
||||||
|
@ -51,7 +65,7 @@ class App.KeyboardShortcutWidget extends Spine.Module
|
||||||
for item in area.content
|
for item in area.content
|
||||||
for shortcut in item.shortcuts
|
for shortcut in item.shortcuts
|
||||||
if shortcut.globalEvent is e
|
if shortcut.globalEvent is e
|
||||||
shortcut.callback()
|
shortcut.callback(shortcut)
|
||||||
)
|
)
|
||||||
|
|
||||||
App.Config.set('keyboard_shortcuts', App.KeyboardShortcutWidget, 'Widgets')
|
App.Config.set('keyboard_shortcuts', App.KeyboardShortcutWidget, 'Widgets')
|
||||||
|
@ -247,10 +261,38 @@ App.Config.set(
|
||||||
key: 'y'
|
key: 'y'
|
||||||
hotkeys: true
|
hotkeys: true
|
||||||
description: 'Copy current object number (e. g. Ticket#) into clipboard'
|
description: 'Copy current object number (e. g. Ticket#) into clipboard'
|
||||||
callback: ->
|
callback: (shortcut, lastKey, modifier) ->
|
||||||
App.Event.trigger('keyboard_shortcuts_close')
|
App.Event.trigger('keyboard_shortcuts_close')
|
||||||
text = $('.active.content .js-objectNumber').data('number') || ''
|
text = $('.active.content .js-objectNumber').first().data('number') || ''
|
||||||
|
if lastKey && lastKey.count is 1
|
||||||
clipboard.copy(text)
|
clipboard.copy(text)
|
||||||
|
return
|
||||||
|
|
||||||
|
title = $('.active.content .js-objectTitle').first().text()
|
||||||
|
if lastKey && lastKey.count is 2
|
||||||
|
if title
|
||||||
|
text += ": #{title}"
|
||||||
|
clipboard.copy(text)
|
||||||
|
return
|
||||||
|
|
||||||
|
url = window.location.toString()
|
||||||
|
if lastKey && lastKey.count is 3
|
||||||
|
clipboard.copy(
|
||||||
|
'text/plain': "#{text}: #{title}\n#{url}",
|
||||||
|
'text/html': "<a href=\"#{url}\">#{text}</a>: #{title}"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keyPrefix: '2x'
|
||||||
|
key: 'y'
|
||||||
|
hotkeys: true
|
||||||
|
description: '...add object title'
|
||||||
|
}
|
||||||
|
{
|
||||||
|
keyPrefix: '3x'
|
||||||
|
key: 'y'
|
||||||
|
hotkeys: true
|
||||||
|
description: '...add object link url'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,16 @@
|
||||||
<% for item in area.content: %>
|
<% for item in area.content: %>
|
||||||
<% if item.where: %><p><i><%- @T(item.where) %></i></p><% end %>
|
<% if item.where: %><p><i><%- @T(item.where) %></i></p><% end %>
|
||||||
<% for shortcut in item.shortcuts: %>
|
<% for shortcut in item.shortcuts: %>
|
||||||
<% if shortcut.hotkeys: %><kbd>ctrl</kbd> <kbd>alt</kbd> <% end %>
|
<% if shortcut.hotkeys: %>
|
||||||
<% if _.isArray(shortcut.key): %><% for key in shortcut.key: %> <kbd><%- key %></kbd><% end %>
|
<kbd>ctrl</kbd> <kbd>alt</kbd>
|
||||||
|
<% end %>
|
||||||
|
<% if shortcut.keyPrefix: %>
|
||||||
|
<%= shortcut.keyPrefix %>
|
||||||
|
<% end %>
|
||||||
|
<% if _.isArray(shortcut.key): %>
|
||||||
|
<% for key in shortcut.key: %>
|
||||||
|
<kbd><%- key %></kbd>
|
||||||
|
<% end %>
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<kbd><%- shortcut.key %></kbd>
|
<kbd><%- shortcut.key %></kbd>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -24,8 +32,16 @@
|
||||||
<% for item in area.content: %>
|
<% for item in area.content: %>
|
||||||
<% if item.where: %><p><i><%- @T(item.where) %></i></p><% end %>
|
<% if item.where: %><p><i><%- @T(item.where) %></i></p><% end %>
|
||||||
<% for shortcut in item.shortcuts: %>
|
<% for shortcut in item.shortcuts: %>
|
||||||
<% if shortcut.hotkeys: %><kbd>ctrl</kbd> <kbd>alt</kbd> <% end %>
|
<% if shortcut.hotkeys: %>
|
||||||
<% if _.isArray(shortcut.key): %><% for key in shortcut.key: %> <kbd><%- key %></kbd><% end %>
|
<kbd>ctrl</kbd> <kbd>alt</kbd>
|
||||||
|
<% end %>
|
||||||
|
<% if shortcut.keyPrefix: %>
|
||||||
|
<%= shortcut.keyPrefix %>
|
||||||
|
<% end %>
|
||||||
|
<% if _.isArray(shortcut.key): %>
|
||||||
|
<% for key in shortcut.key: %>
|
||||||
|
<kbd><%- key %></kbd>
|
||||||
|
<% end %>
|
||||||
<% else: %>
|
<% else: %>
|
||||||
<kbd><%- shortcut.key %></kbd>
|
<kbd><%- shortcut.key %></kbd>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<div contenteditable="true" class="ticket-title-update" data-placeholder="<%- @Ti('Enter Title...') %>"><%= @object.title %></div>
|
<div contenteditable="true" class="ticket-title-update js-objectTitle" data-placeholder="<%- @Ti('Enter Title...') %>"><%= @object.title %></div>
|
|
@ -1808,28 +1808,28 @@ wait untill text in selector disabppears
|
||||||
data = params[:data]
|
data = params[:data]
|
||||||
|
|
||||||
if data[:title]
|
if data[:title]
|
||||||
#element = instance.find_elements(:css => '.content.active .ticketZoom-header .ticket-title-update')[0]
|
#element = instance.find_elements(:css => '.content.active .ticketZoom-header .js-objectTitle')[0]
|
||||||
#element.clear
|
#element.clear
|
||||||
#sleep 0.5
|
#sleep 0.5
|
||||||
#element = instance.find_elements(:css => '.content.active .ticketZoom-header .ticket-title-update')[0]
|
#element = instance.find_elements(:css => '.content.active .ticketZoom-header .js-objectTitle')[0]
|
||||||
#element.send_keys(data[:title])
|
#element.send_keys(data[:title])
|
||||||
#sleep 0.5
|
#sleep 0.5
|
||||||
#element.send_keys(:tab)
|
#element.send_keys(:tab)
|
||||||
|
|
||||||
instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").focus()')
|
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").focus()')
|
||||||
instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").text("' + data[:title] + '")')
|
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").text("' + data[:title] + '")')
|
||||||
instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").blur()')
|
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").blur()')
|
||||||
instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").trigger("blur")')
|
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").trigger("blur")')
|
||||||
# {
|
# {
|
||||||
# :where => :instance2,
|
# :where => :instance2,
|
||||||
# :execute => 'sendkey',
|
# :execute => 'sendkey',
|
||||||
# :css => '.content.active .ticketZoom-header .ticket-title-update',
|
# :css => '.content.active .ticketZoom-header .js-objectTitle',
|
||||||
# :value => 'TTT',
|
# :value => 'TTT',
|
||||||
# },
|
# },
|
||||||
# {
|
# {
|
||||||
# :where => :instance2,
|
# :where => :instance2,
|
||||||
# :execute => 'sendkey',
|
# :execute => 'sendkey',
|
||||||
# :css => '.content.active .ticketZoom-header .ticket-title-update',
|
# :css => '.content.active .ticketZoom-header .js-objectTitle',
|
||||||
# :value => :tab,
|
# :value => :tab,
|
||||||
# },
|
# },
|
||||||
end
|
end
|
||||||
|
@ -2007,7 +2007,7 @@ wait untill text in selector disabppears
|
||||||
data = params[:data]
|
data = params[:data]
|
||||||
|
|
||||||
if data[:title]
|
if data[:title]
|
||||||
title = instance.find_elements(css: '.content.active .ticketZoom-header .ticket-title-update')[0].text.strip
|
title = instance.find_elements(css: '.content.active .ticketZoom-header .js-objectTitle')[0].text.strip
|
||||||
if title =~ /#{data[:title]}/i
|
if title =~ /#{data[:title]}/i
|
||||||
assert(true, "matching '#{data[:title]}' in title '#{title}'")
|
assert(true, "matching '#{data[:title]}' in title '#{title}'")
|
||||||
else
|
else
|
||||||
|
@ -2136,7 +2136,7 @@ wait untill text in selector disabppears
|
||||||
#instance.find_element(partial_link_text: params[:title] } ).click
|
#instance.find_element(partial_link_text: params[:title] } ).click
|
||||||
instance.execute_script("$(\"#global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()")
|
instance.execute_script("$(\"#global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()")
|
||||||
sleep 1
|
sleep 1
|
||||||
title = instance.find_elements(css: '.active .ticketZoom-header .ticket-title-update')[0].text
|
title = instance.find_elements(css: '.active .ticketZoom-header .js-objectTitle')[0].text
|
||||||
if title !~ /#{params[:title]}/
|
if title !~ /#{params[:title]}/
|
||||||
screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
|
screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
|
||||||
raise "unable to search/find ticket #{params[:title]}!"
|
raise "unable to search/find ticket #{params[:title]}!"
|
||||||
|
|
Loading…
Reference in a new issue