Improve reply behaviour.
This commit is contained in:
parent
a938618228
commit
4d9ff76cff
5 changed files with 121 additions and 74 deletions
|
@ -530,11 +530,13 @@ class App.TicketZoom extends App.Controller
|
|||
e.stopPropagation()
|
||||
e.preventDefault()
|
||||
ticketParams = @formParam( @$('.edit') )
|
||||
console.log "submit ticket", ticketParams
|
||||
|
||||
# validate ticket
|
||||
ticket = App.Ticket.fullLocal( @ticket.id )
|
||||
|
||||
# reset article - should not be resubmited on next ticket update
|
||||
ticket.article = undefined
|
||||
|
||||
# update ticket attributes
|
||||
for key, value of ticketParams
|
||||
ticket[key] = value
|
||||
|
@ -627,8 +629,6 @@ class App.TicketZoom extends App.Controller
|
|||
@autosaveStart()
|
||||
return
|
||||
|
||||
console.log "article load", articleParams
|
||||
#return
|
||||
article.load(articleParams)
|
||||
errors = article.validate()
|
||||
if errors
|
||||
|
@ -643,8 +643,7 @@ class App.TicketZoom extends App.Controller
|
|||
return
|
||||
|
||||
ticket.article = article
|
||||
console.log('ARR', article)
|
||||
#return
|
||||
|
||||
# submit changes
|
||||
ticket.save(
|
||||
done: (r) =>
|
||||
|
@ -1404,21 +1403,6 @@ class ArticleView extends App.Controller
|
|||
return true
|
||||
false
|
||||
|
||||
checkIfSignatureIsNeeded: (type) =>
|
||||
console.log('checkIfSignatureIsNeeded', type, @ui.signature)
|
||||
# add signature
|
||||
if @ui.signature && @ui.signature.body && type.name is 'email'
|
||||
body = @ui.el.find('[data-name="body"]').html() || ''
|
||||
|
||||
# convert to html
|
||||
signature = @ui.signature.body
|
||||
signature = App.Utils.text2html( signature )
|
||||
regexp = new RegExp( escapeRegExp( signature ) , 'im')
|
||||
#console.log('aaa', body, regexp)
|
||||
if !body || !body.match(regexp)
|
||||
body = body + signature
|
||||
@ui.el.find('[data-name="body"]').html( body )
|
||||
|
||||
replyAll: (e) =>
|
||||
@reply(e, true)
|
||||
|
||||
|
@ -1433,9 +1417,6 @@ class ArticleView extends App.Controller
|
|||
|
||||
@ui.el.find('.article-add').ScrollTo()
|
||||
|
||||
# update form
|
||||
@checkIfSignatureIsNeeded(type)
|
||||
|
||||
# empty form
|
||||
articleNew = {
|
||||
to: ''
|
||||
|
@ -1504,21 +1485,31 @@ class ArticleView extends App.Controller
|
|||
if article.cc
|
||||
articleNew.cc = addAddresses(articleNew.cc, article.cc)
|
||||
|
||||
# add quoted text if needed
|
||||
selectedText = App.ClipBoard.getSelected()
|
||||
if selectedText
|
||||
# get current body
|
||||
body = @ui.el.find('[data-name="body"]').html() || ''
|
||||
|
||||
# quote text
|
||||
# check if signature need to be added
|
||||
if @ui.signature && @ui.signature.body && type.name is 'email'
|
||||
signature = App.Utils.text2html( @ui.signature.body )
|
||||
if App.Utils.signatureCheck( body, signature )
|
||||
body = body + signature
|
||||
|
||||
# check if quote need to be added
|
||||
selectedText = App.ClipBoard.getSelected()
|
||||
if selectedText
|
||||
|
||||
# clean selection
|
||||
selectedText = App.Utils.textCleanup( selectedText )
|
||||
#selectedText = App.Utils.quote( selectedText )
|
||||
|
||||
# convert to html
|
||||
selectedText = App.Utils.text2html( selectedText )
|
||||
if selectedText
|
||||
selectedText = "<div><br><br/></div><div><blockquote type=\"cite\">#{selectedText}</blockquote></div><div><br></div>"
|
||||
|
||||
articleNew.body = selectedText + body
|
||||
# add selected text to body
|
||||
body = selectedText + body
|
||||
|
||||
articleNew.body = body
|
||||
|
||||
App.Event.trigger('ui::ticket::setArticleType', { ticket: @ticket, type: type, article: articleNew } )
|
||||
|
||||
|
|
|
@ -147,3 +147,21 @@ class App.Utils
|
|||
.removeAttr( 'class' )
|
||||
.removeAttr( 'title' )
|
||||
html
|
||||
|
||||
# signatureNeeded = App.Utils.signatureCheck( message, signature )
|
||||
@signatureCheck: (message, signature) ->
|
||||
messageText = $( '<div>' + message + '</div>' ).text().trim()
|
||||
messageText = messageText.replace(/(\n|\r|\t)/g, '')
|
||||
signatureText = $( '<div>' + signature + '</div>' ).text().trim()
|
||||
signatureText = signatureText.replace(/(\n|\r|\t)/g, '')
|
||||
|
||||
quote = (str) ->
|
||||
(str + '').replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&")
|
||||
|
||||
console.log('SC', messageText, signatureText, quote(signatureText))
|
||||
regex = new RegExp( quote(signatureText), 'mi' )
|
||||
if messageText.match(regex)
|
||||
false
|
||||
else
|
||||
true
|
||||
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
<% position = 'right' %>
|
||||
<% end %>
|
||||
<%- article.created_by.avatar("40", position) %>
|
||||
<div class="flex bubble-gap internal-border">
|
||||
<div class="flex bubble-gap">
|
||||
<div class="internal-border">
|
||||
<div class="text-bubble">
|
||||
<div class="bubble-arrow"></div>
|
||||
<%- article.html %>
|
||||
|
@ -58,6 +59,18 @@
|
|||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% if article.actions: %>
|
||||
<div>
|
||||
<div class="article-actions horizontal stretch">
|
||||
<% for action in article.actions: %>
|
||||
<a href="<%= action.href %>" data-type="<%= action.type %>" class="article-action u-clickable<% if action.class: %> <%= action.class %><% end %>">
|
||||
<span class="<%= action.type %> action icon"></span><%- @T( action.name ) %>
|
||||
</a>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="article-meta-clip bottom">
|
||||
|
@ -74,16 +87,6 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if article.actions: %>
|
||||
<div class="article-actions horizontal stretch">
|
||||
<% for action in article.actions: %>
|
||||
<a href="<%= action.href %>" data-type="<%= action.type %>" class="article-action u-clickable<% if action.class: %> <%= action.class %><% end %>">
|
||||
<span class="<%= action.type %> action icon"></span><%- @T( action.name ) %>
|
||||
</a>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -3162,8 +3162,8 @@ footer {
|
|||
}
|
||||
|
||||
.article-action {
|
||||
padding: 5px;
|
||||
margin: 5px 12px;
|
||||
padding-top: 5px;
|
||||
margin-top: 5px;
|
||||
color: black;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
|
|
|
@ -337,4 +337,39 @@ test( "quote", function() {
|
|||
|
||||
});
|
||||
|
||||
// check signature
|
||||
test( "check signature", function() {
|
||||
|
||||
var message = "<div>test 123 </div>"
|
||||
var signature = '<div>--<br>Some Signature<br>some department</div>'
|
||||
var result = App.Utils.signatureCheck( message, signature )
|
||||
equal( result, true )
|
||||
|
||||
message = "<div>test 123 <div>--<br>Some Signature<br>some department\n</div></div>"
|
||||
signature = '<div>--<br>Some Signature<br>some department</div>'
|
||||
result = App.Utils.signatureCheck( message, signature )
|
||||
equal( result, false )
|
||||
|
||||
message = "<div>test 123 <div>--<br>Some Signature\n<br>some department\n</div></div>"
|
||||
signature = '<div>--<br>Some Signature<br>some department</div>'
|
||||
result = App.Utils.signatureCheck( message, signature )
|
||||
equal( result, false )
|
||||
|
||||
message = "<div>test 123 <div>--<p>Some Signature</p>\n<p><div>some department</div>\n</p>\n</div></div>"
|
||||
signature = '<div>--<br>Some Signature<br>some department</div>'
|
||||
result = App.Utils.signatureCheck( message, signature )
|
||||
equal( result, false )
|
||||
|
||||
message = ""
|
||||
signature = '<div>--<br>Some Signature<br>some department</div>'
|
||||
result = App.Utils.signatureCheck( message, signature )
|
||||
equal( result, true )
|
||||
|
||||
message = ""
|
||||
signature = "--\nSome Signature\nsome department"
|
||||
result = App.Utils.signatureCheck( message, signature )
|
||||
equal( result, true )
|
||||
|
||||
});
|
||||
|
||||
}
|
Loading…
Reference in a new issue