Focus HTML control on abapGit startup (#4817)

* Focus HTML control on abapGit startup 

`cl_gui_control=>set_focus` must be called during PBO. Maybe there's a nicer way to pass the HTML control to the PBO.

* Move to output form

* Set focus

* Add autofocus
This commit is contained in:
Marc Bernard 2021-06-09 17:24:59 +02:00 committed by GitHub
parent 34f350499c
commit f857194037
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 66 deletions

View File

@ -51,6 +51,7 @@ CLASS zcl_abapgit_gui DEFINITION
RAISING
zcx_abapgit_exception .
METHODS free .
METHODS set_focus .
PROTECTED SECTION.
PRIVATE SECTION.
@ -106,7 +107,7 @@ ENDCLASS.
CLASS ZCL_ABAPGIT_GUI IMPLEMENTATION.
CLASS zcl_abapgit_gui IMPLEMENTATION.
METHOD back.
@ -367,6 +368,11 @@ CLASS ZCL_ABAPGIT_GUI IMPLEMENTATION.
ENDMETHOD.
METHOD set_focus.
cl_gui_control=>set_focus( mi_html_viewer->get_viewer( ) ).
ENDMETHOD.
METHOD startup.
DATA: lt_events TYPE cntl_simple_events,

View File

@ -26,6 +26,7 @@ CLASS zcl_abapgit_gui_page_repo_over DEFINITION
PRIVATE SECTION.
TYPES:
BEGIN OF ty_overview,
favorite TYPE string,
@ -41,82 +42,78 @@ CLASS zcl_abapgit_gui_page_repo_over DEFINITION
deserialized_by TYPE xubname,
deserialized_at TYPE string,
write_protected TYPE abap_bool,
END OF ty_overview,
END OF ty_overview .
TYPES:
ty_overviews TYPE STANDARD TABLE OF ty_overview
WITH NON-UNIQUE DEFAULT KEY.
WITH NON-UNIQUE DEFAULT KEY .
CONSTANTS:
BEGIN OF c_action,
select TYPE string VALUE 'select',
apply_filter TYPE string VALUE 'apply_filter',
END OF c_action .
DATA mv_order_descending TYPE abap_bool .
DATA mv_filter TYPE string .
DATA mv_time_zone TYPE timezone .
DATA mt_col_spec TYPE zif_abapgit_definitions=>ty_col_spec_tt .
DATA mt_overview TYPE ty_overviews .
DATA: mv_order_descending TYPE abap_bool,
mv_filter TYPE string,
mv_time_zone TYPE timezone,
mt_col_spec TYPE zif_abapgit_definitions=>ty_col_spec_tt,
mt_overview TYPE ty_overviews.
METHODS: render_text_input
IMPORTING iv_name TYPE string
iv_label TYPE string
iv_value TYPE string OPTIONAL
iv_max_length TYPE string OPTIONAL
RETURNING VALUE(ri_html) TYPE REF TO zif_abapgit_html,
apply_filter
CHANGING
ct_overview TYPE ty_overviews,
map_repo_list_to_overview
RETURNING
VALUE(rt_overview) TYPE ty_overviews
RAISING
zcx_abapgit_exception,
render_table_header
IMPORTING
ii_html TYPE REF TO zif_abapgit_html,
render_table
IMPORTING
ii_html TYPE REF TO zif_abapgit_html
it_overview TYPE ty_overviews
RAISING
zcx_abapgit_exception,
render_table_body
IMPORTING
ii_html TYPE REF TO zif_abapgit_html
it_overview TYPE ty_overviews
RAISING
zcx_abapgit_exception,
render_header_bar
IMPORTING
ii_html TYPE REF TO zif_abapgit_html,
apply_order_by
CHANGING ct_overview TYPE ty_overviews,
_add_column
IMPORTING
iv_tech_name TYPE string OPTIONAL
iv_display_name TYPE string OPTIONAL
iv_css_class TYPE string OPTIONAL
iv_add_tz TYPE abap_bool OPTIONAL
iv_title TYPE string OPTIONAL
iv_allow_order_by TYPE any OPTIONAL.
METHODS render_text_input
IMPORTING
!iv_name TYPE string
!iv_label TYPE string
!iv_value TYPE string OPTIONAL
!iv_max_length TYPE string OPTIONAL
!iv_autofocus TYPE abap_bool DEFAULT abap_false
RETURNING
VALUE(ri_html) TYPE REF TO zif_abapgit_html .
METHODS apply_filter
CHANGING
!ct_overview TYPE ty_overviews .
METHODS map_repo_list_to_overview
RETURNING
VALUE(rt_overview) TYPE ty_overviews
RAISING
zcx_abapgit_exception .
METHODS render_table_header
IMPORTING
!ii_html TYPE REF TO zif_abapgit_html .
METHODS render_table
IMPORTING
!ii_html TYPE REF TO zif_abapgit_html
!it_overview TYPE ty_overviews
RAISING
zcx_abapgit_exception .
METHODS render_table_body
IMPORTING
!ii_html TYPE REF TO zif_abapgit_html
!it_overview TYPE ty_overviews
RAISING
zcx_abapgit_exception .
METHODS render_header_bar
IMPORTING
!ii_html TYPE REF TO zif_abapgit_html .
METHODS apply_order_by
CHANGING
!ct_overview TYPE ty_overviews .
METHODS _add_column
IMPORTING
!iv_tech_name TYPE string OPTIONAL
!iv_display_name TYPE string OPTIONAL
!iv_css_class TYPE string OPTIONAL
!iv_add_tz TYPE abap_bool OPTIONAL
!iv_title TYPE string OPTIONAL
!iv_allow_order_by TYPE any OPTIONAL .
METHODS render_scripts
RETURNING
VALUE(ri_html) TYPE REF TO zif_abapgit_html
RAISING
zcx_abapgit_exception.
zcx_abapgit_exception .
ENDCLASS.
CLASS ZCL_ABAPGIT_GUI_PAGE_REPO_OVER IMPLEMENTATION.
CLASS zcl_abapgit_gui_page_repo_over IMPLEMENTATION.
METHOD apply_filter.
@ -239,9 +236,10 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_REPO_OVER IMPLEMENTATION.
ii_html->add( |<form class="inline" method="post" action="sapevent:{ c_action-apply_filter }">| ).
ii_html->add( render_text_input(
iv_name = |filter|
iv_label = |Filter: |
iv_value = mv_filter ) ).
iv_name = |filter|
iv_label = |Filter: |
iv_value = mv_filter
iv_autofocus = abap_true ) ).
ii_html->add( |<input type="submit" class="hidden-submit">| ).
ii_html->add( |</form>| ).
@ -549,7 +547,11 @@ CLASS ZCL_ABAPGIT_GUI_PAGE_REPO_OVER IMPLEMENTATION.
ENDIF.
IF iv_max_length IS NOT INITIAL.
lv_attrs = | maxlength="{ iv_max_length }"|.
lv_attrs = lv_attrs && | maxlength="{ iv_max_length }"|.
ENDIF.
IF iv_autofocus = abap_true.
lv_attrs = lv_attrs && | autofocus|.
ENDIF.
ri_html->add( |<label for="{ iv_name }">{ iv_label }</label>| ).

View File

@ -94,6 +94,11 @@ CLASS zcl_abapgit_html_viewer_gui IMPLEMENTATION.
ENDMETHOD.
METHOD zif_abapgit_html_viewer~get_viewer.
ro_result = mo_html_viewer.
ENDMETHOD.
METHOD zif_abapgit_html_viewer~load_data.
mo_html_viewer->load_data(

View File

@ -49,4 +49,7 @@ INTERFACE zif_abapgit_html_viewer
VALUE(rv_url) TYPE w3url.
METHODS back .
METHODS set_visiblity IMPORTING iv_visible TYPE abap_bool.
METHODS get_viewer
RETURNING
VALUE(ro_result) TYPE REF TO cl_gui_html_viewer .
ENDINTERFACE.

View File

@ -86,6 +86,7 @@ FORM output.
TABLES
p_exclude = lt_ucomm.
zcl_abapgit_ui_factory=>get_gui( )->set_focus( ).
ENDFORM.
FORM exit RAISING zcx_abapgit_exception.