shortcut switch tabs

This commit is contained in:
Yuri Kuznetsov
2022-08-01 15:41:14 +03:00
parent 048a75ff67
commit e93ff18b4c
+39 -1
View File
@@ -437,6 +437,9 @@ function (Dep, ViewRecordHelper, ActionItemSetup) {
'Escape': function (e) {
this.handleShortcutKeyEscape(e);
},
'Control+Backslash': function (e) {
this.handleShortcutKeyControlBackslash(e);
},
},
/**
@@ -3506,7 +3509,7 @@ function (Dep, ViewRecordHelper, ActionItemSetup) {
*/
focusForEdit: function () {
this.$el
.find('.middle-tabs > button.active, .form-control:not([disabled])')
.find('.field:not(.hidden) .form-control:not([disabled])')
.first()
.focus();
},
@@ -3555,5 +3558,40 @@ function (Dep, ViewRecordHelper, ActionItemSetup) {
* @param {JQueryKeyEventObject} e
*/
handleShortcutKeyCtrlAltEnter: function (e) {},
/**
* @protected
* @param {JQueryKeyEventObject} e
*/
handleShortcutKeyControlBackslash: function (e) {
if (!this.hasMiddleTabs()) {
return;
}
let $buttons = this.$el.find('.middle-tabs > button:not(.hidden)');
let index = $buttons.toArray().findIndex(el => $(el).hasClass('active'));
index++;
if (index >= $buttons.length) {
index = 0;
}
let $tab = $($buttons.get(index));
let tab = parseInt($tab.attr('data-tab'));
this.selectMiddleTab(tab);
if (this.mode === this.MODE_EDIT) {
setTimeout(() => {
this.$middle
.find(`.panel[data-tab="${tab}"] .cell:not(.hidden)`)
.first()
.focus();
}, 50);
}
},
});
});