From 718263afd110e39f6e24c2971d1b15eea2c5720d Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 3 Jun 2016 15:24:42 +0200 Subject: [PATCH 1/3] Improved autosave. Also moved to event based auto save for ticket creation. --- .../javascripts/app/controllers/agent_ticket_create.coffee | 5 ++++- app/assets/javascripts/app/controllers/ticket_zoom.coffee | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee index 57aba6707..afc05b72f 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_create.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_create.coffee @@ -142,7 +142,10 @@ class App.TicketCreate extends App.Controller @latestTitle = title App.TaskManager.touch(@task_key) - @interval(update, 3000, @id) + @el.on('change.local blur.local keyup.local paste.local input.local', 'form, .js-textarea', (e) => + @delay(update, 250, 'ticket-create-form-update') + ) + @delay(update, 800, 'ticket-create-form-update') # get data / in case also ticket data for split buildScreen: (params) => diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee index f93993b8c..313e88d81 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee @@ -100,7 +100,7 @@ class App.TicketZoom extends App.Controller @activeState = true # start autosave - @delay(@autosaveStart, 800, "ticket-zoom-auto-save-#{@ticket_id}") + @autosaveStart() # if ticket is shown the first time if !@shown @@ -428,6 +428,7 @@ class App.TicketZoom extends App.Controller @el.on('change.local blur.local keyup.local paste.local input.local', 'form, .js-textarea', (e) => @delay(update, 250, 'ticket-zoom-form-update') ) + @delay(update, 800, 'ticket-zoom-form-update') currentStore: => return if !@ticket From 3bb6267f39e8bdb9b8e7266078c9493ab3678b21 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 3 Jun 2016 15:25:06 +0200 Subject: [PATCH 2/3] Code cleanup. --- lib/core_ext/string.rb | 43 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index debd4ce59..0dd79d0e7 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -92,7 +92,7 @@ class String link_list = '' counter = 0 if !string_only - string.gsub!( //ix ) { + string.gsub!(//ix) { link = $2 counter = counter + 1 link_list += "[#{counter}] #{link}\n" @@ -101,31 +101,32 @@ class String end # remove style tags with content - string.gsub!( %r{(.+?)}im, '') + string.gsub!(%r{(.+?)}im, '') + # remove empty lines - string.gsub!( /^\s*/m, '' ) + string.gsub!(/^\s*/m, '') # pre/code handling 1/2 - string.gsub!( %r{
(.+?)
}m ) { |placeholder| + string.gsub!(%r{
(.+?)
}m) { |placeholder| placeholder = placeholder.gsub(/\n/, '###BR###') } - string.gsub!( %r{(.+?)}m ) { |placeholder| + string.gsub!(%r{(.+?)}m) { |placeholder| placeholder = placeholder.gsub(/\n/, '###BR###') } # insert spaces on [A-z]\n[A-z] - string.gsub!( /([A-z])\n([A-z])/m, '\1 \2' ) + string.gsub!(/([A-z])\n([A-z])/m, '\1 \2') # remove all new lines string.gsub!(/(\n\r|\r\r\n|\r\n|\n)/, '') # blockquote handling - string.gsub!( %r{]*)>(.+?)}m ) { + string.gsub!(%r{]*)>(.+?)}m) { "\n" + $2.html2text(true).gsub(/^(.*)$/, '> \1') + "\n" } # pre/code handling 2/2 - string.gsub!(/###BR###/, "\n" ) + string.gsub!(/###BR###/, "\n") # add counting string.gsub!(/]*)>/i, "\n* ") @@ -137,14 +138,14 @@ class String string.gsub!(%r{}i, "\n") # add new lines - string.gsub!( %r{}im, "\n" ) - string.gsub!( %r{

}im, "\n" ) - string.gsub!( %r{<(div|p|pre|br|table|h)(|/| [^>]*)>}i, "\n" ) - string.gsub!( %r{}i, "\n" ) - string.gsub!( %r{}i, ' ' ) + string.gsub!(%r{}im, "\n") + string.gsub!(%r{

}im, "\n") + string.gsub!(%r{<(div|p|pre|br|table|h)(|/| [^>]*)>}i, "\n") + string.gsub!(%r{}i, "\n") + string.gsub!(%r{}i, ' ') # strip all other tags - string.gsub!( /\<.+?\>/, '' ) + string.gsub!(/\<.+?\>/, '') # replace multiple spaces with one string.gsub!(/ /, ' ') @@ -156,19 +157,19 @@ class String rescue # strip all & < > " - string.gsub!( '&', '&' ) - string.gsub!( '<', '<' ) - string.gsub!( '>', '>' ) - string.gsub!( '"', '"' ) - string.gsub!( ' ', ' ' ) + string.gsub!('&', '&') + string.gsub!('<', '<') + string.gsub!('>', '>') + string.gsub!('"', '"') + string.gsub!(' ', ' ') # encode html entities like "–" - string.gsub!( /(&\#(\d+);?)/x ) { + string.gsub!(/(&\#(\d+);?)/x) { $2.chr } # encode html entities like "d;" - string.gsub!( /(&\#[xX]([0-9a-fA-F]+);?)/x ) { + string.gsub!(/(&\#[xX]([0-9a-fA-F]+);?)/x) { chr_orig = $1 hex = $2.hex if hex From 536cc11ba15ba70ece18dd94a8c5e26915fd7b93 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 3 Jun 2016 15:25:35 +0200 Subject: [PATCH 3/3] Improved doc. --- app/models/channel/email_parser.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index df08669ad..651444a57 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -23,6 +23,7 @@ class Channel::EmailParser cc: 'Somebody ', subject: 'some message subject', body: 'some message body', + date: Time.zone.now, attachments: [ { data: 'binary of attachment',