Add attachment inputs to new conversation form
Fixes reference error to 'map' on undefined attachments list.
This commit is contained in:
parent
f7d92ccb5b
commit
aa937ae1d1
2 changed files with 11 additions and 2 deletions
|
@ -87,7 +87,9 @@
|
||||||
<div class='send-message-area'>
|
<div class='send-message-area'>
|
||||||
<div class='message-composer'>
|
<div class='message-composer'>
|
||||||
<input name='message' class='send-message' rows='6' type='textarea'>
|
<input name='message' class='send-message' rows='6' type='textarea'>
|
||||||
<div class='attachments'> Add Files </div>
|
<div class='attachments'>
|
||||||
|
<input type='file' name='files[]' multiple class='file-input'>
|
||||||
|
</div>
|
||||||
<input type='submit'>
|
<input type='submit'>
|
||||||
</div>
|
</div>
|
||||||
<div class='extension-details'>
|
<div class='extension-details'>
|
||||||
|
|
|
@ -40,6 +40,7 @@ var Whisper = Whisper || {};
|
||||||
Mustache.parse(this.template);
|
Mustache.parse(this.template);
|
||||||
this.render();
|
this.render();
|
||||||
this.input = new MessageRecipientInputView({el: this.$el.find('input.number')});
|
this.input = new MessageRecipientInputView({el: this.$el.find('input.number')});
|
||||||
|
this.fileInput = new Whisper.FileInputView({el: this.$el.find('.attachments')});
|
||||||
},
|
},
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
|
@ -53,7 +54,13 @@ var Whisper = Whisper || {};
|
||||||
if (number) {
|
if (number) {
|
||||||
var thread = Whisper.Threads.findOrCreateForRecipient(number);
|
var thread = Whisper.Threads.findOrCreateForRecipient(number);
|
||||||
var message_input = this.$el.find('input.send-message');
|
var message_input = this.$el.find('input.send-message');
|
||||||
thread.sendMessage(message_input.val());
|
var message = message_input.val();
|
||||||
|
if (message.length > 0 || this.fileInput.hasFiles()) {
|
||||||
|
this.fileInput.getFiles().then(function(attachments) {
|
||||||
|
thread.sendMessage(message, attachments);
|
||||||
|
});
|
||||||
|
message_input.val("");
|
||||||
|
}
|
||||||
this.remove();
|
this.remove();
|
||||||
thread.trigger('render');
|
thread.trigger('render');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue