From 1d7c527ea196aee94ebba4f08fcb02d016c0541e Mon Sep 17 00:00:00 2001 From: Molkobain Date: Sat, 1 Oct 2022 09:28:56 +0200 Subject: [PATCH] Activity panel: Fix compose button opening log picker menu when only 1 log available --- js/layouts/activity-panel/activity-panel.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/js/layouts/activity-panel/activity-panel.js b/js/layouts/activity-panel/activity-panel.js index c2dc1b5c4..dc8219b30 100644 --- a/js/layouts/activity-panel/activity-panel.js +++ b/js/layouts/activity-panel/activity-panel.js @@ -363,13 +363,22 @@ $(function() const oActiveTabData = this._GetActiveTabData(); // If on a caselog tab, open its form if it has one if ((this.enums.tab_types.caselog === oActiveTabData.type) && this._HasCaseLogEntryFormForTab(oActiveTabData.att_code)) { - // Note: Stop propogation to avoid the menu to be opened automatically by the popover handler, we will decide when it can opens below + // Note: Stop propagation to avoid the menu to be opened automatically by the popover handler oEvent.stopImmediatePropagation(); this._ShowCaseLogTab(oActiveTabData.att_code); this._ShowCaseLogsEntryForms(); this._SetFocusInCaseLogEntryForm(oActiveTabData.att_code); } + // Else (activity tab) if only 1 clog tab, open it directly + else if (this._GetCaseLogEntryFormCount() === 1) { + // Note: Stop propagation to avoid the menu to be opened automatically by the popover handler + oEvent.stopImmediatePropagation(); + + // Simulate click on the only menu item + this.element.find(this.js_selectors.compose_menu_item+':first').trigger('click'); + } + // Else, the compose menu will open automatically }, /** @@ -737,6 +746,14 @@ $(function() }, // - Helpers on case logs entry forms + /** + * @returns {integer} The number of caselog entry form + * @private + * @since 3.1.0 + */ + _GetCaseLogEntryFormCount: function () { + return this.element.find(this.js_selectors.caselog_entry_form).length; + }, /** * @param sCaseLogAttCode {string} * @returns {boolean} Return true if there is a case log for entry for the sCaseLogAttCode tab