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> <label for="form-message-thank-you"><%- @T('Message after sending form') %></label>
</div> </div>
<div class="controls"> <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>
</div> </div>
</fieldset> </fieldset>
@ -89,6 +89,16 @@
</span> </span>
<%- @T('Load no CSS for form. You need to generate your own CSS for the form.') %> <%- @T('Load no CSS for form. You need to generate your own CSS for the form.') %>
</label> </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> </tbody>
</table> </table>
</form> </form>

View file

@ -118,8 +118,7 @@ class FormController < ApplicationController
data: File.read(file.tempfile), data: File.read(file.tempfile),
filename: file.original_filename, filename: file.original_filename,
preferences: { preferences: {
'content-alternative' => true, 'Mime-Type' => file.content_type,
'Mime-Type' => file.content_type
} }
) )
} }

View file

@ -13,11 +13,12 @@ $(function() {
$('#feedback-form').ZammadForm({ $('#feedback-form').ZammadForm({
messageTitle: 'Feedback Form', // optional messageTitle: 'Feedback Form', // optional
messageSubmit: 'Submit', // optional messageSubmit: 'Submit', // optional
messageThankYou: 'Thank you for your inquiry (#%s)! We\'ll contact you soon as possible.', // 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 featrue is disabled.', // optional messageNoConfig: 'Unable to load form config from server. Maybe feature is disabled.', // optional
showTitle: true, showTitle: true,
lang: 'de', // optional, <html lang="xx"> will be used per default lang: 'de', // optional, <html lang="xx"> will be used per default
modal: true, modal: true,
attachmentSupport: false,
attributes: [ attributes: [
{ {
display: 'Name', display: 'Name',
@ -65,6 +66,7 @@ $(function() {
messageSubmit: 'Submit', messageSubmit: 'Submit',
messageThankYou: 'Thank you for your inquiry! We\'ll contact you as soon as possible.', 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.', messageNoConfig: 'Unable to load form config from server. Maybe feature is disabled.',
attachmentSupport: false,
attributes: [ attributes: [
{ {
display: 'Name', display: 'Name',
@ -95,6 +97,7 @@ $(function() {
'Email': 'E-Mail', 'Email': 'E-Mail',
'Your Email': 'Ihre E-Mail', 'Your Email': 'Ihre E-Mail',
'Message': 'Nachricht', 'Message': 'Nachricht',
'Attachments': 'Anhänge',
'Your Message...': 'Ihre Nachricht...', 'Your Message...': 'Ihre Nachricht...',
}, },
es: { es: {
@ -103,6 +106,7 @@ $(function() {
'Email': 'correo electrónico', 'Email': 'correo electrónico',
'Your Email': 'Tu correo electrónico', 'Your Email': 'Tu correo electrónico',
'Message': 'Mensaje', 'Message': 'Mensaje',
'Attachments': 'archivos adjuntos',
'Your Message...': 'tu Mensaje...', 'Your Message...': 'tu Mensaje...',
}, },
fr: { fr: {
@ -111,6 +115,7 @@ $(function() {
'Email': 'Email', 'Email': 'Email',
'Your Email': 'Votre Email', 'Your Email': 'Votre Email',
'Message': 'Message', 'Message': 'Message',
'Attachments': 'Pièces jointes',
'Your Message...': 'Votre message...', 'Your Message...': 'Votre message...',
}, },
} }
@ -157,6 +162,17 @@ $(function() {
_this.loadCss(_this.css_location) _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_config: ' + _this.endpoint_config)
_this.log('debug', 'endpoint_submit: ' + _this.endpoint_submit) _this.log('debug', 'endpoint_submit: ' + _this.endpoint_submit)