Followup for issue #586 - Small improvement for “enable form to include file attachments”.

This commit is contained in:
Martin Edenhofer 2017-01-09 15:47:27 +01:00
parent 6ef4ace299
commit 4caf022893
3 changed files with 30 additions and 5 deletions

View file

@ -35,7 +35,7 @@
<label for="form-message-thank-you"><%- @T('Message after sending form') %></label>
</div>
<div class="controls">
<textarea type="text" id="form-message-thank-you" name="messageThankYou" rows="3"><%- @Ti('Thank you for your inquiry (#%s)! We\'ll contact you soon as possible.') %></textarea>
<textarea type="text" id="form-message-thank-you" name="messageThankYou" rows="3"><%- @Ti('Thank you for your inquiry (#%s)! We\'ll contact you as soon as possible.') %></textarea>
</div>
</div>
</fieldset>
@ -89,6 +89,16 @@
</span>
<%- @T('Load no CSS for form. You need to generate your own CSS for the form.') %>
</label>
<tr>
<td>
<label class="inline-label">
<span class="checkbox-replacement checkbox-replacement--inline">
<input type="checkbox" name="attachmentSupport" value="true">
<%- @Icon('checkbox', 'icon-unchecked') %>
<%- @Icon('checkbox-checked', 'icon-checked') %>
</span>
<%- @T('Add attachment option to upload.') %>
</label>
</tbody>
</table>
</form>

View file

@ -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,
}
)
}

View file

@ -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, <html lang="xx"> 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)