From 64d939e125e80c305bdce9db29ef1b4e45adfd7a Mon Sep 17 00:00:00 2001 From: oblomov <102328295+oblomov-dev@users.noreply.github.com> Date: Mon, 10 Apr 2023 19:30:47 +0200 Subject: [PATCH] gen data binding (#151) * bugfixes * bugfixes * geeric binding * binding gen data * abaplint fixes * abaplint fixes --- src/00/z2ui5_cl_app_demo_01.clas.abap | 2 - src/00/z2ui5_cl_app_demo_02.clas.abap | 2 +- src/00/z2ui5_cl_app_demo_04.clas.abap | 10 +- src/00/z2ui5_cl_app_demo_05.clas.abap | 13 +- src/00/z2ui5_cl_app_demo_06.clas.abap | 2 +- src/00/z2ui5_cl_app_demo_07.clas.abap | 2 +- src/00/z2ui5_cl_app_demo_08.clas.abap | 2 +- src/00/z2ui5_cl_app_demo_13.clas.abap | 6 +- src/00/z2ui5_cl_app_demo_14.clas.abap | 2 +- src/00/z2ui5_cl_app_demo_15.clas.abap | 3 +- src/00/z2ui5_cl_app_demo_16.clas.abap | 2 +- src/00/z2ui5_cl_app_demo_18.clas.abap | 2 +- src/00/z2ui5_cl_app_demo_28.clas.abap | 126 +++++++++------ src/00/z2ui5_cl_app_demo_28.clas.xml | 2 +- src/z2ui5_cl_http_handler.clas.abap | 17 +-- ...z2ui5_cl_http_handler.clas.locals_imp.abap | 143 ++++++++++++++++-- src/z2ui5_if_client.intf.abap | 5 +- 17 files changed, 239 insertions(+), 102 deletions(-) diff --git a/src/00/z2ui5_cl_app_demo_01.clas.abap b/src/00/z2ui5_cl_app_demo_01.clas.abap index f221d23f..ca393831 100644 --- a/src/00/z2ui5_cl_app_demo_01.clas.abap +++ b/src/00/z2ui5_cl_app_demo_01.clas.abap @@ -46,8 +46,6 @@ CLASS z2ui5_cl_app_demo_01 IMPLEMENTATION. )->content( 'form' )->title( 'Input' )->label( 'quantity' - )->input( client->_bind( quantity ) - )->label( 'quantity' )->input( client->_bind( quantity ) )->label( 'product' )->input( diff --git a/src/00/z2ui5_cl_app_demo_02.clas.abap b/src/00/z2ui5_cl_app_demo_02.clas.abap index eadf2b60..1e5bbffb 100644 --- a/src/00/z2ui5_cl_app_demo_02.clas.abap +++ b/src/00/z2ui5_cl_app_demo_02.clas.abap @@ -109,7 +109,7 @@ CLASS Z2UI5_CL_APP_DEMO_02 IMPLEMENTATION. METHOD z2ui5_on_rendering. - DATA(page) = z2ui5_cl_xml_view_helper=>factory( + DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - Selection-Screen Example' navbuttonpress = client->_event( 'BACK' ) diff --git a/src/00/z2ui5_cl_app_demo_04.clas.abap b/src/00/z2ui5_cl_app_demo_04.clas.abap index 987883c3..815139ea 100644 --- a/src/00/z2ui5_cl_app_demo_04.clas.abap +++ b/src/00/z2ui5_cl_app_demo_04.clas.abap @@ -77,11 +77,11 @@ CLASS Z2UI5_CL_APP_DEMO_04 IMPLEMENTATION. WHEN 'MAIN'. - DATA(page) = z2ui5_cl_xml_view_helper=>factory( + DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - Controller' navbuttonpress = client->_event( 'BACK' ) - shownavbutton = abap_true + shownavbutton = abap_true )->header_content( )->link( text = 'Source_Code' @@ -109,10 +109,12 @@ CLASS Z2UI5_CL_APP_DEMO_04 IMPLEMENTATION. WHEN 'SECOND'. - page = z2ui5_cl_xml_view_helper=>factory( + page = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - Controller' - navbuttonpress = client->_event( 'BACK' ) ). + navbuttonpress = client->_event( 'BACK' ) + shownavbutton = abap_true + ). page->grid( 'L12 M12 S12' )->content( 'l' )->simple_form( 'View Second' )->content( 'form' diff --git a/src/00/z2ui5_cl_app_demo_05.clas.abap b/src/00/z2ui5_cl_app_demo_05.clas.abap index 40a1c9c4..c3a4b4b4 100644 --- a/src/00/z2ui5_cl_app_demo_05.clas.abap +++ b/src/00/z2ui5_cl_app_demo_05.clas.abap @@ -33,6 +33,7 @@ CLASS z2ui5_cl_app_demo_05 DEFINITION PUBLIC. end of ty_S_token. data mt_token type STANDARD TABLE OF ty_S_token with empty key. + data mt_token_sugg type STANDARD TABLE OF ty_S_token with empty key. PROTECTED SECTION. PRIVATE SECTION. @@ -50,11 +51,17 @@ CLASS Z2UI5_CL_APP_DEMO_05 IMPLEMENTATION. mt_token = value #( ( key = 'VAL1' text = 'value_1' selkz = abap_true visible = abap_true ) - ( key = 'VAL2' text = 'value_2' selkz = abap_false ) ( key = 'VAL3' text = 'value_3' selkz = abap_false visible = abap_true ) ( key = 'VAL4' text = 'value_4' selkz = abap_true ) ). + mt_token_sugg = value #( + ( key = 'VAL1' text = 'value_1' ) + ( key = 'VAL2' text = 'value_2' ) + ( key = 'VAL3' text = 'value_3' ) + ( key = 'VAL4' text = 'value_4' ) + ). + screen = VALUE #( check_initialized = abap_true check_is_active = abap_true @@ -84,7 +91,7 @@ CLASS Z2UI5_CL_APP_DEMO_05 IMPLEMENTATION. ENDCASE. - DATA(page) = z2ui5_cl_xml_view_helper=>factory( + DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - Selection-Screen more Controls' navbuttonpress = client->_event( 'BACK' ) @@ -165,7 +172,7 @@ CLASS Z2UI5_CL_APP_DEMO_05 IMPLEMENTATION. tokens = client->_bind( mt_token ) showclearicon = abap_true showvaluehelp = abap_true - suggestionitems = client->_bind_one( mt_token ) + suggestionitems = client->_bind( mt_token_sugg ) )->item( key = `{KEY}` text = `{TEXT}` diff --git a/src/00/z2ui5_cl_app_demo_06.clas.abap b/src/00/z2ui5_cl_app_demo_06.clas.abap index 728281f5..d3b81714 100644 --- a/src/00/z2ui5_cl_app_demo_06.clas.abap +++ b/src/00/z2ui5_cl_app_demo_06.clas.abap @@ -73,7 +73,7 @@ CLASS Z2UI5_CL_APP_DEMO_06 IMPLEMENTATION. ENDCASE. - DATA(page) = z2ui5_cl_xml_view_helper=>factory( + DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - Scroll Container with Table and Toolbar' navbuttonpress = client->_event( 'BACK' ) diff --git a/src/00/z2ui5_cl_app_demo_07.clas.abap b/src/00/z2ui5_cl_app_demo_07.clas.abap index 6c9db1b3..610dc070 100644 --- a/src/00/z2ui5_cl_app_demo_07.clas.abap +++ b/src/00/z2ui5_cl_app_demo_07.clas.abap @@ -184,7 +184,7 @@ CLASS z2ui5_cl_app_demo_07 IMPLEMENTATION. METHOD ui5_render_view_main. - DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->page( + DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - File Upload/Download' navbuttonpress = client->_event( 'BACK' ) shownavbutton = abap_true diff --git a/src/00/z2ui5_cl_app_demo_08.clas.abap b/src/00/z2ui5_cl_app_demo_08.clas.abap index 7765f545..37c79f08 100644 --- a/src/00/z2ui5_cl_app_demo_08.clas.abap +++ b/src/00/z2ui5_cl_app_demo_08.clas.abap @@ -52,7 +52,7 @@ CLASS Z2UI5_CL_APP_DEMO_08 IMPLEMENTATION. ENDCASE. - DATA(page) = z2ui5_cl_xml_view_helper=>factory( + DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - Messages' navbuttonpress = client->_event( 'BACK' ) diff --git a/src/00/z2ui5_cl_app_demo_13.clas.abap b/src/00/z2ui5_cl_app_demo_13.clas.abap index 0a052058..73fa6ded 100644 --- a/src/00/z2ui5_cl_app_demo_13.clas.abap +++ b/src/00/z2ui5_cl_app_demo_13.clas.abap @@ -159,7 +159,7 @@ CLASS Z2UI5_CL_APP_DEMO_13 IMPLEMENTATION. METHOD z2ui5_on_render_view_edit. - DATA(page) = z2ui5_cl_xml_view_helper=>factory( + DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2ui5 - Table Maintenance' navbuttonpress = client->_event( 'BACK' ) @@ -247,7 +247,7 @@ CLASS Z2UI5_CL_APP_DEMO_13 IMPLEMENTATION. METHOD z2ui5_on_render_view_export. - DATA(page) = z2ui5_cl_xml_view_helper=>factory( + DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2ui5 - Table Maintenance' navbuttonpress = client->_event( 'BACK' ) @@ -311,7 +311,7 @@ CLASS Z2UI5_CL_APP_DEMO_13 IMPLEMENTATION. METHOD z2ui5_on_render_view_import. - DATA(page) = z2ui5_cl_xml_view_helper=>factory( + DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - Table Maintenance' navbuttonpress = client->_event( 'BACK' ) diff --git a/src/00/z2ui5_cl_app_demo_14.clas.abap b/src/00/z2ui5_cl_app_demo_14.clas.abap index 22356ad0..d79f569d 100644 --- a/src/00/z2ui5_cl_app_demo_14.clas.abap +++ b/src/00/z2ui5_cl_app_demo_14.clas.abap @@ -51,7 +51,7 @@ CLASS Z2UI5_CL_APP_DEMO_14 IMPLEMENTATION. client->nav_app_leave( client->get_app( client->get( )-id_prev_app_stack ) ). ENDCASE. - DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->page( + DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - MIME Editor' navbuttonpress = client->_event( 'BACK' ) shownavbutton = abap_true diff --git a/src/00/z2ui5_cl_app_demo_15.clas.abap b/src/00/z2ui5_cl_app_demo_15.clas.abap index 4d3a2e47..3e49febe 100644 --- a/src/00/z2ui5_cl_app_demo_15.clas.abap +++ b/src/00/z2ui5_cl_app_demo_15.clas.abap @@ -31,9 +31,10 @@ CLASS Z2UI5_CL_APP_DEMO_15 IMPLEMENTATION. CASE client->get( )-event. WHEN 'BACK'. client->nav_app_leave( client->get_app( client->get( )-id_prev_app_stack ) ). + ENDCASE. - data(view) = z2ui5_cl_xml_view_helper=>factory( + data(view) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - Formatted Text' navbuttonpress = client->_event( 'BACK' ) diff --git a/src/00/z2ui5_cl_app_demo_16.clas.abap b/src/00/z2ui5_cl_app_demo_16.clas.abap index 1ee09311..fced0008 100644 --- a/src/00/z2ui5_cl_app_demo_16.clas.abap +++ b/src/00/z2ui5_cl_app_demo_16.clas.abap @@ -364,7 +364,7 @@ CLASS Z2UI5_CL_APP_DEMO_16 IMPLEMENTATION. ENDCASE. - DATA(container) = z2ui5_cl_xml_view_helper=>factory( + DATA(container) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - Visualization' navbuttonpress = client->_event( 'BACK' ) diff --git a/src/00/z2ui5_cl_app_demo_18.clas.abap b/src/00/z2ui5_cl_app_demo_18.clas.abap index 941a50d8..f88bd86a 100644 --- a/src/00/z2ui5_cl_app_demo_18.clas.abap +++ b/src/00/z2ui5_cl_app_demo_18.clas.abap @@ -124,7 +124,7 @@ CLASS z2ui5_cl_app_demo_18 IMPLEMENTATION. METHOD z2ui5_render_view_main. - result = z2ui5_cl_xml_view_helper=>factory( + result = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( title = 'abap2UI5 - Template' navbuttonpress = client->_event( 'BACK' ) diff --git a/src/00/z2ui5_cl_app_demo_28.clas.abap b/src/00/z2ui5_cl_app_demo_28.clas.abap index b60852c3..555965b7 100644 --- a/src/00/z2ui5_cl_app_demo_28.clas.abap +++ b/src/00/z2ui5_cl_app_demo_28.clas.abap @@ -4,17 +4,21 @@ CLASS z2ui5_cl_app_demo_28 DEFINITION PUBLIC. INTERFACES z2ui5_if_app. - DATA product TYPE string. - DATA quantity TYPE i. +* DATA product TYPE string. +* DATA quantity TYPE i. +* +* DATA input21 TYPE string. +* DATA input22 TYPE string. +* DATA input41 TYPE string. + + DATA mt_draft TYPE REF TO data. + DATA mv_test TYPE REF TO data. - DATA input21 TYPE string. - DATA input22 TYPE string. - DATA input41 TYPE string. PROTECTED SECTION. + DATA client TYPE REF TO z2ui5_if_client. DATA: BEGIN OF app, - client TYPE REF TO z2ui5_if_client, check_initialized TYPE abap_bool, view_main TYPE string, view_popup TYPE string, @@ -31,12 +35,12 @@ ENDCLASS. -CLASS Z2UI5_CL_APP_DEMO_28 IMPLEMENTATION. +CLASS z2ui5_cl_app_demo_28 IMPLEMENTATION. METHOD z2ui5_if_app~controller. - app-client = client. + me->client = client. app-s_get = client->get( ). app-view_popup = ``. @@ -63,19 +67,19 @@ CLASS Z2UI5_CL_APP_DEMO_28 IMPLEMENTATION. CASE app-s_get-event. WHEN 'BUTTON_POST'. - app-client->popup_message_toast( |{ product } { quantity } - send to the server| ). +* client->popup_message_toast( |{ product } { quantity } - send to the server| ). app-view_popup = 'POPUP_CONFIRM'. WHEN 'BUTTON_CONFIRM'. - app-client->popup_message_toast( |confirm| ). + client->popup_message_toast( |confirm| ). app-view_popup = ''. WHEN 'BUTTON_CANCEL'. - app-client->popup_message_toast( |cancel| ). + client->popup_message_toast( |cancel| ). app-view_popup = ''. WHEN 'BACK'. - app-client->nav_app_leave( app-client->get_app( app-s_get-id_prev_app_stack ) ). + client->nav_app_leave( client->get_app( app-s_get-id_prev_app_stack ) ). ENDCASE. @@ -84,53 +88,75 @@ CLASS Z2UI5_CL_APP_DEMO_28 IMPLEMENTATION. METHOD z2ui5_on_init. - product = 'tomato'. - quantity = '500'. +* product = 'tomato'. +* quantity = '500'. app-view_main = 'VIEW_MAIN'. - input41 = 'faasdfdfsaVIp'. +* input41 = 'faasdfdfsaVIp'. +* +* input21 = '40'. +* input22 = '40'. - input21 = '40'. - input22 = '40'. + + + CREATE DATA mv_test TYPE string. + mv_test->* = 'test'. + + CREATE DATA mt_draft TYPE STANDARD TABLE OF z2ui5_t_draft. + + SELECT FROM z2ui5_t_draft + FIELDS uuid, uuid_prev + order by uuid + INTO TABLE @DATA(lt_data) + UP TO 10 ROWS + . + + mt_draft->* = CORRESPONDING #( lt_data ). ENDMETHOD. METHOD z2ui5_on_render. -* -* app-s_next-xml_main = z2ui5_cl_xml_view_helper=>factory( -* )->page( -* title = 'abap2UI5 - Binding Syntax' -* navbuttonpress = app-client->_event( 'BACK' ) -* shownavbutton = abap_true -* )->header_content( -* )->link( -* text = 'Source_Code' -* href = app-client->get( )-url_source_code -* )->get_parent( -* )->simple_form( title = 'Binding Syntax' editable = abap_true -* )->content( 'form' -* )->title( 'Templating' -* )->label( 'Documentation' -* )->link( -* text = 'Templating' -* href = 'https://sapui5.hana.ondemand.com/#/entity/sap.ui.core.mvc.XMLView' -* )->label( 'when both values are equal second form is displayed' -* )->input( app-client->_bind( input21 ) -* )->input( app-client->_bind( input22 ) -* -* )->get_parent( )->get_parent( -* " )->template_if( test = '{= $' && app-client->_bind( input21 ) && ` === $` && app-client->_bind( input22 ) && ` } ` -* )->template_if( test = '{= ${meta>/oUpdate/INPUT21} === ${meta>/oUpdate/INPUT22} } ' -* )->simple_form( title = 'Binding Syntax' editable = abap_true -* )->content( 'form' -* )->title( 'Expression Binding' -* )->label( 'templating' -* )->input( app-client->_bind( input21 ) -* )->input( app-client->_bind( input22 ) -* -* )->get_root( )->xml_get( ). + DATA(lo_view) = z2ui5_cl_xml_view_helper=>factory( )->shell( )->page( + title = 'abap2UI5 - First Example' + navbuttonpress = client->_event( 'BACK' ) + shownavbutton = abap_true + )->header_content( + )->link( + text = 'Source_Code' + href = z2ui5_cl_xml_view_helper=>hlp_get_source_code_url( app = me get = client->get( ) ) + )->get_parent( + )->simple_form( title = 'Form Title' editable = abap_true + )->content( 'form' + )->title( 'Input' + )->label( 'quantity' ). + lo_view->input( client->_bind( val = mv_test->* check_gen_data = abap_true ) ). + + lo_view->button( + text = 'post' + press = client->_event( 'BUTTON_POST' ) + ). + + data(tab) = lo_view->get_parent( )->get_parent( )->simple_form( title = 'Table' editable = abap_true + )->content( 'form' )->table( + items = client->_bind( val = mt_draft->* check_gen_data = abap_true ) + ). + + tab->columns( + )->column( + )->text( 'UUID' )->get_parent( + )->column( + )->text( 'UUID_PREV' ). + + tab->items( )->column_list_item( + )->cells( + )->input( '{UUID}' + )->input( '{UUID_PREV}' + ). + + app-s_next-xml_main = lo_view->get_root( )->xml_get( ). ENDMETHOD. + ENDCLASS. diff --git a/src/00/z2ui5_cl_app_demo_28.clas.xml b/src/00/z2ui5_cl_app_demo_28.clas.xml index a2f9220f..00e3a3d4 100644 --- a/src/00/z2ui5_cl_app_demo_28.clas.xml +++ b/src/00/z2ui5_cl_app_demo_28.clas.xml @@ -5,7 +5,7 @@ Z2UI5_CL_APP_DEMO_28 E - templ - ... + demo - table maintenance 2 1 X X diff --git a/src/z2ui5_cl_http_handler.clas.abap b/src/z2ui5_cl_http_handler.clas.abap index 3aabf5a0..bf5a9701 100644 --- a/src/z2ui5_cl_http_handler.clas.abap +++ b/src/z2ui5_cl_http_handler.clas.abap @@ -70,16 +70,8 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION. METHOD main_index_html. - client-t_param = VALUE #( LET tab = client-t_param IN FOR row IN tab - ( name = to_upper( row-name ) value = to_upper( row-value ) ) ). - - DATA(lv_url) = client-t_header[ name = '~path' ]-value. - - TRY. - DATA(lv_app) = client-t_param[ name = 'APP' ]-value. - CATCH cx_root. - ENDTRY. - + DATA(lv_url) = _=>get_header_val( '~path' ). + DATA(lv_app) = _=>get_param_val( 'app' ). z2ui5_lcl_db=>cleanup( ). r_result = `` && |\n| && @@ -103,8 +95,6 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION. `` && |\n| && `` && |\n|. - - r_result = r_result && `