From 4caf0228931062147f3664a004c4b3adfa336843 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 9 Jan 2017 15:47:27 +0100 Subject: [PATCH] =?UTF-8?q?Followup=20for=20issue=20#586=20-=20Small=20imp?= =?UTF-8?q?rovement=20for=20=E2=80=9Cenable=20form=20to=20include=20file?= =?UTF-8?q?=20attachments=E2=80=9D.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/views/channel/form.jst.eco | 12 ++++++++++- app/controllers/form_controller.rb | 3 +-- public/assets/form/form.js | 20 +++++++++++++++++-- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/views/channel/form.jst.eco b/app/assets/javascripts/app/views/channel/form.jst.eco index 357d26892..fa080566a 100644 --- a/app/assets/javascripts/app/views/channel/form.jst.eco +++ b/app/assets/javascripts/app/views/channel/form.jst.eco @@ -35,7 +35,7 @@
- +
@@ -89,6 +89,16 @@ <%- @T('Load no CSS for form. You need to generate your own CSS for the form.') %> + + + diff --git a/app/controllers/form_controller.rb b/app/controllers/form_controller.rb index 2e0624f27..b80e26341 100644 --- a/app/controllers/form_controller.rb +++ b/app/controllers/form_controller.rb @@ -118,8 +118,7 @@ class FormController < ApplicationController data: File.read(file.tempfile), filename: file.original_filename, preferences: { - 'content-alternative' => true, - 'Mime-Type' => file.content_type + 'Mime-Type' => file.content_type, } ) } diff --git a/public/assets/form/form.js b/public/assets/form/form.js index 92c09d8de..6ffc9b7ee 100644 --- a/public/assets/form/form.js +++ b/public/assets/form/form.js @@ -13,11 +13,12 @@ $(function() { $('#feedback-form').ZammadForm({ messageTitle: 'Feedback Form', // optional messageSubmit: 'Submit', // optional - messageThankYou: 'Thank you for your inquiry (#%s)! We\'ll contact you soon as possible.', // optional - messageNoConfig: 'Unable to load form config from server. Maybe featrue is disabled.', // optional + messageThankYou: 'Thank you for your inquiry (#%s)! We\'ll contact you as soon as possible.', // optional + messageNoConfig: 'Unable to load form config from server. Maybe feature is disabled.', // optional showTitle: true, lang: 'de', // optional, will be used per default modal: true, + attachmentSupport: false, attributes: [ { display: 'Name', @@ -65,6 +66,7 @@ $(function() { messageSubmit: 'Submit', messageThankYou: 'Thank you for your inquiry! We\'ll contact you as soon as possible.', messageNoConfig: 'Unable to load form config from server. Maybe feature is disabled.', + attachmentSupport: false, attributes: [ { display: 'Name', @@ -95,6 +97,7 @@ $(function() { 'Email': 'E-Mail', 'Your Email': 'Ihre E-Mail', 'Message': 'Nachricht', + 'Attachments': 'Anhänge', 'Your Message...': 'Ihre Nachricht...', }, es: { @@ -103,6 +106,7 @@ $(function() { 'Email': 'correo electrónico', 'Your Email': 'Tu correo electrónico', 'Message': 'Mensaje', + 'Attachments': 'archivos adjuntos', 'Your Message...': 'tu Mensaje...', }, fr: { @@ -111,6 +115,7 @@ $(function() { 'Email': 'Email', 'Your Email': 'Votre Email', 'Message': 'Message', + 'Attachments': 'Pièces jointes', 'Your Message...': 'Votre message...', }, } @@ -157,6 +162,17 @@ $(function() { _this.loadCss(_this.css_location) } + if (_this.options.attachmentSupport === true || _this.options.attachmentSupport === 'true') { + var attachment = { + display: 'Attachments', + name: 'file[]', + tag: 'input', + type: 'file', + repeat: 1, + } + _this.options.attributes.push(attachment) + } + _this.log('debug', 'endpoint_config: ' + _this.endpoint_config) _this.log('debug', 'endpoint_submit: ' + _this.endpoint_submit)