Activity panel: Fix compose button opening log picker menu when only 1 log available

This commit is contained in:
Molkobain
2022-10-01 09:28:56 +02:00
parent 4baff1b3d1
commit 1d7c527ea1

View File

@@ -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