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
|
||||
|
||||
events:
|
||||
'blur .ticket-title-update': 'update'
|
||||
'blur .js-objectTitle': 'update'
|
||||
|
||||
renderPost: (object) =>
|
||||
@$('.ticket-title-update').ce({
|
||||
@$('.js-objectTitle').ce({
|
||||
mode: 'textonly'
|
||||
multiline: false
|
||||
maxlength: 250
|
||||
|
|
|
@ -24,6 +24,12 @@ class App.KeyboardShortcutWidget extends Spine.Module
|
|||
|
||||
constructor: ->
|
||||
@observerKeys()
|
||||
@lastKey = undefined
|
||||
|
||||
$(document).keyup((e) =>
|
||||
return if e.keyCode isnt 27
|
||||
@lastKey = undefined
|
||||
)
|
||||
|
||||
observerKeys: =>
|
||||
navigationHotkeys = 'alt+ctrl'
|
||||
|
@ -41,9 +47,17 @@ class App.KeyboardShortcutWidget extends Spine.Module
|
|||
modifier += shortcut.key
|
||||
if shortcut.callback
|
||||
@log 'debug', 'bind for', modifier
|
||||
$(document).bind('keydown', modifier, (e) ->
|
||||
$(document).bind('keydown', modifier, (e) =>
|
||||
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) ->
|
||||
|
@ -51,7 +65,7 @@ class App.KeyboardShortcutWidget extends Spine.Module
|
|||
for item in area.content
|
||||
for shortcut in item.shortcuts
|
||||
if shortcut.globalEvent is e
|
||||
shortcut.callback()
|
||||
shortcut.callback(shortcut)
|
||||
)
|
||||
|
||||
App.Config.set('keyboard_shortcuts', App.KeyboardShortcutWidget, 'Widgets')
|
||||
|
@ -247,10 +261,38 @@ App.Config.set(
|
|||
key: 'y'
|
||||
hotkeys: true
|
||||
description: 'Copy current object number (e. g. Ticket#) into clipboard'
|
||||
callback: ->
|
||||
callback: (shortcut, lastKey, modifier) ->
|
||||
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)
|
||||
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: %>
|
||||
<% if item.where: %><p><i><%- @T(item.where) %></i></p><% end %>
|
||||
<% for shortcut in item.shortcuts: %>
|
||||
<% if shortcut.hotkeys: %><kbd>ctrl</kbd> <kbd>alt</kbd> <% end %>
|
||||
<% if _.isArray(shortcut.key): %><% for key in shortcut.key: %> <kbd><%- key %></kbd><% end %>
|
||||
<% if shortcut.hotkeys: %>
|
||||
<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: %>
|
||||
<kbd><%- shortcut.key %></kbd>
|
||||
<% end %>
|
||||
|
@ -24,8 +32,16 @@
|
|||
<% for item in area.content: %>
|
||||
<% if item.where: %><p><i><%- @T(item.where) %></i></p><% end %>
|
||||
<% for shortcut in item.shortcuts: %>
|
||||
<% if shortcut.hotkeys: %><kbd>ctrl</kbd> <kbd>alt</kbd> <% end %>
|
||||
<% if _.isArray(shortcut.key): %><% for key in shortcut.key: %> <kbd><%- key %></kbd><% end %>
|
||||
<% if shortcut.hotkeys: %>
|
||||
<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: %>
|
||||
<kbd><%- shortcut.key %></kbd>
|
||||
<% 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]
|
||||
|
||||
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
|
||||
#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])
|
||||
#sleep 0.5
|
||||
#element.send_keys(:tab)
|
||||
|
||||
instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").focus()')
|
||||
instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").text("' + data[:title] + '")')
|
||||
instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").blur()')
|
||||
instance.execute_script('$(".content.active .ticketZoom-header .ticket-title-update").trigger("blur")')
|
||||
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").focus()')
|
||||
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").text("' + data[:title] + '")')
|
||||
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").blur()')
|
||||
instance.execute_script('$(".content.active .ticketZoom-header .js-objectTitle").trigger("blur")')
|
||||
# {
|
||||
# :where => :instance2,
|
||||
# :execute => 'sendkey',
|
||||
# :css => '.content.active .ticketZoom-header .ticket-title-update',
|
||||
# :css => '.content.active .ticketZoom-header .js-objectTitle',
|
||||
# :value => 'TTT',
|
||||
# },
|
||||
# {
|
||||
# :where => :instance2,
|
||||
# :execute => 'sendkey',
|
||||
# :css => '.content.active .ticketZoom-header .ticket-title-update',
|
||||
# :css => '.content.active .ticketZoom-header .js-objectTitle',
|
||||
# :value => :tab,
|
||||
# },
|
||||
end
|
||||
|
@ -2007,7 +2007,7 @@ wait untill text in selector disabppears
|
|||
data = params[:data]
|
||||
|
||||
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
|
||||
assert(true, "matching '#{data[:title]}' in title '#{title}'")
|
||||
else
|
||||
|
@ -2136,7 +2136,7 @@ wait untill text in selector disabppears
|
|||
#instance.find_element(partial_link_text: params[:title] } ).click
|
||||
instance.execute_script("$(\"#global-search-result a:contains('#{params[:title]}') .nav-tab-icon\").click()")
|
||||
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]}/
|
||||
screenshot(browser: instance, comment: 'ticket_open_by_title_failed')
|
||||
raise "unable to search/find ticket #{params[:title]}!"
|
||||
|
|
Loading…
Reference in a new issue