diff --git a/README.md b/README.md index ad1a63a4..a3fd5be3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # abap2UI5 -image

-Follow this project on [**twitter**](https://twitter.com/OblomovDev) to keep up to date and don't forget to explore the [**demo repository** :flashlight:](https://github.com/oblomov-dev/abap2UI5-demos) +![bild](https://github.com/oblomov-dev/abap2UI5/assets/102328295/8cf3f160-2881-45b9-a38b-80abda0d8bb0) +Follow this project on [**twitter** :sound:](https://twitter.com/OblomovDev) to keep up to date and don't forget to explore the [**demo repository** :flashlight:](https://github.com/oblomov-dev/abap2UI5-demos) #### Features * easy to use – implement just one interface for a standalone UI5 application * pure ABAP – development using 100% ABAP (no JavaScript, DDL, EML or Customizing) @@ -37,8 +37,8 @@ Follow this project on [**twitter**](https://twitter.com/OblomovDev) to keep up * [work-in-progress] Launchpad integration with the following extension [(abap2UI5_ext-launchpad)](https://github.com/oblomov-dev/abap2UI5_ext-launchpad_app) #### Installation -Install with [abapGit](https://abapgit.org) ![abapGit](https://docs.abapgit.org/img/favicon.png), create a new HTTP service and replace the handler method with the following code snippet: -##### Standard ABAP :computer: +Install with [abapGit](https://abapgit.org) ![abapGit](https://docs.abapgit.org/img/favicon.png), create a new HTTP service and replace the handler method with the following code: +##### Standard ABAP 🏠 ```abap METHOD if_http_extension~handle_request. @@ -62,7 +62,7 @@ METHOD if_http_extension~handle_request. ENDMETHOD. ``` -##### ABAP for Cloud :cloud: +##### ABAP for Cloud :cloud: ```abap METHOD if_http_service_extension~handle_request. diff --git a/src/z2ui5_cl_http_handler.clas.locals_imp.abap b/src/z2ui5_cl_http_handler.clas.locals_imp.abap index ab9495d2..6979ec54 100644 --- a/src/z2ui5_cl_http_handler.clas.locals_imp.abap +++ b/src/z2ui5_cl_http_handler.clas.locals_imp.abap @@ -622,7 +622,6 @@ CLASS z2ui5_lcl_utility_tree_json IMPLEMENTATION. FIELD-SYMBOLS TYPE any. DATA(lv_name) = c_prefix && replace( val = name sub = `-` with = `_` occ = 0 ). - " DATA(lv_name) = c_prefix && replace( val = name sub = `-` with = `_` occ = 0 ). ASSIGN (lv_name) TO . z2ui5_lcl_utility=>raise( when = xsdbool( sy-subrc <> 0 ) ). @@ -712,7 +711,6 @@ CLASS z2ui5_lcl_fw_handler DEFINITION. id_prev TYPE string, id_prev_app TYPE string, id_prev_app_stack TYPE string, - t_attri TYPE z2ui5_lcl_utility=>ty_t_attri, o_app TYPE REF TO z2ui5_if_app, END OF ty_s_db. @@ -761,8 +759,6 @@ CLASS z2ui5_lcl_fw_handler DEFINITION. RETURNING VALUE(result) TYPE REF TO z2ui5_lcl_fw_handler. - - METHODS set_app_leave RETURNING VALUE(result) TYPE REF TO z2ui5_lcl_fw_handler. @@ -781,7 +777,7 @@ CLASS z2ui5_lcl_fw_handler DEFINITION. CLASS-METHODS bind_front_2_back IMPORTING - lo_model TYPE REF TO z2ui5_lcl_utility_tree_json + lr_model TYPE REF TO data lo_app TYPE REF TO object t_attri TYPE z2ui5_lcl_utility=>ty_t_attri ##NEEDED. @@ -1254,11 +1250,16 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION. ENDIF. DATA(lo_resp) = z2ui5_lcl_utility_tree_json=>factory( ). + + DATA(lv_viewmodel) = COND #( WHEN ms_next-s_set-_viewmodel IS NOT INITIAL THEN ms_next-s_set-_viewmodel + ELSE bind_back_2_front( lo_app = ms_db-o_app t_attri = ms_db-t_attri ) ). + lo_resp->add_attribute( n = `OVIEWMODEL` v = lv_viewmodel apos_active = abap_false ). + CLEAR ms_next-s_set-_viewmodel. + lo_resp->add_attribute( n = `PARAMS` v = z2ui5_lcl_utility=>trans_any_2_json( ms_next-s_set ) apos_active = abap_false ). lo_resp->add_attribute( n = `S_MSG` v = z2ui5_lcl_utility=>trans_any_2_json( ms_next-s_msg ) apos_active = abap_false ). - lo_resp->add_attribute( n = `ID` v = ms_db-id ). + lo_resp->add_attribute( n = `ID` v = ms_db-id ). - lo_resp->add_attribute( n = `OVIEWMODEL` v = bind_back_2_front( lo_app = ms_db-o_app t_attri = ms_db-t_attri ) apos_active = abap_false ). result = lo_resp->get_root( )->stringify( ). DELETE ms_db-t_attri WHERE bind_type = cs_bind_type-one_time. @@ -1269,30 +1270,31 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION. METHOD bind_front_2_back. - CONSTANTS c_prefix TYPE string VALUE `LO_APP->`. + LOOP AT t_attri REFERENCE INTO DATA(lr_attri) + WHERE bind_type = cs_bind_type-two_way. + TRY. + FIELD-SYMBOLS TYPE any. + DATA(lv_name) = `LO_APP->` && lr_attri->name. + ASSIGN (lv_name) TO . + z2ui5_lcl_utility=>raise( when = xsdbool( sy-subrc <> 0 ) ). - TRY. - - LOOP AT t_attri REFERENCE INTO DATA(lr_attri) - WHERE bind_type = cs_bind_type-two_way. - - FIELD-SYMBOLS TYPE any. - DATA(lv_name) = c_prefix && to_upper( lr_attri->name ). - ASSIGN (lv_name) TO . + FIELD-SYMBOLS TYPE any. + lv_name = `LR_MODEL->` && replace( val = lr_attri->name sub = `-` with = `_` occ = 0 ). + ASSIGN (lv_name) TO . z2ui5_lcl_utility=>raise( when = xsdbool( sy-subrc <> 0 ) ). IF lr_attri->gen_kind IS NOT INITIAL. CASE lr_attri->gen_kind. WHEN cl_abap_datadescr=>kind_elem. - CREATE DATA TYPE (lr_attri->gen_type). - ASSIGN ->* TO . + CREATE DATA TYPE (lr_attri->gen_type). + ASSIGN ->* TO . WHEN cl_abap_datadescr=>kind_table. DATA lr_data TYPE REF TO data. CREATE DATA lr_data TYPE (lr_attri->gen_type). ASSIGN lr_data->* TO FIELD-SYMBOL(). - CREATE DATA LIKE STANDARD TABLE OF . - ASSIGN ->* TO . + CREATE DATA LIKE STANDARD TABLE OF . + ASSIGN ->* TO . ENDCASE. ENDIF. @@ -1300,30 +1302,27 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION. WHEN `h`. z2ui5_lcl_utility=>trans_ref_tab_2_tab( - EXPORTING ir_tab_from = lo_model->get_attribute( lr_attri->name )->mr_actual - IMPORTING t_result = ). + EXPORTING ir_tab_from = + IMPORTING t_result = ). WHEN OTHERS. - DATA(lo_attri) = lo_model->get_attribute( lr_attri->name ). - FIELD-SYMBOLS TYPE any. - ASSIGN lo_attri->mr_actual->* TO . - + ASSIGN ->* TO . CASE lr_attri->type_kind. WHEN 'D' OR 'T'. /ui2/cl_json=>deserialize( EXPORTING - json = `"` && && `"` + json = `"` && && `"` CHANGING - data = ). + data = ). WHEN OTHERS. - = . + = . ENDCASE. ENDCASE. - ENDLOOP. - CATCH cx_root. - ENDTRY. + CATCH cx_root. + ENDTRY. + ENDLOOP. ENDMETHOD. @@ -1333,7 +1332,6 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION. CONSTANTS c_prefix TYPE string VALUE `LO_APP->`. DATA(r_view_model) = z2ui5_lcl_utility_tree_json=>factory( ). - r_view_model->mv_name = `oViewModel`. DATA(lo_update) = r_view_model->add_attribute_object( `oUpdate` ). LOOP AT t_attri REFERENCE INTO DATA(lr_attri) WHERE bind_type <> ``. @@ -1423,11 +1421,13 @@ CLASS z2ui5_lcl_fw_handler IMPLEMENTATION. ENDTRY. bind_front_2_back( - lo_model = mo_body->get_attribute( `OUPDATE` ) + lr_model = mo_body->get_attribute( `OUPDATE` )->mr_actual lo_app = result->ms_db-o_app t_attri = result->ms_db-t_attri ). + result->ms_actual-_viewmodel = mo_body->get_attribute( `OUPDATE` )->mr_actual. + ENDMETHOD. @@ -1667,8 +1667,7 @@ CLASS z2ui5_lcl_fw_client IMPLEMENTATION. event = mo_handler->ms_actual-event t_event_arg = mo_handler->ms_actual-t_event_arg t_scroll_pos = mo_handler->ms_actual-t_scroll_pos - t_req_header = z2ui5_cl_http_handler=>client-t_header - t_req_param = z2ui5_cl_http_handler=>client-t_param + _viewmodel = mo_handler->ms_actual-_viewmodel ). ENDMETHOD. @@ -1739,99 +1738,3 @@ CLASS z2ui5_lcl_fw_client IMPLEMENTATION. ENDMETHOD. ENDCLASS. - -CLASS z2ui5_lcl_fw_view DEFINITION. - - PUBLIC SECTION. - CLASS-METHODS read_view - RETURNING - VALUE(result) TYPE string. -ENDCLASS. - -CLASS z2ui5_lcl_fw_view IMPLEMENTATION. - - METHOD read_view. - - result = ` <Label ` && |\n| && - ` text="quantity" ` && |\n| && - ` /> <Input ` && |\n| && - ` value="onEvent( {/oUpdate/QUANTITY} )` && |\n| && - ` /> <Label ` && |\n| && - ` text="product" ` && |\n| && - ` /> <Input ` && |\n| && - ` enabled="false" ` && |\n| && - ` value="{VALUE}" ` && |\n| && - ` /> <Button ` && |\n| && - ` press="onEvent( { 'EVENT' : 'BUTTON_POST', 'METHOD' : 'UPDATE' , 'isHoldView' : false })" ` && |\n| && - ` text="post" ` && |\n| && - ` /></form:content></form:SimpleForm></Page></Shell></mvc:View>`. - ENDMETHOD. - -ENDCLASS. - -CLASS z2ui5_lcl_fw_view_app DEFINITION. - - PUBLIC SECTION. - INTERFACES z2ui5_if_app. - - DATA quantity TYPE string VALUE `10` ##NEEDED. -ENDCLASS. - -CLASS z2ui5_lcl_fw_view_app IMPLEMENTATION. - - METHOD z2ui5_if_app~main. - - DATA(lt_attri) = z2ui5_lcl_utility=>get_t_attri_by_ref( me ). - DATA(lv_view) = z2ui5_lcl_fw_view=>read_view( ). - - SPLIT lv_view AT `{` INTO TABLE DATA(lt_view). - DELETE lt_view INDEX 1. - - LOOP AT lt_view INTO DATA(lr_view). - SPLIT lr_view AT `}` INTO lr_view DATA(lv_dummy). - - LOOP AT lt_attri REFERENCE INTO DATA(lr_attri). - IF lr_view = `/oUpdate/` && lr_attri->name. - lr_attri->bind_type = z2ui5_lcl_fw_handler=>cs_bind_type-two_way. - CONTINUE. - ENDIF. - - IF lr_view = lr_attri->name. - lr_attri->bind_type = z2ui5_lcl_fw_handler=>cs_bind_type-one_way. - CONTINUE. - ENDIF. - ENDLOOP. - ENDLOOP. - - client->set_next( VALUE #( xml_main = lv_view ) ). - - ENDMETHOD. - -ENDCLASS. diff --git a/src/z2ui5_cl_xml_view.clas.abap b/src/z2ui5_cl_xml_view.clas.abap index 43de776b..54ed29e0 100644 --- a/src/z2ui5_cl_xml_view.clas.abap +++ b/src/z2ui5_cl_xml_view.clas.abap @@ -36,9 +36,9 @@ CLASS z2ui5_cl_xml_view DEFINITION CLASS-METHODS hlp_get_source_code_url IMPORTING app TYPE REF TO z2ui5_if_app - get TYPE z2ui5_if_client=>ty_s_get + get TYPE z2ui5_if_client=>ty_s_get RETURNING - VALUE(result) TYPE string. + VALUE(result) TYPE string ##NEEDED. CLASS-METHODS hlp_replace_controller_name IMPORTING @@ -348,7 +348,6 @@ CLASS z2ui5_cl_xml_view DEFINITION valuehelprequest TYPE clike OPTIONAL class TYPE clike OPTIONAL visible TYPE clike OPTIONAL - submit TYPE clike OPTIONAL PREFERRED PARAMETER value RETURNING VALUE(result) TYPE REF TO z2ui5_cl_xml_view. @@ -1745,7 +1744,7 @@ CLASS Z2UI5_CL_XML_VIEW IMPLEMENTATION. METHOD hlp_get_source_code_url. - DATA(lv_url) = get-t_req_header[ name = `referer` ]-value. + DATA(lv_url) = z2ui5_cl_http_handler=>client-t_header[ name = `referer` ]-value. SPLIT lv_url AT '?' INTO lv_url DATA(lv_dummy). result = z2ui5_cl_http_handler=>client-t_header[ name = `origin` ]-value && `/sap/bc/adt/oo/classes/` && lcl_utility=>get_classname_by_ref( app ) && `/source/main`. @@ -1820,7 +1819,6 @@ CLASS Z2UI5_CL_XML_VIEW IMPLEMENTATION. ( n = `valueHelpRequest` v = valuehelprequest ) ( n = `showValueHelp` v = lcl_utility=>get_json_boolean( showvaluehelp ) ) ( n = `class` v = class ) - ( n = `submit` v = submit ) ) ). ENDMETHOD. diff --git a/src/z2ui5_if_client.intf.abap b/src/z2ui5_if_client.intf.abap index 7c2110ee..128674fa 100644 --- a/src/z2ui5_if_client.intf.abap +++ b/src/z2ui5_if_client.intf.abap @@ -17,8 +17,7 @@ INTERFACE z2ui5_if_client id_prev_app TYPE string, id_prev_app_stack TYPE string, t_scroll_pos TYPE ty_t_name_value, - t_req_param TYPE ty_t_name_value, - t_req_header TYPE ty_t_name_value, + _viewmodel TYPE REF TO data, END OF ty_s_get. TYPES: @@ -39,6 +38,7 @@ INTERFACE z2ui5_if_client interval_ms TYPE string, event_finished TYPE string, END OF s_timer, + _viewmodel TYPE string, END OF ty_s_next. METHODS set_next @@ -91,9 +91,9 @@ INTERFACE z2ui5_if_client METHODS _event IMPORTING - val TYPE clike - hold_view TYPE abap_bool DEFAULT abap_false - t_arg TYPE string_table OPTIONAL + val TYPE clike + hold_view TYPE abap_bool DEFAULT abap_false + t_arg TYPE string_table OPTIONAL RETURNING VALUE(result) TYPE string.