mirror of
https://github.com/abapGit/abapGit.git
synced 2025-04-30 20:03:20 +08:00
New hotkeys for remote settings page (#5083)
* New hotkeys for remote settings page * Enable hotkeys for non-input fields * Prioritize link hint activation key over hotkey * cleanup * resolve 2 * resolve 3 Co-authored-by: Marc Bernard <59966492+mbtools@users.noreply.github.com>
This commit is contained in:
parent
c0ad1a96d0
commit
882ef7dc8d
|
@ -1554,6 +1554,14 @@ function Hotkeys(oKeyMap){
|
|||
return;
|
||||
}
|
||||
|
||||
// Or a SAP event input
|
||||
var sUiSapEventFormAction = this.getSapEventFormAction(action);
|
||||
if (sUiSapEventFormAction) {
|
||||
submitSapeventForm({}, sUiSapEventFormAction, "post");
|
||||
oEvent.preventDefault();
|
||||
return;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}.bind(this));
|
||||
|
@ -1569,32 +1577,56 @@ Hotkeys.prototype.showHotkeys = function() {
|
|||
};
|
||||
|
||||
Hotkeys.prototype.getAllSapEventsForSapEventName = function(sSapEvent) {
|
||||
return [].slice.call(document.querySelectorAll('a[href*="sapevent:' + sSapEvent + '"], a[href*="SAPEVENT:' + sSapEvent + '"]'));
|
||||
return [].slice.call(
|
||||
document.querySelectorAll('a[href*="sapevent:' + sSapEvent + '"],'
|
||||
+ 'a[href*="SAPEVENT:' + sSapEvent + '"],'
|
||||
+ 'input[formaction*="sapevent:' + sSapEvent + '"],'
|
||||
+ 'input[formaction*="SAPEVENT:' + sSapEvent + '"]'));
|
||||
};
|
||||
|
||||
Hotkeys.prototype.getSapEventHref = function(sSapEvent) {
|
||||
|
||||
return this.getAllSapEventsForSapEventName(sSapEvent)
|
||||
.filter(function(el){
|
||||
// only anchors
|
||||
return (!!el.href);
|
||||
})
|
||||
.map(function(oSapEvent){
|
||||
return oSapEvent.href;
|
||||
})
|
||||
.filter(function(sapEventHref){
|
||||
// eliminate false positives
|
||||
return sapEventHref.match(new RegExp("\\b" + sSapEvent + "\\b"));
|
||||
})
|
||||
.filter(this.eliminateSapEventFalsePositives(sSapEvent))
|
||||
.pop();
|
||||
|
||||
};
|
||||
|
||||
Hotkeys.prototype.getSapEventFormAction = function(sSapEvent) {
|
||||
|
||||
return this.getAllSapEventsForSapEventName(sSapEvent)
|
||||
.filter(function(el){
|
||||
// input forms
|
||||
return (el.type === "submit");
|
||||
})
|
||||
.map(function(oSapEvent){
|
||||
return oSapEvent.formAction;
|
||||
})
|
||||
.filter(this.eliminateSapEventFalsePositives(sSapEvent))
|
||||
.pop();
|
||||
|
||||
};
|
||||
|
||||
Hotkeys.prototype.eliminateSapEventFalsePositives = function(sapEvent){
|
||||
return function(sapEventAttr) {
|
||||
return sapEventAttr.match(new RegExp("\\b" + sapEvent + "\\b"));
|
||||
};
|
||||
};
|
||||
|
||||
Hotkeys.prototype.onkeydown = function(oEvent){
|
||||
|
||||
if (oEvent.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
|
||||
var activeElementType = ((document.activeElement && document.activeElement.nodeName) || "");
|
||||
|
||||
if (activeElementType === "INPUT" || activeElementType === "TEXTAREA") {
|
||||
if (!this.isHotkeyCallPossible()){
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1607,6 +1639,14 @@ Hotkeys.prototype.onkeydown = function(oEvent){
|
|||
}
|
||||
};
|
||||
|
||||
Hotkeys.prototype.isHotkeyCallPossible = function(){
|
||||
|
||||
var activeElementType = ((document.activeElement && document.activeElement.nodeName) || "");
|
||||
var activeElementReadOnly = ((document.activeElement && document.activeElement.readOnly) || false);
|
||||
|
||||
return (activeElementReadOnly || ( activeElementType !== "INPUT" && activeElementType !== "TEXTAREA" ));
|
||||
};
|
||||
|
||||
Hotkeys.addHotkeyToHelpSheet = function(key, description) {
|
||||
var hotkeysUl = document.querySelector("#hotkeys ul.hotkeys");
|
||||
if (!hotkeysUl) return;
|
||||
|
|
|
@ -15,11 +15,15 @@ CLASS zcl_abapgit_gui_hotkey_ctl DEFINITION
|
|||
CLASS-METHODS should_show_hint
|
||||
RETURNING
|
||||
VALUE(rv_yes) TYPE abap_bool.
|
||||
METHODS constructor
|
||||
RAISING
|
||||
zcx_abapgit_exception.
|
||||
PROTECTED SECTION.
|
||||
PRIVATE SECTION.
|
||||
|
||||
DATA:
|
||||
mt_hotkeys TYPE zif_abapgit_gui_hotkeys=>ty_hotkeys_with_descr.
|
||||
mt_hotkeys TYPE zif_abapgit_gui_hotkeys=>ty_hotkeys_with_descr,
|
||||
ms_user_settings TYPE zif_abapgit_definitions=>ty_s_user_settings.
|
||||
CLASS-DATA gv_hint_was_shown TYPE abap_bool .
|
||||
|
||||
METHODS render_scripts
|
||||
|
@ -33,6 +37,14 @@ ENDCLASS.
|
|||
|
||||
CLASS zcl_abapgit_gui_hotkey_ctl IMPLEMENTATION.
|
||||
|
||||
METHOD constructor.
|
||||
|
||||
super->constructor( ).
|
||||
|
||||
ms_user_settings = zcl_abapgit_persistence_user=>get_instance( )->get_settings( ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD render_scripts.
|
||||
|
||||
|
@ -97,6 +109,13 @@ CLASS zcl_abapgit_gui_hotkey_ctl IMPLEMENTATION.
|
|||
IF sy-subrc = 0. " If found command with same hotkey
|
||||
DELETE mt_hotkeys INDEX sy-tabix. " Later registered commands enjoys the priority
|
||||
ENDIF.
|
||||
|
||||
IF ms_user_settings-link_hints_enabled = abap_true
|
||||
AND ms_user_settings-link_hint_key = <ls_hotkey>-hotkey.
|
||||
" Link hint activation key is more important
|
||||
CONTINUE.
|
||||
ENDIF.
|
||||
|
||||
APPEND <ls_hotkey> TO mt_hotkeys.
|
||||
ENDLOOP.
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ CLASS zcl_abapgit_gui_page_sett_remo DEFINITION
|
|||
|
||||
INTERFACES zif_abapgit_gui_event_handler .
|
||||
INTERFACES zif_abapgit_gui_renderable .
|
||||
INTERFACES zif_abapgit_gui_hotkeys.
|
||||
|
||||
CLASS-METHODS create
|
||||
IMPORTING
|
||||
|
@ -20,7 +21,7 @@ CLASS zcl_abapgit_gui_page_sett_remo DEFINITION
|
|||
IMPORTING
|
||||
!io_repo TYPE REF TO zcl_abapgit_repo
|
||||
RAISING
|
||||
zcx_abapgit_exception .
|
||||
zcx_abapgit_exception.
|
||||
PROTECTED SECTION.
|
||||
PRIVATE SECTION.
|
||||
|
||||
|
@ -171,7 +172,7 @@ ENDCLASS.
|
|||
|
||||
|
||||
|
||||
CLASS ZCL_ABAPGIT_GUI_PAGE_SETT_REMO IMPLEMENTATION.
|
||||
CLASS zcl_abapgit_gui_page_sett_remo IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD checkout_commit_build_list.
|
||||
|
@ -287,10 +288,10 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_SETT_REMO IMPLEMENTATION.
|
|||
METHOD choose_branch.
|
||||
|
||||
DATA:
|
||||
lo_repo TYPE REF TO zcl_abapgit_repo_online,
|
||||
lv_url LIKE lo_repo->ms_data-url,
|
||||
lo_repo TYPE REF TO zcl_abapgit_repo_online,
|
||||
lv_url LIKE lo_repo->ms_data-url,
|
||||
lv_branch_name LIKE lo_repo->ms_data-branch_name,
|
||||
ls_branch TYPE zif_abapgit_definitions=>ty_git_branch.
|
||||
ls_branch TYPE zif_abapgit_definitions=>ty_git_branch.
|
||||
|
||||
IF mo_repo->is_offline( ) = abap_true.
|
||||
RETURN.
|
||||
|
@ -923,6 +924,40 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_SETT_REMO IMPLEMENTATION.
|
|||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD zif_abapgit_gui_hotkeys~get_hotkey_actions.
|
||||
|
||||
DATA: ls_hotkey_action LIKE LINE OF rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-ui_component = 'Remote'.
|
||||
|
||||
ls_hotkey_action-description = |Choose branch|.
|
||||
ls_hotkey_action-action = c_event-choose_branch.
|
||||
ls_hotkey_action-hotkey = |b|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Choose commit|.
|
||||
ls_hotkey_action-action = c_event-choose_commit.
|
||||
ls_hotkey_action-hotkey = |c|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Choose pull request|.
|
||||
ls_hotkey_action-action = c_event-choose_pull_req.
|
||||
ls_hotkey_action-hotkey = |p|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Choose tag|.
|
||||
ls_hotkey_action-action = c_event-choose_tag.
|
||||
ls_hotkey_action-hotkey = |t|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ls_hotkey_action-description = |Choose url|.
|
||||
ls_hotkey_action-action = c_event-choose_url.
|
||||
ls_hotkey_action-hotkey = |u|.
|
||||
INSERT ls_hotkey_action INTO TABLE rt_hotkey_actions.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD zif_abapgit_gui_renderable~render.
|
||||
|
||||
gui_services( )->register_event_handler( me ).
|
||||
|
@ -946,5 +981,8 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_SETT_REMO IMPLEMENTATION.
|
|||
|
||||
ri_html->add( `</div>` ).
|
||||
|
||||
gui_services( )->get_hotkeys_ctl( )->register_hotkeys( zif_abapgit_gui_hotkeys~get_hotkey_actions( ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
|
Loading…
Reference in New Issue
Block a user