diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.coffee
index 094a15f30..d05db0448 100644
--- a/app/assets/javascripts/app/controllers/ticket_zoom.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_zoom.coffee
@@ -461,6 +461,7 @@ class App.TicketZoom extends App.Controller
ui: @
highligher: @highligher
ticket_article_ids: @ticket_article_ids
+ form_id: @form_id
)
new App.TicketCustomerAvatar(
diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee
index eacd9cf14..0d1cd8666 100644
--- a/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_action/email_reply.coffee
@@ -10,6 +10,13 @@ class EmailReply extends App.Controller
icon: 'reply'
href: '#'
}
+ actions.push {
+ name: 'forward'
+ type: 'emailForward'
+ #icon: 'forward'
+ icon: 'info'
+ href: '#'
+ }
recipients = []
if article.sender.name is 'Customer'
if article.from
@@ -57,6 +64,13 @@ class EmailReply extends App.Controller
icon: 'reply'
href: '#'
}
+ actions.push {
+ name: 'forward'
+ type: 'emailForward'
+ #icon: 'forward'
+ icon: 'info'
+ href: '#'
+ }
if article.sender.name is 'Agent' && article.type.name is 'phone'
actions.push {
name: 'reply'
@@ -64,17 +78,27 @@ class EmailReply extends App.Controller
icon: 'reply'
href: '#'
}
+ actions.push {
+ name: 'forward'
+ type: 'emailForward'
+ #icon: 'forward'
+ icon: 'info'
+ href: '#'
+ }
actions
@perform: (articleContainer, type, ticket, article, ui) ->
- return true if type isnt 'emailReply' && type isnt 'emailReplyAll'
+ return true if type isnt 'emailReply' && type isnt 'emailReplyAll' && type isnt 'emailForward'
- if type isnt 'emailReply'
+ if type is 'emailReply'
+ @emailReply(false, ticket, article, ui)
+
+ else if type is 'emailReplyAll'
@emailReply(true, ticket, article, ui)
- else if type isnt 'emailReplyAll'
- @emailReply(false, ticket, article, ui)
+ else if type is 'emailForward'
+ @emailForward(ticket, article, ui)
true
@@ -132,4 +156,49 @@ class EmailReply extends App.Controller
true
+ @emailForward: (ticket, article, ui) ->
+
+ ui.scrollToCompose()
+
+ signaturePosition = 'top'
+ body = ''
+ if article.content_type.match('html')
+ body = App.Utils.textCleanup(article.body)
+ if article.content_type.match('plain')
+ body = App.Utils.textCleanup(article.body)
+ body = App.Utils.text2html(body)
+
+ body = "
---Begin forwarded message:---
"
+
+ articleNew = {}
+ articleNew.body = body
+
+ type = App.TicketArticleType.findByAttribute(name:'email')
+
+ App.Event.trigger('ui::ticket::setArticleType', {
+ ticket: ticket
+ type: type
+ article: articleNew
+ signaturePosition: signaturePosition
+ })
+
+ # add attachments to form
+ App.Ajax.request(
+ id: "ticket_attachment_clone#{ui.form_id}"
+ type: 'POST'
+ url: "#{App.Config.get('api_path')}/ticket_attachment_upload_clone_by_article/#{article.id}"
+ data: JSON.stringify(form_id: ui.form_id)
+ processData: true
+ success: (data, status, xhr) ->
+ return if _.isEmpty(data.attachments)
+ App.Event.trigger('ui::ticket::addArticleAttachent', {
+ ticket: ticket
+ article: article
+ attachments: data.attachments
+ form_id: ui.form_id
+ })
+ )
+
+ true
+
App.Config.set('200-EmailReply', EmailReply, 'TicketZoomArticleAction')
diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee
index e2c854bae..3eaf3dce9 100644
--- a/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_new.coffee
@@ -70,6 +70,14 @@ class App.TicketZoomArticleNew extends App.Controller
@textarea.focus()
)
+ # add article attachment
+ @bind('ui::ticket::addArticleAttachent', (data) =>
+ return if data.ticket.id.toString() isnt @ticket_id.toString()
+ return if _.isEmpty(data.attachments)
+ for file in data.attachments
+ @renderAttachment(file)
+ )
+
# reset new article screen
@bind('ui::ticket::taskReset', (data) =>
return if data.ticket_id.toString() isnt @ticket_id.toString()
diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee
index d66ed3c15..d70282853 100644
--- a/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee
+++ b/app/assets/javascripts/app/controllers/ticket_zoom/article_view.coffee
@@ -20,6 +20,7 @@ class App.TicketZoomArticleView extends App.Controller
el: el
ui: @ui
highligher: @highligher
+ form_id: @form_id
)
if !@ticketArticleInsertByIndex(index, el)
all.push el
@@ -193,6 +194,7 @@ class ArticleViewItem extends App.ObserverController
ticket: @ticket
article: article
lastAttributres: @lastAttributres
+ form_id: @form_id
)
# set see more
diff --git a/app/controllers/ticket_articles_controller.rb b/app/controllers/ticket_articles_controller.rb
index 10468c8b5..415ee4dcb 100644
--- a/app/controllers/ticket_articles_controller.rb
+++ b/app/controllers/ticket_articles_controller.rb
@@ -208,6 +208,43 @@ class TicketArticlesController < ApplicationController
}
end
+ # POST /ticket_attachment_upload_clone_by_article
+ def ticket_attachment_upload_clone_by_article
+
+ article = Ticket::Article.find(params[:article_id])
+ access!(article.ticket, 'read')
+
+ raise Exceptions::NotAuthorized, 'Need form_id to attach attachmeints.' if params[:form_id].blank?
+
+ existing_attachments = Store.list(
+ object: 'UploadCache',
+ o_id: params[:form_id],
+ ).to_a
+ new_attachments = []
+ article.attachments.each do |new_attachment|
+ next if new_attachment.preferences['Content-ID'].present?
+ already_added = false
+ existing_attachments.each do |local_attachment|
+ next if local_attachment.filename != new_attachment.filename || local_attachment.size != new_attachment.size
+ already_added = true
+ break
+ end
+ next if already_added == true
+ file = Store.add(
+ object: 'UploadCache',
+ o_id: params[:form_id],
+ data: new_attachment.content,
+ filename: new_attachment.filename,
+ preferences: new_attachment.preferences,
+ )
+ new_attachments.push file
+ end
+
+ render json: {
+ attachments: new_attachments,
+ }
+ end
+
# GET /ticket_attachment/:ticket_id/:article_id/:id
def attachment
ticket = Ticket.lookup(id: params[:ticket_id])
diff --git a/config/routes/ticket.rb b/config/routes/ticket.rb
index 0e12e66e0..fef82d720 100644
--- a/config/routes/ticket.rb
+++ b/config/routes/ticket.rb
@@ -44,6 +44,7 @@ Zammad::Application.routes.draw do
match api_path + '/ticket_attachment/:ticket_id/:article_id/:id', to: 'ticket_articles#attachment', via: :get
match api_path + '/ticket_attachment_upload', to: 'ticket_articles#ticket_attachment_upload_add', via: :post
match api_path + '/ticket_attachment_upload', to: 'ticket_articles#ticket_attachment_upload_delete', via: :delete
+ match api_path + '/ticket_attachment_upload_clone_by_article/:article_id', to: 'ticket_articles#ticket_attachment_upload_clone_by_article', via: :post
match api_path + '/ticket_article_plain/:id', to: 'ticket_articles#article_plain', via: :get
end