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 0d1cd8666..c1b65742a 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,13 +10,6 @@ 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 +50,15 @@ class EmailReply extends App.Controller
icon: 'reply-all'
href: '#'
}
+
+ actions.push {
+ name: 'forward'
+ type: 'emailForward'
+ #icon: 'forward'
+ icon: 'line-right-arrow'
+ href: '#'
+ }
+
if article.sender.name is 'Customer' && article.type.name is 'phone'
actions.push {
name: 'reply'
@@ -68,7 +70,7 @@ class EmailReply extends App.Controller
name: 'forward'
type: 'emailForward'
#icon: 'forward'
- icon: 'info'
+ icon: 'line-right-arrow'
href: '#'
}
if article.sender.name is 'Agent' && article.type.name is 'phone'
@@ -82,7 +84,7 @@ class EmailReply extends App.Controller
name: 'forward'
type: 'emailForward'
#icon: 'forward'
- icon: 'info'
+ icon: 'line-right-arrow'
href: '#'
}
diff --git a/app/assets/javascripts/app/views/ticket_zoom/article_view_actions.jst.eco b/app/assets/javascripts/app/views/ticket_zoom/article_view_actions.jst.eco
index e0301172b..e4cd4695e 100644
--- a/app/assets/javascripts/app/views/ticket_zoom/article_view_actions.jst.eco
+++ b/app/assets/javascripts/app/views/ticket_zoom/article_view_actions.jst.eco
@@ -1,7 +1,7 @@
\ No newline at end of file
diff --git a/app/assets/stylesheets/zammad.scss b/app/assets/stylesheets/zammad.scss
index 6678c2d2a..b7014b403 100644
--- a/app/assets/stylesheets/zammad.scss
+++ b/app/assets/stylesheets/zammad.scss
@@ -4985,6 +4985,18 @@ footer {
fill: currentColor;
}
+ .article-action-name {
+ @media screen and (max-width: 1080px) {
+ display: none;
+ }
+
+ @media screen and (max-width: 1358px) {
+ .main:not(.is-closed) & {
+ display: none;
+ }
+ }
+ }
+
.article-add {
position: relative;
z-index: 1; // fixed chrome 49 + flex issue, not shown article
diff --git a/app/controllers/concerns/clones_ticket_article_attachments.rb b/app/controllers/concerns/clones_ticket_article_attachments.rb
new file mode 100644
index 000000000..da8248030
--- /dev/null
+++ b/app/controllers/concerns/clones_ticket_article_attachments.rb
@@ -0,0 +1,37 @@
+module ClonesTicketArticleAttachments
+ extend ActiveSupport::Concern
+
+ private
+
+ def article_attachments_clone(article)
+ raise Exceptions::UnprocessableEntity, 'Need form_id to attach attachments to new form.' if params[:form_id].blank?
+
+ existing_attachments = Store.list(
+ object: 'UploadCache',
+ o_id: params[:form_id],
+ )
+ attachments = []
+ article.attachments.each do |new_attachment|
+ next if new_attachment.preferences['Content-ID'].present?
+ next if new_attachment.preferences['content-alternative'] == true
+ already_added = false
+ existing_attachments.each do |existing_attachment|
+ next if existing_attachment.filename != new_attachment.filename || existing_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,
+ )
+ attachments.push file
+ end
+
+ attachments
+ end
+
+end
diff --git a/app/controllers/ticket_articles_controller.rb b/app/controllers/ticket_articles_controller.rb
index 415ee4dcb..cf4e5c98d 100644
--- a/app/controllers/ticket_articles_controller.rb
+++ b/app/controllers/ticket_articles_controller.rb
@@ -2,6 +2,7 @@
class TicketArticlesController < ApplicationController
include CreatesTicketArticles
+ include ClonesTicketArticleAttachments
prepend_before_action :authentication_check
@@ -210,38 +211,11 @@ class TicketArticlesController < ApplicationController
# 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,
+ attachments: article_attachments_clone(article),
}
end
diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb
index 9b471d5ee..df8b29ae1 100644
--- a/app/controllers/tickets_controller.rb
+++ b/app/controllers/tickets_controller.rb
@@ -2,6 +2,7 @@
class TicketsController < ApplicationController
include CreatesTicketArticles
+ include ClonesTicketArticleAttachments
include TicketStats
prepend_before_action :authentication_check
@@ -353,32 +354,13 @@ class TicketsController < ApplicationController
access!(ticket, 'read')
assets = ticket.assets({})
- # get related articles
article = Ticket::Article.find(params[:article_id])
+ access!(article.ticket, 'read')
assets = article.assets(assets)
- attachments = []
- if params[:form_id].present?
- attachments = Store.list(
- object: 'UploadCache',
- o_id: params[:form_id],
- ).to_a
- article.attachments.each do |attachment|
- next if attachment.preferences['Content-ID'].present?
- file = Store.add(
- object: 'UploadCache',
- o_id: params[:form_id],
- data: attachment.content,
- filename: attachment.filename,
- preferences: attachment.preferences,
- )
- attachments.push file
- end
- end
-
render json: {
assets: assets,
- attachments: attachments,
+ attachments: article_attachments_clone(article),
}
end
diff --git a/test/controllers/ticket_article_attachments_controller_test.rb b/test/controllers/ticket_article_attachments_controller_test.rb
index 2e4286332..90acadf91 100644
--- a/test/controllers/ticket_article_attachments_controller_test.rb
+++ b/test/controllers/ticket_article_attachments_controller_test.rb
@@ -141,4 +141,57 @@ class TicketArticleAttachmentsControllerTest < ActionDispatch::IntegrationTest
end
+ test '01.02 test attachments for split' do
+ headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' }
+
+ email_raw_string = IO.binread('test/fixtures/mail24.box')
+ ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email_raw_string)
+
+ credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
+ get "/api/v1/ticket_split", params: { form_id: '1234-2', ticket_id: ticket_p.id, article_id: article_p.id }, headers: headers.merge('Authorization' => credentials)
+ assert_response(200)
+ result = JSON.parse(@response.body)
+ assert(result['assets'])
+ assert_equal(result['attachments'].class, Array)
+ assert_equal(result['attachments'].count, 1)
+ assert_equal(result['attachments'][0]['filename'], 'rulesets-report.csv')
+
+ end
+
+ test '01.03 test attachments for forward' do
+ headers = { 'ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json' }
+
+ email_raw_string = IO.binread('test/fixtures/mail8.box')
+ ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email_raw_string)
+
+ credentials = ActionController::HttpAuthentication::Basic.encode_credentials('tickets-agent@example.com', 'agentpw')
+ post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: {}, headers: headers.merge('Authorization' => credentials)
+ assert_response(422)
+ result = JSON.parse(@response.body)
+ assert_equal(result.class, Hash)
+ assert(result['error'], 'Need form_id to attach attachments to new form')
+
+ post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: { form_id: '1234-1' }.to_json, headers: headers.merge('Authorization' => credentials)
+ assert_response(200)
+ result = JSON.parse(@response.body)
+ assert_equal(result['attachments'].class, Array)
+ assert(result['attachments'].blank?)
+
+ email_raw_string = IO.binread('test/fixtures/mail24.box')
+ ticket_p, article_p, user_p = Channel::EmailParser.new.process({}, email_raw_string)
+
+ post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: { form_id: '1234-2' }.to_json, headers: headers.merge('Authorization' => credentials)
+ assert_response(200)
+ result = JSON.parse(@response.body)
+ assert_equal(result['attachments'].class, Array)
+ assert_equal(result['attachments'].count, 1)
+ assert_equal(result['attachments'][0]['filename'], 'rulesets-report.csv')
+
+ post "/api/v1/ticket_attachment_upload_clone_by_article/#{article_p.id}", params: { form_id: '1234-2' }.to_json, headers: headers.merge('Authorization' => credentials)
+ assert_response(200)
+ result = JSON.parse(@response.body)
+ assert_equal(result['attachments'].class, Array)
+ assert(result['attachments'].blank?)
+ end
+
end