From ac115642cd7bb40bec6fcd7a3208c99bb3ea00dd Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 4 Aug 2022 09:55:42 +0300 Subject: [PATCH] ctrl click --- client/src/utils.js | 13 ++++++++- client/src/views/record/list.js | 47 ++++++++++++++++++--------------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/client/src/utils.js b/client/src/utils.js index 0245a5ca2f..ddaa507053 100644 --- a/client/src/utils.js +++ b/client/src/utils.js @@ -42,21 +42,32 @@ define('utils', [], function () { * Process a view event action. * * @param {module:view.Class} viewObject A view. - * @param {Event} e An event. + * @param {JQueryKeyEventObject} e An event. * @param {string} [action] An action. If not specified, will be fetched from a target element. * @param {string} [handler] A handler name. */ handleAction: function (viewObject, e, action, handler) { let $target = $(e.currentTarget); + action = action || $target.data('action'); + let fired = false; if (!action) { return; } + if (e.ctrlKey) { + let href = $target.attr('href'); + + if (href && href !== 'javascript:') { + return; + } + } + let data = $target.data(); let method = 'action' + Espo.Utils.upperCaseFirst(action); + handler = handler || data.handler; if (typeof viewObject[method] === 'function') { diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js index 4a6786a5ed..f3247c3bcd 100644 --- a/client/src/views/record/list.js +++ b/client/src/views/record/list.js @@ -426,10 +426,14 @@ function (Dep, MassActionHelper, ExportHelper) { */ events: { /** - * @param {Event} e + * @param {JQueryKeyEventObject} e * @this module:views/record/list.Class */ 'click a.link': function (e) { + if (e.ctrlKey) { + return; + } + e.stopPropagation(); if (!this.scope || this.selectable) { @@ -438,11 +442,11 @@ function (Dep, MassActionHelper, ExportHelper) { e.preventDefault(); - var id = $(e.currentTarget).attr('data-id'); - var model = this.collection.get(id); - var scope = this.getModelScope(id); + let id = $(e.currentTarget).attr('data-id'); + let model = this.collection.get(id); + let scope = this.getModelScope(id); - var options = { + let options = { id: id, model: model, }; @@ -461,20 +465,20 @@ function (Dep, MassActionHelper, ExportHelper) { this.showMoreRecords(); }, /** - * @param {Event} e + * @param {JQueryKeyEventObject} e * @this module:views/record/list.Class */ 'click a.sort': function (e) { - var field = $(e.currentTarget).data('name'); + let field = $(e.currentTarget).data('name'); this.toggleSort(field); }, /** - * @param {Event} e + * @param {JQueryKeyEventObject} e * @this module:views/record/list.Class */ 'click .pagination a': function (e) { - var page = $(e.currentTarget).data('page'); + let page = $(e.currentTarget).data('page'); if ($(e.currentTarget).parent().hasClass('disabled')) { return; @@ -483,7 +487,7 @@ function (Dep, MassActionHelper, ExportHelper) { Espo.Ui.notify(this.translate('loading', 'messages')); this.collection.once('sync', () => { - this.notify(false); + Espo.Ui.notify(false); }); if (page === 'current') { @@ -497,13 +501,13 @@ function (Dep, MassActionHelper, ExportHelper) { this.deactivate(); }, /** - * @param {Event} e + * @param {JQueryKeyEventObject} e * @this module:views/record/list.Class */ 'click .record-checkbox': function (e) { - var $target = $(e.currentTarget); + let $target = $(e.currentTarget); - var id = $target.attr('data-id'); + let id = $target.attr('data-id'); if (e.currentTarget.checked) { this.checkRecord(id, $target); @@ -512,14 +516,14 @@ function (Dep, MassActionHelper, ExportHelper) { } }, /** - * @param {Event} e + * @param {JQueryKeyEventObject} e * @this module:views/record/list.Class */ 'click .select-all': function (e) { this.selectAllHandler(e.currentTarget.checked); }, /** - * @param {Event} e + * @param {JQueryKeyEventObject} e * @this module:views/record/list.Class */ 'click .action': function (e) { @@ -532,27 +536,28 @@ function (Dep, MassActionHelper, ExportHelper) { this.selectAllResult(); }, /** - * @param {Event} e + * @param {JQueryKeyEventObject} e * @this module:views/record/list.Class */ 'click .actions-menu a.mass-action': function (e) { let $el = $(e.currentTarget); - var action = $el.data('action'); - var method = 'massAction' + Espo.Utils.upperCaseFirst(action); + let action = $el.data('action'); + let method = 'massAction' + Espo.Utils.upperCaseFirst(action); if (method in this) { this[method](); - } else { - this.massAction(action); + + return; } + + this.massAction(action); }, /** * @this module:views/record/list.Class */ 'click a.reset-custom-order': function () { this.resetCustomOrder(); - }, },