Skip to content

Commit

Permalink
refactoring (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
oblomov-dev authored May 5, 2024
1 parent d7f0286 commit 242c67e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 201 deletions.
10 changes: 9 additions & 1 deletion src/z2ui5_cl_demo_app_000.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,21 @@ CLASS Z2UI5_CL_DEMO_APP_000 IMPLEMENTATION.
).

panel->generic_tile(
header = 'Timer'
header = 'Timer I'
subheader = 'Wait n MS and call again the server'
press = client->_event( 'Z2UI5_CL_DEMO_APP_028' )
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel->generic_tile(
header = 'Timer II'
subheader = 'Set Loading Indicator while Server Request'
press = client->_event( 'Z2UI5_CL_DEMO_APP_064' )
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel->generic_tile(
header = 'New Tab'
subheader = 'Open an URL in a new tab'
Expand Down
9 changes: 2 additions & 7 deletions src/z2ui5_cl_demo_app_028.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ CLASS z2ui5_cl_demo_app_028 DEFINITION PUBLIC.
checkbox TYPE abap_bool,
END OF ty_row.
DATA t_tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY.

DATA mv_counter TYPE i.
* DATA mv_check_repeat TYPE abap_bool.
DATA mv_check_active TYPE abap_bool.

PROTECTED SECTION.
Expand Down Expand Up @@ -61,7 +61,6 @@ CLASS z2ui5_cl_demo_app_028 IMPLEMENTATION.
INTO TABLE t_tab.

IF mv_counter = 3.
* mv_check_repeat = abap_false.
mv_check_active = abap_false.
client->message_toast_display( `timer deactivated` ).
ENDIF.
Expand All @@ -79,7 +78,6 @@ CLASS z2ui5_cl_demo_app_028 IMPLEMENTATION.
METHOD z2ui5_on_init.

mv_counter = 1.
* mv_check_repeat = abap_true.
mv_check_active = abap_true.

t_tab = VALUE #(
Expand All @@ -95,9 +93,7 @@ CLASS z2ui5_cl_demo_app_028 IMPLEMENTATION.
lo_view->_z2ui5( )->timer(
finished = client->_event( 'TIMER_FINISHED' )
delayms = `2000`
* checkrepeat = client->_bind( mv_check_repeat )
checkactive = client->_bind( mv_check_active )
).
checkactive = client->_bind( mv_check_active ) ).

DATA(page) = lo_view->shell( )->page(
title = 'abap2UI5 - CL_GUI_TIMER - Monitor'
Expand All @@ -107,7 +103,6 @@ CLASS z2ui5_cl_demo_app_028 IMPLEMENTATION.
)->link( text = 'Demo' target = '_blank' href = `https://twitter.com/abap2UI5/status/1645816100813152256`
)->link(
text = 'Source_Code' target = '_blank'

)->get_parent( ).

page->list(
Expand Down
214 changes: 33 additions & 181 deletions src/z2ui5_cl_demo_app_064.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@ CREATE PUBLIC .
DATA mv_search_value TYPE string .
DATA mt_table TYPE ty_t_table .
DATA lv_selkz TYPE abap_bool .

DATA mv_check_active TYPE abap_bool.
DATA:
BEGIN OF screen,
progress_value TYPE string VALUE '0',
display_value TYPE string VALUE '',
END OF screen.

DATA mv_percent TYPE i.
DATA mv_check_enabled TYPE abap_bool.
PROTECTED SECTION.

DATA client TYPE REF TO z2ui5_if_client.
DATA check_initialized TYPE abap_bool.


METHODS z2ui5_on_init.
METHODS z2ui5_on_event.
METHODS z2ui5_set_search.
METHODS z2ui5_set_data.
PRIVATE SECTION.

METHODS set_selkz
Expand Down Expand Up @@ -86,46 +88,24 @@ CLASS z2ui5_cl_demo_app_064 IMPLEMENTATION.
DATA ls_arg TYPE string.

CASE client->get( )-event.
WHEN 'BUTTON_SEARCH' OR 'BUTTON_START'.
client->message_toast_display( 'Search Entries' ).
z2ui5_set_data( ).
z2ui5_set_search( ).
client->view_model_update( ).
WHEN 'SORT'.

lt_arg = client->get( )-t_event_arg.
client->message_toast_display( 'Event SORT' ).
WHEN 'FILTER'.
lt_arg = client->get( )-t_event_arg.
client->message_toast_display( 'Event FILTER' ).
WHEN 'SELKZ'.
client->message_toast_display( |'Event SELKZ' { lv_selkz } | ).
set_selkz( lv_selkz ).
client->view_model_update( ).
WHEN 'CUSTOMFILTER'.
lt_arg = client->get( )-t_event_arg.
client->message_toast_display( 'Event CUSTOMFILTER' ).
WHEN 'BACK'.
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).
WHEN 'ROWEDIT'.
lt_arg = client->get( )-t_event_arg.

READ TABLE lt_arg INTO ls_arg INDEX 1.
IF sy-subrc = 0.
client->message_toast_display( |Event ROWEDIT Row Index { ls_arg } | ).
ENDIF.
WHEN 'ROW_ACTION_ITEM_NAVIGATION'.
lt_arg = client->get( )-t_event_arg.
READ TABLE lt_arg INTO ls_arg INDEX 1.
IF sy-subrc = 0.
client->message_toast_display( |Event ROW_ACTION_ITEM_NAVIGATION Row Index { ls_arg } | ).
ENDIF.
WHEN 'ROW_ACTION_ITEM_EDIT'.
lt_arg = client->get( )-t_event_arg.
READ TABLE lt_arg INTO ls_arg INDEX 1.
IF sy-subrc = 0.
client->message_toast_display( |Event ROW_ACTION_ITEM_EDIT Row Index { ls_arg } | ).
WHEN `LOAD`.

mv_percent = mv_percent + 25.
mv_check_active = abap_true.
mv_check_enabled = abap_false.
IF mv_percent > 100.
mv_percent = 0.
mv_check_active = abap_false.
mv_check_enabled = abap_true.
ENDIF.

client->message_toast_display( `loaded` ).
WAIT UP TO 2 SECONDS.
client->view_model_update( ).

ENDCASE.

ENDMETHOD.
Expand All @@ -134,169 +114,41 @@ CLASS z2ui5_cl_demo_app_064 IMPLEMENTATION.
METHOD z2ui5_on_init.

DATA temp1 TYPE z2ui5_if_types=>ty_t_name_value.
DATA temp2 LIKE LINE OF temp1.
DATA view TYPE REF TO z2ui5_cl_xml_view.
DATA page1 TYPE REF TO z2ui5_cl_xml_view.
DATA temp5 TYPE xsdboolean.
DATA page TYPE REF TO z2ui5_cl_xml_view.
DATA header_title TYPE REF TO z2ui5_cl_xml_view.
DATA lo_box TYPE REF TO z2ui5_cl_xml_view.
DATA cont TYPE REF TO z2ui5_cl_xml_view.
DATA tab TYPE REF TO z2ui5_cl_xml_view.
DATA lo_columns TYPE REF TO z2ui5_cl_xml_view.
DATA temp3 TYPE string_table.
DATA temp4 TYPE string_table.
CLEAR temp1.

mv_check_enabled = abap_true.
view = z2ui5_cl_xml_view=>factory( ).

view->_z2ui5( )->timer(
finished = client->_event( 'LOAD' )
checkactive = client->_bind( mv_check_active )
).

temp5 = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL ).
page1 = view->page( id = 'page_main'
title = 'abap2UI5 - sap.ui.table.Table Features'
page1 = view->shell( )->page( id = 'page_main'
title = 'abap2UI5 - Progress Bar while Server Request'
navbuttonpress = client->_event( 'BACK' )
shownavbutton = temp5
class = 'sapUiContentPadding' ).

page1->header_content(
)->link(
text = 'Source_Code' target = '_blank'
).

*/
DATA layout TYPE REF TO z2ui5_cl_xml_view.
layout = page1->vertical_layout( class = 'sapuicontentpadding' width = '100%' ).
layout->vbox( )->progress_indicator(
percentvalue = client->_bind_edit( screen-progress_value )
percentvalue = client->_bind_edit( mv_percent )
displayvalue = client->_bind_edit( screen-display_value )
showvalue = abap_true
state = 'Success' ).

state = 'Success'
).
*/
page = page1->dynamic_page( headerexpanded = abap_true headerpinned = abap_true ).

header_title = page->title( ns = 'f' )->get( )->dynamic_page_title( ).
header_title->heading( ns = 'f' )->hbox( )->title( `Search Field` ).
header_title->expanded_content( 'f' ).
header_title->snapped_content( ns = 'f' ).


lo_box = page->header( )->dynamic_page_header( pinnable = abap_true
)->flex_box( alignitems = `Start` justifycontent = `SpaceBetween` )->flex_box( alignitems = `Start` ).

lo_box->vbox( )->text( `Search` )->search_field(
value = client->_bind_edit( mv_search_value )
search = client->_event( 'BUTTON_SEARCH' )
change = client->_event( 'BUTTON_SEARCH' )
livechange = client->_event( 'BUTTON_SEARCH' )
width = `17.5rem`
id = `SEARCH` ).
lo_box->get_parent( )->hbox( justifycontent = 'end' )->button(
text = 'go'
press = client->_event( 'button_start' )
type = 'emphasized' ).

cont = page->content( ns = 'f' ).

tab = cont->ui_table( rows = client->_bind( val = mt_table )
editable = abap_false
alternaterowcolors = abap_true
rowactioncount = '2'
enablegrouping = abap_false
fixedcolumncount = '1'
selectionmode = 'None'
sort = client->_event( 'SORT' )
filter = client->_event( 'FILTER' )
customfilter = client->_event( 'CUSTOMFILTER' ) ).
tab->ui_extension( )->overflow_toolbar( )->title( text = 'Products' ).

lo_columns = tab->ui_columns( ).
lo_columns->ui_column( width = '4rem' )->checkbox( selected = client->_bind_edit( lv_selkz ) enabled = abap_true select = client->_event( val = 'SELKZ' ) )->ui_template( )->checkbox( selected = '{SELKZ}' ).
lo_columns->ui_column( width = '5rem' sortproperty = 'ROW_ID'
filterproperty = 'ROW_ID' )->text( text = 'index' )->ui_template( )->text( text = '{row_id}' ).
lo_columns->ui_column( width = '11rem' sortproperty = 'CARRID' filterproperty = 'CARRID' )->text( text = 'carrid' )->ui_template( )->text( text = `{carrid}` ).
lo_columns->ui_column( width = '11rem' sortproperty = 'CONNID' filterproperty = 'CONNID')->text( text = 'connid' )->ui_template( )->text( text = `{connid}` ).
lo_columns->ui_column( width = '11rem' sortproperty = 'FLDATE' filterproperty = 'FLDATE' )->text( text = 'fldate' )->ui_template( )->text( text = `{fldate}`).
lo_columns->ui_column( width = '11rem' sortproperty = 'PLANETYPE' filterproperty = 'PLANETYPE' )->text( text = 'planetype' )->ui_template( )->text( text = `{planetype}` ).

CLEAR temp3.
INSERT `${row_id}` INTO TABLE temp3.

CLEAR temp4.
INSERT `${row_id}` INTO TABLE temp4.
lo_columns->get_parent( )->ui_row_action_template( )->ui_row_action(
)->ui_row_action_item( type = 'Navigation'
press = client->_event( val = 'ROW_ACTION_ITEM_NAVIGATION' t_arg = temp3 )
)->get_parent( )->ui_row_action_item( icon = 'sap-icon://edit' text = 'Edit' press = client->_event( val = 'ROW_ACTION_ITEM_EDIT' t_arg = temp4 ) ).

lo_columns->ui_column( width = '4rem' )->text( )->ui_template( )->overflow_toolbar( )->overflow_toolbar_button(

icon = 'sap-icon://edit' type = 'Transparent' press = client->_event(

val = `rowedit` t_arg = VALUE #( ( `${row_id}` ) ) ) ).
layout->button(
text = `Load`
press = client->_event( 'LOAD' )
enabled = client->_bind( mv_check_enabled ) ).

client->view_display( view->stringify( ) ).
ENDMETHOD.

METHOD z2ui5_set_data.

* DATA temp5 TYPE ty_t_table.
* DATA temp6 LIKE LINE OF temp5.
* CLEAR temp5.
*
**/ fetch 1
* SELECT * UP TO 10 ROWS APPENDING CORRESPONDING FIELDS OF TABLE temp5 FROM sflight.
* screen-progress_value = 25.
* screen-display_value = 'fetch 1'.
* WAIT UP TO 2 SECONDS.
**/ fetch 2
* SELECT * UP TO 10 ROWS APPENDING CORRESPONDING FIELDS OF TABLE temp5 FROM sflight.
* screen-progress_value = 50.
* screen-display_value = 'fetch 2'.
* WAIT UP TO 2 SECONDS.
**/ fetch 3
* SELECT * UP TO 10 ROWS APPENDING CORRESPONDING FIELDS OF TABLE temp5 FROM sflight.
* screen-progress_value = 75.
* screen-display_value = 'fetch 3'.
* WAIT UP TO 2 SECONDS.
**/ fetch 4
* SELECT * UP TO 10 ROWS APPENDING CORRESPONDING FIELDS OF TABLE temp5 FROM sflight.
* screen-progress_value = 100.
* screen-display_value = 'fetch 4'.
* WAIT UP TO 2 SECONDS.
*
* mt_table = temp5.
ENDMETHOD.

METHOD z2ui5_set_search.
DATA temp7 LIKE LINE OF mt_table.
DATA lr_row LIKE REF TO temp7.
DATA lv_row TYPE string.
DATA lv_index TYPE i.
FIELD-SYMBOLS <field> TYPE any.

IF mv_search_value IS NOT INITIAL.

LOOP AT mt_table REFERENCE INTO lr_row.

lv_row = ``.

lv_index = 1.
DO.

ASSIGN COMPONENT lv_index OF STRUCTURE lr_row->* TO <field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
lv_row = lv_row && <field>.
lv_index = lv_index + 1.
ENDDO.

IF lv_row NS mv_search_value.
DELETE mt_table.
ENDIF.
ENDLOOP.
ENDIF.

ENDMETHOD.
ENDCLASS.
1 change: 0 additions & 1 deletion src/z2ui5_cl_demo_app_197.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CLASS z2ui5_cl_demo_app_197 DEFINITION

PUBLIC SECTION.

INTERFACES if_serializable_object .
INTERFACES z2ui5_if_app .

TYPES:
Expand Down
22 changes: 11 additions & 11 deletions src/z2ui5_cl_demo_app_198.clas.abap
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
class Z2UI5_CL_DEMO_APP_198 definition
public
create public .
CLASS z2ui5_cl_demo_app_198 DEFINITION
PUBLIC
CREATE PUBLIC .

public section.
PUBLIC SECTION.

interfaces IF_SERIALIZABLE_OBJECT .
interfaces Z2UI5_IF_APP .
INTERFACES z2ui5_if_app .

DATA product TYPE string .
DATA quantity TYPE string .
DATA check_initialized TYPE abap_bool.

data PRODUCT type STRING .
data QUANTITY type STRING .
data CHECK_INITIALIZED type ABAP_BOOL .
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.



CLASS Z2UI5_CL_DEMO_APP_198 IMPLEMENTATION.
CLASS z2ui5_cl_demo_app_198 IMPLEMENTATION.


METHOD Z2UI5_IF_APP~MAIN.
METHOD z2ui5_if_app~main.

IF check_initialized = abap_false.
check_initialized = abap_true.
Expand Down

0 comments on commit 242c67e

Please sign in to comment.