mirror of
https://github.com/abapGit/abapGit.git
synced 2025-05-01 12:20:51 +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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Or a SAP event input
|
||||||
|
var sUiSapEventFormAction = this.getSapEventFormAction(action);
|
||||||
|
if (sUiSapEventFormAction) {
|
||||||
|
submitSapeventForm({}, sUiSapEventFormAction, "post");
|
||||||
|
oEvent.preventDefault();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
@ -1569,32 +1577,56 @@ Hotkeys.prototype.showHotkeys = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
Hotkeys.prototype.getAllSapEventsForSapEventName = function(sSapEvent) {
|
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) {
|
Hotkeys.prototype.getSapEventHref = function(sSapEvent) {
|
||||||
|
|
||||||
return this.getAllSapEventsForSapEventName(sSapEvent)
|
return this.getAllSapEventsForSapEventName(sSapEvent)
|
||||||
|
.filter(function(el){
|
||||||
|
// only anchors
|
||||||
|
return (!!el.href);
|
||||||
|
})
|
||||||
.map(function(oSapEvent){
|
.map(function(oSapEvent){
|
||||||
return oSapEvent.href;
|
return oSapEvent.href;
|
||||||
})
|
})
|
||||||
.filter(function(sapEventHref){
|
.filter(this.eliminateSapEventFalsePositives(sSapEvent))
|
||||||
// eliminate false positives
|
|
||||||
return sapEventHref.match(new RegExp("\\b" + sSapEvent + "\\b"));
|
|
||||||
})
|
|
||||||
.pop();
|
.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){
|
Hotkeys.prototype.onkeydown = function(oEvent){
|
||||||
|
|
||||||
if (oEvent.defaultPrevented) {
|
if (oEvent.defaultPrevented) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var activeElementType = ((document.activeElement && document.activeElement.nodeName) || "");
|
if (!this.isHotkeyCallPossible()){
|
||||||
|
|
||||||
if (activeElementType === "INPUT" || activeElementType === "TEXTAREA") {
|
|
||||||
return;
|
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) {
|
Hotkeys.addHotkeyToHelpSheet = function(key, description) {
|
||||||
var hotkeysUl = document.querySelector("#hotkeys ul.hotkeys");
|
var hotkeysUl = document.querySelector("#hotkeys ul.hotkeys");
|
||||||
if (!hotkeysUl) return;
|
if (!hotkeysUl) return;
|
||||||
|
|
|
@ -15,11 +15,15 @@ CLASS zcl_abapgit_gui_hotkey_ctl DEFINITION
|
||||||
CLASS-METHODS should_show_hint
|
CLASS-METHODS should_show_hint
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_yes) TYPE abap_bool.
|
VALUE(rv_yes) TYPE abap_bool.
|
||||||
|
METHODS constructor
|
||||||
|
RAISING
|
||||||
|
zcx_abapgit_exception.
|
||||||
PROTECTED SECTION.
|
PROTECTED SECTION.
|
||||||
PRIVATE SECTION.
|
PRIVATE SECTION.
|
||||||
|
|
||||||
DATA:
|
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 .
|
CLASS-DATA gv_hint_was_shown TYPE abap_bool .
|
||||||
|
|
||||||
METHODS render_scripts
|
METHODS render_scripts
|
||||||
|
@ -33,6 +37,14 @@ ENDCLASS.
|
||||||
|
|
||||||
CLASS zcl_abapgit_gui_hotkey_ctl IMPLEMENTATION.
|
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.
|
METHOD render_scripts.
|
||||||
|
|
||||||
|
@ -97,6 +109,13 @@ CLASS zcl_abapgit_gui_hotkey_ctl IMPLEMENTATION.
|
||||||
IF sy-subrc = 0. " If found command with same hotkey
|
IF sy-subrc = 0. " If found command with same hotkey
|
||||||
DELETE mt_hotkeys INDEX sy-tabix. " Later registered commands enjoys the priority
|
DELETE mt_hotkeys INDEX sy-tabix. " Later registered commands enjoys the priority
|
||||||
ENDIF.
|
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.
|
APPEND <ls_hotkey> TO mt_hotkeys.
|
||||||
ENDLOOP.
|
ENDLOOP.
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ CLASS zcl_abapgit_gui_page_sett_remo DEFINITION
|
||||||
|
|
||||||
INTERFACES zif_abapgit_gui_event_handler .
|
INTERFACES zif_abapgit_gui_event_handler .
|
||||||
INTERFACES zif_abapgit_gui_renderable .
|
INTERFACES zif_abapgit_gui_renderable .
|
||||||
|
INTERFACES zif_abapgit_gui_hotkeys.
|
||||||
|
|
||||||
CLASS-METHODS create
|
CLASS-METHODS create
|
||||||
IMPORTING
|
IMPORTING
|
||||||
|
@ -20,7 +21,7 @@ CLASS zcl_abapgit_gui_page_sett_remo DEFINITION
|
||||||
IMPORTING
|
IMPORTING
|
||||||
!io_repo TYPE REF TO zcl_abapgit_repo
|
!io_repo TYPE REF TO zcl_abapgit_repo
|
||||||
RAISING
|
RAISING
|
||||||
zcx_abapgit_exception .
|
zcx_abapgit_exception.
|
||||||
PROTECTED SECTION.
|
PROTECTED SECTION.
|
||||||
PRIVATE 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.
|
METHOD checkout_commit_build_list.
|
||||||
|
@ -287,10 +288,10 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_SETT_REMO IMPLEMENTATION.
|
||||||
METHOD choose_branch.
|
METHOD choose_branch.
|
||||||
|
|
||||||
DATA:
|
DATA:
|
||||||
lo_repo TYPE REF TO zcl_abapgit_repo_online,
|
lo_repo TYPE REF TO zcl_abapgit_repo_online,
|
||||||
lv_url LIKE lo_repo->ms_data-url,
|
lv_url LIKE lo_repo->ms_data-url,
|
||||||
lv_branch_name LIKE lo_repo->ms_data-branch_name,
|
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.
|
IF mo_repo->is_offline( ) = abap_true.
|
||||||
RETURN.
|
RETURN.
|
||||||
|
@ -923,6 +924,40 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_SETT_REMO IMPLEMENTATION.
|
||||||
ENDMETHOD.
|
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.
|
METHOD zif_abapgit_gui_renderable~render.
|
||||||
|
|
||||||
gui_services( )->register_event_handler( me ).
|
gui_services( )->register_event_handler( me ).
|
||||||
|
@ -946,5 +981,8 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_SETT_REMO IMPLEMENTATION.
|
||||||
|
|
||||||
ri_html->add( `</div>` ).
|
ri_html->add( `</div>` ).
|
||||||
|
|
||||||
|
gui_services( )->get_hotkeys_ctl( )->register_hotkeys( zif_abapgit_gui_hotkeys~get_hotkey_actions( ) ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user