shortcut next/prev

This commit is contained in:
Yuri Kuznetsov
2022-08-02 17:49:35 +03:00
parent 375454fc5d
commit 6a5f15bbc5
2 changed files with 108 additions and 0 deletions
+44
View File
@@ -94,6 +94,12 @@ define('views/modals/detail', ['views/modal', 'helpers/action-item-setup'], func
'Control+Backslash': function (e) {
this.getRecordView().handleShortcutKeyControlBackslash(e);
},
'Control+ArrowLeft': function (e) {
this.handleShortcutKeyControlArrowLeft(e);
},
'Control+ArrowRight': function (e) {
this.handleShortcutKeyControlArrowRight(e);
},
},
setup: function () {
@@ -695,5 +701,43 @@ define('views/modals/detail', ['views/modal', 'helpers/action-item-setup'], func
this.getRouter().navigate(url, {trigger: false});
});
},
/**
* @protected
* @param {JQueryKeyEventObject} e
*/
handleShortcutKeyControlArrowLeft: function (e) {
if (!this.model.collection) {
return;
}
if (this.buttonList.findIndex(item => item.name === 'previous' && !item.disabled) === -1) {
return;
}
e.preventDefault();
e.stopPropagation();
this.actionPrevious();
},
/**
* @protected
* @param {JQueryKeyEventObject} e
*/
handleShortcutKeyControlArrowRight: function (e) {
if (!this.model.collection) {
return;
}
if (this.buttonList.findIndex(item => item.name === 'next' && !item.disabled) === -1) {
return;
}
e.preventDefault();
e.stopPropagation();
this.actionNext();
},
});
});
+64
View File
@@ -440,6 +440,12 @@ function (Dep, ViewRecordHelper, ActionItemSetup) {
'Control+Backslash': function (e) {
this.handleShortcutKeyControlBackslash(e);
},
'Control+ArrowLeft': function (e) {
this.handleShortcutKeyControlArrowLeft(e);
},
'Control+ArrowRight': function (e) {
this.handleShortcutKeyControlArrowRight(e);
},
},
/**
@@ -3604,5 +3610,63 @@ function (Dep, ViewRecordHelper, ActionItemSetup) {
}, 50);
}
},
/**
* @protected
* @param {JQueryKeyEventObject} e
*/
handleShortcutKeyControlArrowLeft: function (e) {
if (this.inlineEditModeIsOn || this.buttonsDisabled) {
return;
}
if (this.navigateButtonsDisabled) {
return;
}
if (this.type !== this.TYPE_DETAIL || this.mode !== this.MODE_DETAIL) {
return;
}
let $button = this.$el.find('button[data-action="previous"]');
if (!$button.length || $button.hasClass('disabled')) {
return;
}
e.preventDefault();
e.stopPropagation();
this.actionPrevious();
},
/**
* @protected
* @param {JQueryKeyEventObject} e
*/
handleShortcutKeyControlArrowRight: function (e) {
if (this.inlineEditModeIsOn || this.buttonsDisabled) {
return;
}
if (this.navigateButtonsDisabled) {
return;
}
if (this.type !== this.TYPE_DETAIL || this.mode !== this.MODE_DETAIL) {
return;
}
let $button = this.$el.find('button[data-action="next"]');
if (!$button.length || $button.hasClass('disabled')) {
return;
}
e.preventDefault();
e.stopPropagation();
this.actionNext();
},
});
});