ctrl click

This commit is contained in:
Yuri Kuznetsov
2022-08-04 09:55:42 +03:00
parent 41af71ebf3
commit ac115642cd
2 changed files with 38 additions and 22 deletions

View File

@@ -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') {

View File

@@ -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();
},
},