From e485853b089ec2fa4ba04679eff4d4bcc0a53d5c Mon Sep 17 00:00:00 2001 From: Molkobain Date: Fri, 12 Feb 2021 09:10:55 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B03549=20-=20Activity=20panel:=20Fix=20dra?= =?UTF-8?q?g=20/=20drop=20of=20images=20during=20object=20edition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity-panel/caselog-entry-form.js | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/js/layouts/activity-panel/caselog-entry-form.js b/js/layouts/activity-panel/caselog-entry-form.js index f7de6278ae..f7079b471d 100644 --- a/js/layouts/activity-panel/caselog-entry-form.js +++ b/js/layouts/activity-panel/caselog-entry-form.js @@ -84,11 +84,12 @@ $(function() { _bindEvents: function() { let me = this; - // Enable send button only when content - CKEDITOR.on('instanceReady', function(oEvent){ + // Handlers for the CKEditor itself + CKEDITOR.on('instanceReady', function (oEvent) { // Handle only the current CKEditor instance - if(oEvent.editor.name === me.options.text_input_id) { + if (oEvent.editor.name === me.options.text_input_id) { // Update depending elements on change + // Note: That when images are uploaded, the "change" event is triggered before the image upload is complete, meaning that we don't have the tag yet. me._GetCKEditorInstance().on('change', function () { const bWasDraftBefore = me.is_draft; const bIsDraftNow = !me._IsInputEmpty(); @@ -102,15 +103,19 @@ $(function() { me._UpdateSubmitButtonState(); } } - - // We need to keep this out of the draft check as we need to update the bridge input at character change, otherwise, only the first character will be sent - if (false === me._IsSubmitAutonomous()) { - me._UpdateBridgeInput(); - } }); } }); + if (false === this._IsSubmitAutonomous()) { + // Update the general form input on submit. + // This cannot be "completely" done in the "change" handler above because we don't have an event for when + // the image has been uploaded and its HTML markup added to the data. The "change" event occurs too early. + this._GetGeneralFormElement().on('submit', function () { + me._UpdateBridgeInput(); + }); + } + // Form buttons this.element.find(this.js_selectors.cancel_button).on('click', function (oEvent) { me.element.trigger('cancelled_form.caselog_entry_form.itop');