FIX: too many upload placeholders when uploading several files

This commit is contained in:
Régis Hanol 2016-07-06 17:58:11 +02:00
parent 3035d144c0
commit ee2780466c
3 changed files with 9 additions and 7 deletions

View File

@ -203,9 +203,8 @@ export default Ember.Component.extend({
$element.on("fileuploadsend", (e, data) => { $element.on("fileuploadsend", (e, data) => {
this._validUploads++; this._validUploads++;
// add upload placeholders (as much placeholders as valid files dropped) // add upload placeholders
const placeholder = _.times(this._validUploads, () => uploadPlaceholder).join("\n"); this.appEvents.trigger('composer:insert-text', uploadPlaceholder);
this.appEvents.trigger('composer:insert-text', placeholder);
if (data.xhr && data.originalFiles.length === 1) { if (data.xhr && data.originalFiles.length === 1) {
this.set("isCancellable", true); this.set("isCancellable", true);

View File

@ -472,10 +472,14 @@ export default Ember.Component.extend({
}, },
_addText(sel, text) { _addText(sel, text) {
const $textarea = this.$('textarea.d-editor-input');
const insert = `${sel.pre}${text}`; const insert = `${sel.pre}${text}`;
this.set('value', `${insert}${sel.post}`); const value = `${insert}${sel.post}`;
this._selectText(insert.length, 0); this.set('value', value);
Ember.run.scheduleOnce("afterRender", () => this.$("textarea.d-editor-input").focus()); $textarea.val(value);
$textarea.prop("selectionStart", insert.length);
$textarea.prop("selectionEnd", insert.length);
Ember.run.scheduleOnce("afterRender", () => $textarea.focus());
}, },
actions: { actions: {

View File

@ -22,7 +22,6 @@ const ComposerView = Ember.View.extend({
}, },
movePanels(sizePx) { movePanels(sizePx) {
$('#main-outlet').css('padding-bottom', sizePx); $('#main-outlet').css('padding-bottom', sizePx);
// signal the progress bar it should move! // signal the progress bar it should move!