From 9096bc32d634c9a4a4a8017b3f6ddcf9a9652aef Mon Sep 17 00:00:00 2001 From: oblomov <102328295+oblomov-dev@users.noreply.github.com> Date: Fri, 10 Nov 2023 15:00:52 +0100 Subject: [PATCH] startup params (#637) * startup params * abaplint fix * bugfix unit test --- src/00/z2ui5_cl_fw_handler.clas.abap | 57 +++++++++++++++++++++++--- src/z2ui5_cl_fw_http_handler.clas.abap | 9 ++-- src/z2ui5_if_client.intf.abap | 2 + 3 files changed, 59 insertions(+), 9 deletions(-) diff --git a/src/00/z2ui5_cl_fw_handler.clas.abap b/src/00/z2ui5_cl_fw_handler.clas.abap index ff9aed60..6cd3f4cd 100644 --- a/src/00/z2ui5_cl_fw_handler.clas.abap +++ b/src/00/z2ui5_cl_fw_handler.clas.abap @@ -136,6 +136,7 @@ ENDCLASS. CLASS z2ui5_cl_fw_handler IMPLEMENTATION. + METHOD app_set_next. app->id = COND #( WHEN app->id IS INITIAL THEN z2ui5_cl_fw_utility=>func_get_uuid_32( ) ELSE app->id ). @@ -157,6 +158,7 @@ CLASS z2ui5_cl_fw_handler IMPLEMENTATION. ENDMETHOD. + METHOD request_begin. so_body = z2ui5_cl_fw_utility_json=>factory( body ). @@ -164,10 +166,55 @@ CLASS z2ui5_cl_fw_handler IMPLEMENTATION. TRY. DATA(location) = so_body->get_attribute( `OLOCATION` ). ss_config-body = body. - ss_config-search = location->get_attribute( `SEARCH` )->get_val( ). - ss_config-origin = location->get_attribute( `ORIGIN` )->get_val( ). - ss_config-pathname = location->get_attribute( `PATHNAME` )->get_val( ). - ss_config-version = location->get_attribute( `VERSION` )->get_val( ). + + TRY. + ss_config-search = location->get_attribute( `SEARCH` )->get_val( ). + CATCH cx_root. + ENDTRY. + + TRY. + ss_config-origin = location->get_attribute( `ORIGIN` )->get_val( ). + CATCH cx_root. + ENDTRY. + + TRY. + ss_config-pathname = location->get_attribute( `PATHNAME` )->get_val( ). + CATCH cx_root. + ENDTRY. + + TRY. + ss_config-version = location->get_attribute( `VERSION` )->get_val( ). + CATCH cx_root. + ENDTRY. + + TRY. + ss_config-check_launchpad_active = location->get_attribute( `CHECK_LAUNCHPAD_ACTIVE` )->get_val( ). + CATCH cx_root. + ENDTRY. + + TRY. + FIELD-SYMBOLS TYPE any. + DATA(ls_params) = location->get_attribute( `STARTUP_PARAMETERS` )->get_val_ref( ). + ASSIGN ls_params->* TO . + + DATA(lt_comp) = z2ui5_cl_fw_utility=>rtti_get_t_comp_by_struc( ). + + LOOP AT lt_comp INTO DATA(ls_comp). + + FIELD-SYMBOLS TYPE REF TO data. + FIELD-SYMBOLS TYPE table. + FIELD-SYMBOLS TYPE data. + ASSIGN COMPONENT ls_comp-name OF STRUCTURE TO . + ASSIGN ->* TO . + ASSIGN [ 1 ] TO . + ASSIGN ->* TO . + + INSERT VALUE #( n = ls_comp-name v = ) INTO TABLE ss_config-t_startup_params. + + ENDLOOP. + CATCH cx_root. + ENDTRY. + CATCH cx_root. ENDTRY. ss_config-view_model_edit_name = z2ui5_cl_fw_binding=>cv_model_edit_name. @@ -407,6 +454,4 @@ CLASS z2ui5_cl_fw_handler IMPLEMENTATION. result->ms_db-app->id = result->ms_db-id. ENDMETHOD. - - ENDCLASS. diff --git a/src/z2ui5_cl_fw_http_handler.clas.abap b/src/z2ui5_cl_fw_http_handler.clas.abap index 84df662c..8133a96f 100644 --- a/src/z2ui5_cl_fw_http_handler.clas.abap +++ b/src/z2ui5_cl_fw_http_handler.clas.abap @@ -259,7 +259,7 @@ CLASS Z2UI5_CL_FW_HTTP_HANDLER IMPLEMENTATION. ` const hash = ( oCrossAppNavigator.hrefForExternal({` && |\n| && ` target: args[1],` && |\n| && ` params: args[2]` && |\n| && - ` })) || "";` && |\n| && + ` } )) || "";` && |\n| && |\n| && ` if (args[3] === 'EXT') {` && |\n| && |\n| && @@ -461,7 +461,7 @@ CLASS Z2UI5_CL_FW_HTTP_HANDLER IMPLEMENTATION. ` sap.m.MessageBox[sap.z2ui5.oResponse.PARAMS.S_MSG_BOX.TYPE](sap.z2ui5.oResponse.PARAMS.S_MSG_BOX.TEXT);` && |\n| && ` }` && |\n| && ` if (sap.z2ui5.oResponse.SEARCH != "") {` && |\n| && - ` history.replaceState(null, null, sap.z2ui5.oResponse.SEARCH );` && |\n| && + ` history.replaceState(null, null, window.location.pathname + '?' + sap.z2ui5.oResponse.SEARCH );` && |\n| && ` }` && |\n| && ` if (sap.z2ui5.oResponse.PARAMS.S_MESSAGE_MANAGER.CHECK_CLEAR == true) {` && |\n| && ` sap.ui.getCore().getMessageManager().removeAllMessages(); ` && |\n| && @@ -493,11 +493,14 @@ CLASS Z2UI5_CL_FW_HTTP_HANDLER IMPLEMENTATION. ` sap.z2ui5.checkNestAfter = false;` && |\n| && ` sap.z2ui5.checkNestAfter2 = false;` && |\n| && |\n| && + ` debugger;` && |\n| && ` sap.z2ui5.oBody.OLOCATION = {` && |\n| && ` ORIGIN: window.location.origin,` && |\n| && ` PATHNAME: sap.z2ui5.pathname,` && |\n| && ` SEARCH: window.location.search,` && |\n| && ` VERSION: sap.ui.getVersionInfo().gav,` && |\n| && + ` CHECK_LAUNCHPAD_ACTIVE: sap.ushell !== undefined,` && |\n| && + ` STARTUP_PARAMETERS: sap.z2ui5.startupParameters,` && |\n| && ` };` && |\n| && ` if(sap.z2ui5.search) { sap.z2ui5.oBody.OLOCATION.SEARCH = sap.z2ui5.search; }` && |\n| && |\n| && @@ -528,7 +531,7 @@ CLASS Z2UI5_CL_FW_HTTP_HANDLER IMPLEMENTATION. ` var oViewNest2 = sap.ui.xmlview({ viewContent: xml });` && |\n| && ` sap.z2ui5.oControllerNest = oViewNest.getController();` && |\n| && ` sap.z2ui5.oControllerNest2 = oViewNest.getController();` && |\n| && - ` sap.z2ui5.checkLogActive = ` && z2ui5_cl_fw_utility=>boolean_abap_2_json( check_logging ) && `;` && |\n| && + ` sap.z2ui5.checkLogActive = ` && z2ui5_cl_fw_utility=>boolean_abap_2_json( check_logging ) && `;` && |\n| && ` sap.z2ui5.oBody = {};` && |\n| && ` sap.z2ui5.oBody.APP_START = sap.z2ui5.APP_START;` && |\n| && ` sap.z2ui5.oController.Roundtrip();` && |\n| && diff --git a/src/z2ui5_if_client.intf.abap b/src/z2ui5_if_client.intf.abap index d8a90133..56195ae5 100644 --- a/src/z2ui5_if_client.intf.abap +++ b/src/z2ui5_if_client.intf.abap @@ -44,6 +44,8 @@ INTERFACE z2ui5_if_client pathname TYPE string, search TYPE string, body TYPE string, + CHECK_LAUNCHPAD_ACTIVE TYPE abap_bool, + t_startup_params type ty_t_name_value, END OF ty_s_config. TYPES: