From 31a376b4faac27d07b135828d119b05376ae89c7 Mon Sep 17 00:00:00 2001 From: oblomov <102328295+oblomov-dev@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:03:17 +0100 Subject: [PATCH] refactoring and cleanup (#812) * refactoring and cleanup * lint fixes --- src/00/z2ui5_cl_util_func.clas.abap | 245 +++++---- .../z2ui5_cl_util_func.clas.testclasses.abap | 18 +- src/00/z2ui5_cx_util_error.clas.abap | 2 +- src/01/01/z2ui5_cl_fw_binding.clas.abap | 6 +- src/01/01/z2ui5_cl_fw_client.clas.abap | 4 +- src/01/01/z2ui5_cl_fw_controller.clas.abap | 64 ++- ...ui5_cl_fw_controller.clas.testclasses.abap | 1 + src/01/01/z2ui5_cl_fw_db.clas.abap | 10 +- src/01/01/z2ui5_cl_fw_http_handler.clas.abap | 517 +----------------- src/01/01/z2ui5_cl_fw_index_html.clas.abap | 515 +++++++++++++++++ src/01/01/z2ui5_cl_fw_index_html.clas.xml | 16 + src/01/01/z2ui5_cl_fw_model.clas.abap | 4 +- src/03/01/z2ui5_cl_popup_get_range.clas.abap | 6 +- .../z2ui5_cl_popup_get_range_multi.clas.abap | 6 +- 14 files changed, 768 insertions(+), 646 deletions(-) create mode 100644 src/01/01/z2ui5_cl_fw_index_html.clas.abap create mode 100644 src/01/01/z2ui5_cl_fw_index_html.clas.xml diff --git a/src/00/z2ui5_cl_util_func.clas.abap b/src/00/z2ui5_cl_util_func.clas.abap index 1550dc8b..a66ba614 100644 --- a/src/00/z2ui5_cl_util_func.clas.abap +++ b/src/00/z2ui5_cl_util_func.clas.abap @@ -23,36 +23,45 @@ CLASS z2ui5_cl_util_func DEFINITION t_range TYPE ty_t_range, t_token TYPE ty_t_token, END OF ty_s_sql_multi. - TYPES ty_t_sql_multi TYPE STANDARD TABLE OF ty_s_sql_multi WITH EMPTY KEY. + TYPES ty_t_filter_multi TYPE STANDARD TABLE OF ty_s_sql_multi WITH EMPTY KEY. TYPES: BEGIN OF ty_s_sql_result, table TYPE string, END OF ty_s_sql_result. - CLASS-METHODS source_code_get_method + CLASS-METHODS itab_get_itab_by_csv + IMPORTING + val TYPE string + RETURNING + VALUE(result) TYPE REF TO data. + + CLASS-METHODS itab_get_csv_by_itab + IMPORTING + val TYPE any + RETURNING + VALUE(result) TYPE string. + + + CLASS-METHODS source_get_method IMPORTING iv_classname TYPE clike iv_methodname TYPE clike RETURNING VALUE(result) TYPE string_table. - CLASS-METHODS get_sql_multi_by_data + CLASS-METHODS filter_get_multi_by_data IMPORTING val TYPE data RETURNING - VALUE(result) TYPE ty_t_sql_multi. + VALUE(result) TYPE ty_t_filter_multi. - CLASS-METHODS get_sql_by_string + CLASS-METHODS sql_get_by_string IMPORTING val TYPE clike RETURNING VALUE(result) TYPE ty_s_sql_result. - CLASS-METHODS js_load_ext_lib - RETURNING - VALUE(result) TYPE string. - CLASS-METHODS app_get_url_source_code IMPORTING !client TYPE REF TO z2ui5_if_client @@ -103,19 +112,19 @@ CLASS z2ui5_cl_util_func DEFINITION !v TYPE clike DEFAULT `CX_SY_SUBRC` PREFERRED PARAMETER v. - CLASS-METHODS func_get_uuid_32 + CLASS-METHODS uuid_get_c32 RETURNING VALUE(result) TYPE string. - CLASS-METHODS func_get_uuid_22 + CLASS-METHODS uuid_Get_c22 RETURNING VALUE(result) TYPE string. - CLASS-METHODS func_get_user_tech + CLASS-METHODS user_get_tech RETURNING VALUE(result) TYPE string. - CLASS-METHODS trans_json_any_2 + CLASS-METHODS trans_json_by_any IMPORTING !any TYPE any !pretty_name TYPE clike DEFAULT /ui2/cl_json=>pretty_mode-none @@ -129,7 +138,7 @@ CLASS z2ui5_cl_util_func DEFINITION EXPORTING !any TYPE any. - CLASS-METHODS trans_xml_any_2 + CLASS-METHODS trans_xml_by_any IMPORTING !any TYPE any RETURNING @@ -181,13 +190,13 @@ CLASS z2ui5_cl_util_func DEFINITION RETURNING VALUE(result) TYPE string. - CLASS-METHODS rtti_xml_get_by_data + CLASS-METHODS trans_srtti_xml_by_data IMPORTING !data TYPE any RETURNING VALUE(result) TYPE string. - CLASS-METHODS rtti_xml_set_to_data + CLASS-METHODS trans_srtti_xml_2_data IMPORTING !rtti_data TYPE clike EXPORTING @@ -264,53 +273,53 @@ CLASS z2ui5_cl_util_func DEFINITION RETURNING VALUE(result) TYPE abap_bool. - CLASS-METHODS get_range_t_by_token_t + CLASS-METHODS filter_get_range_t_by_token_t IMPORTING val TYPE ty_t_token RETURNING VALUE(result) TYPE ty_t_range. - CLASS-METHODS get_range_by_token + CLASS-METHODS filter_get_range_by_token IMPORTING VALUE(value) TYPE string RETURNING VALUE(result) TYPE ty_s_range. - CLASS-METHODS get_token_t_by_range_t + CLASS-METHODS filter_get_token_t_by_range_t IMPORTING val TYPE ty_t_range RETURNING VALUE(result) TYPE ty_t_token. - CLASS-METHODS get_token_range_mapping + CLASS-METHODS filter_get_token_range_mapping RETURNING VALUE(result) TYPE z2ui5_if_client=>ty_t_name_value. - CLASS-METHODS get_tab_filter_by_val + CLASS-METHODS itab_filter_by_val IMPORTING val TYPE clike CHANGING tab TYPE STANDARD TABLE. - CLASS-METHODS decode_x_base64 + CLASS-METHODS conv_decode_x_base64 IMPORTING val TYPE string RETURNING VALUE(result) TYPE xstring. - CLASS-METHODS encode_x_base64 + CLASS-METHODS conv_encode_x_base64 IMPORTING val TYPE xstring RETURNING VALUE(result) TYPE string. - CLASS-METHODS get_string_by_xstring + CLASS-METHODS conv_get_string_by_xstring IMPORTING val TYPE xstring RETURNING VALUE(result) TYPE string. - CLASS-METHODS get_xstring_by_string + CLASS-METHODS conv_get_xstring_by_string IMPORTING val TYPE string RETURNING @@ -328,13 +337,13 @@ CLASS z2ui5_cl_util_func DEFINITION RETURNING VALUE(result) TYPE d. - CLASS-METHODS copy_ref_data_to_ref_data + CLASS-METHODS conv_copy_ref_data IMPORTING from TYPE REF TO data RETURNING VALUE(result) TYPE REF TO data. - CLASS-METHODS get_file_types + CLASS-METHODS source_get_file_types RETURNING VALUE(result) TYPE string_table. @@ -353,8 +362,86 @@ ENDCLASS. CLASS z2ui5_cl_util_func IMPLEMENTATION. + METHOD itab_get_itab_by_csv. - METHOD get_file_types. + SPLIT val AT cl_abap_char_utilities=>newline INTO TABLE DATA(lt_rows). + SPLIT lt_rows[ 1 ] AT ';' INTO TABLE DATA(lt_cols). + + DATA lt_comp TYPE cl_abap_structdescr=>component_table. + LOOP AT lt_cols REFERENCE INTO DATA(lr_col). + + DATA(lv_name) = c_trim_upper( lr_col->* ). + REPLACE ` ` IN lv_name WITH `_`. + + INSERT VALUE #( name = lv_name type = cl_abap_elemdescr=>get_c( 40 ) ) INTO TABLE lt_comp. + ENDLOOP. + + DATA(struc) = cl_abap_structdescr=>get( lt_comp ). + DATA(o_table_desc) = cl_abap_tabledescr=>create( + p_line_type = CAST #( struc ) + p_table_kind = cl_abap_tabledescr=>tablekind_std + p_unique = abap_false ). + + CREATE DATA result TYPE HANDLE o_table_desc. + FIELD-SYMBOLS TYPE STANDARD TABLE. + ASSIGN result->* TO . + + DELETE lt_rows WHERE table_line IS INITIAL. + + LOOP AT lt_rows REFERENCE INTO DATA(lr_rows) FROM 2. + + SPLIT lr_rows->* AT ';' INTO TABLE lt_cols. + DATA lr_row TYPE REF TO data. + CREATE DATA lr_row TYPE HANDLE struc. + + LOOP AT lt_cols REFERENCE INTO lr_col. + ASSIGN lr_row->* TO FIELD-SYMBOL(). + ASSIGN COMPONENT sy-tabix OF STRUCTURE TO FIELD-SYMBOL(). + = lr_col->*. + ENDLOOP. + + INSERT INTO TABLE . + ENDLOOP. + + ENDMETHOD. + + + + METHOD itab_get_csv_by_itab. + + FIELD-SYMBOLS TYPE table. + ASSIGN val TO . + + DATA lr_row TYPE REF TO data. + + DATA(tab) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( ) ). + + DATA(struc) = CAST cl_abap_structdescr( tab->get_table_line_type( ) ). + + LOOP AT struc->get_components( ) REFERENCE INTO DATA(lr_comp). + result = result && lr_comp->name && ';'. + ENDLOOP. + + result = result && cl_abap_char_utilities=>cr_lf. + + LOOP AT REFERENCE INTO lr_row. + + DATA(lv_index) = 1. + DO. + ASSIGN lr_row->* TO FIELD-SYMBOL(). + ASSIGN COMPONENT lv_index OF STRUCTURE TO FIELD-SYMBOL(). + IF sy-subrc <> 0. + EXIT. + ENDIF. + lv_index = lv_index + 1. + result = result && && ';'. + ENDDO. + result = result && cl_abap_char_utilities=>cr_lf. + ENDLOOP. + + ENDMETHOD. + + METHOD source_get_file_types. DATA(lv_types) = `abap, abc, actionscript, ada, apache_conf, applescript, asciidoc, assembly_x86, autohotkey, batchfile, bro, c9search, c_cpp, cirru, clojure, cobol, coffee, coldfusion, csharp, css, curly, d, dart, diff, django, dockerfile, ` && `dot, drools, eiffel, yaml, ejs, elixir, elm, erlang, forth, fortran, ftl, gcode, gherkin, gitignore, glsl, gobstones, golang, groovy, haml, handlebars, haskell, haskell_cabal, haxe, hjson, html, html_elixir, html_ruby, ini, io, jack, jade, java, ja` && @@ -441,7 +528,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD copy_ref_data_to_ref_data. + METHOD conv_copy_ref_data. FIELD-SYMBOLS TYPE data. FIELD-SYMBOLS TYPE data. @@ -497,7 +584,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD decode_x_base64. + METHOD conv_decode_x_base64. TRY. @@ -521,7 +608,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD encode_x_base64. + METHOD conv_encode_x_base64. TRY. @@ -545,12 +632,12 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD func_get_user_tech. + METHOD user_get_tech. result = sy-uname. ENDMETHOD. - METHOD func_get_uuid_22. + METHOD uuid_Get_c22. TRY. DATA uuid TYPE c LENGTH 22. @@ -583,7 +670,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD func_get_uuid_32. + METHOD uuid_get_c32. TRY. DATA uuid TYPE c LENGTH 32. @@ -611,24 +698,24 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD get_range_by_token. + METHOD filter_get_range_by_token. DATA(lv_length) = strlen( value ) - 1. CASE value(1). WHEN `=`. - result = VALUE #( option = `EQ` low = value+1 ). + result = VALUE #( sign = `I` option = `EQ` low = value+1 ). WHEN `<`. IF value+1(1) = `=`. - result = VALUE #( option = `LE` low = value+2 ). + result = VALUE #( sign = `I` option = `LE` low = value+2 ). ELSE. - result = VALUE #( option = `LT` low = value+1 ). + result = VALUE #( sign = `I` option = `LT` low = value+1 ). ENDIF. WHEN `>`. IF value+1(1) = `=`. - result = VALUE #( option = `GE` low = value+2 ). + result = VALUE #( sign = `I` option = `GE` low = value+2 ). ELSE. - result = VALUE #( option = `GT` low = value+1 ). + result = VALUE #( sign = `I` option = `GT` low = value+1 ). ENDIF. WHEN `*`. @@ -651,16 +738,16 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD get_range_t_by_token_t. + METHOD filter_get_range_t_by_token_t. LOOP AT val INTO DATA(ls_token). - INSERT get_range_by_token( ls_token-text ) INTO TABLE result. + INSERT filter_get_range_by_token( ls_token-text ) INTO TABLE result. ENDLOOP. ENDMETHOD. - METHOD get_sql_by_string. + METHOD sql_get_by_string. DATA(lv_sql) = CONV string( val ). REPLACE ALL OCCURRENCES OF ` ` IN lv_sql WITH ``. @@ -673,7 +760,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD get_sql_multi_by_data. + METHOD filter_get_multi_by_data. LOOP AT rtti_get_t_comp_by_data( val ) REFERENCE INTO DATA(lr_comp). INSERT VALUE #( name = lr_comp->name ) INTO TABLE result. @@ -682,7 +769,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD get_string_by_xstring. + METHOD conv_get_string_by_xstring. DATA conv TYPE REF TO object. @@ -715,7 +802,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD get_tab_filter_by_val. + METHOD itab_filter_by_val. LOOP AT tab ASSIGNING FIELD-SYMBOL(). DATA(lv_row) = ``. @@ -737,8 +824,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD get_token_range_mapping. - + METHOD filter_get_token_range_mapping. result = VALUE #( ( n = `EQ` v = `={LOW}` ) @@ -756,9 +842,9 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD get_token_t_by_range_t. + METHOD filter_get_token_t_by_range_t. - DATA(lt_mapping) = get_token_range_mapping( ). + DATA(lt_mapping) = filter_get_token_range_mapping( ). LOOP AT val REFERENCE INTO DATA(lr_row). @@ -772,7 +858,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD get_xstring_by_string. + METHOD conv_get_xstring_by_string. DATA conv TYPE REF TO object. @@ -802,53 +888,6 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. buffer = result. ENDTRY. - - -* result = cl_abap_conv_codepage=>create_out( )->convert( val ). - - ENDMETHOD. - - - METHOD js_load_ext_lib. - - result = ` async loadScriptExt(url) {` && |\n| && - ` this.BusyDialog = new sap.m.BusyDialog({ title: "External Library", text: "... now loading the data from a far away server" });` && |\n| && - ` this.BusyDialog.open();` && |\n| && - |\n| && - ` const loadScript = (FILE_URL, async = true, type = "text/javascript") => {` && |\n| && - ` return new Promise((resolve, reject) => {` && |\n| && - ` try {` && |\n| && - ` const scriptEle = document.createElement("script");` && |\n| && - ` scriptEle.type = type;` && |\n| && - ` scriptEle.async = async;` && |\n| && - ` scriptEle.src = FILE_URL;` && |\n| && - ` scriptEle.addEventListener("load", (ev) => {` && |\n| && - ` resolve({ status: true });` && |\n| && - ` });` && |\n| && - ` scriptEle.addEventListener("error", (ev) => {` && |\n| && - ` reject({` && |\n| && - ` status: false,` && |\n| && - ` message: ``Failed to load the script ${FILE_URL}``` && |\n| && - ` });` && |\n| && - ` });` && |\n| && - ` document.body.appendChild(scriptEle);` && |\n| && - ` } catch (error) {` && |\n| && - ` reject(error);` && |\n| && - ` }` && |\n| && - ` });` && |\n| && - ` };` && |\n| && - |\n| && - ` await loadScript(url)` && |\n| && - ` .then(data => {` && |\n| && - ` this.result = 'A';` && |\n| && - ` }).catch(err => {` && |\n| && - ` this.result = 'E';` && |\n| && - ` });` && |\n| && - ` this.BusyDialog.close();` && |\n| && - ` return this.result;` && |\n| && - |\n| && - ` },`. - ENDMETHOD. @@ -980,7 +1019,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD rtti_xml_get_by_data. + METHOD trans_srtti_xml_by_data. TRY. @@ -1008,7 +1047,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD rtti_xml_set_to_data. + METHOD trans_srtti_xml_2_data. TRY. DATA srtti TYPE REF TO object. @@ -1040,7 +1079,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD source_code_get_method. + METHOD source_get_method. DATA object TYPE REF TO object. FIELD-SYMBOLS TYPE any. DATA lt_source TYPE string_table. @@ -1151,7 +1190,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD trans_json_any_2. + METHOD trans_json_by_any. CASE compress. @@ -1369,7 +1408,7 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION. ENDMETHOD. - METHOD trans_xml_any_2. + METHOD trans_xml_by_any. CALL TRANSFORMATION id SOURCE data = any diff --git a/src/00/z2ui5_cl_util_func.clas.testclasses.abap b/src/00/z2ui5_cl_util_func.clas.testclasses.abap index 9d280a8a..1902c8c5 100644 --- a/src/00/z2ui5_cl_util_func.clas.testclasses.abap +++ b/src/00/z2ui5_cl_util_func.clas.testclasses.abap @@ -364,7 +364,7 @@ CLASS ltcl_unit_test IMPLEMENTATION. METHOD test_func_get_uuid_32. - DATA(lv_uuid) = z2ui5_cl_util_func=>func_get_uuid_32( ). + DATA(lv_uuid) = z2ui5_cl_util_func=>uuid_get_c32( ). IF lv_uuid IS INITIAL. cl_abap_unit_assert=>fail( ). @@ -378,7 +378,7 @@ CLASS ltcl_unit_test IMPLEMENTATION. METHOD test_func_get_uuid_22. - DATA(lv_uuid) = z2ui5_cl_util_func=>func_get_uuid_22( ). + DATA(lv_uuid) = z2ui5_cl_util_func=>uuid_Get_c22( ). IF lv_uuid IS INITIAL. cl_abap_unit_assert=>fail( ). @@ -392,7 +392,7 @@ CLASS ltcl_unit_test IMPLEMENTATION. METHOD test_func_get_user_tech. - DATA(lv_uname) = z2ui5_cl_util_func=>func_get_user_tech( ). + DATA(lv_uname) = z2ui5_cl_util_func=>user_get_tech( ). IF sy-uname <> lv_uname OR lv_uname IS INITIAL. cl_abap_unit_assert=>fail( ). ENDIF. @@ -439,7 +439,7 @@ CLASS ltcl_unit_test IMPLEMENTATION. ( title = 'Test2' value = 'this is a new descr' selected = abap_false ) ). - DATA(lv_tab_json) = z2ui5_cl_util_func=>trans_json_any_2( lt_tab ). + DATA(lv_tab_json) = z2ui5_cl_util_func=>trans_json_by_any( lt_tab ). DATA(lv_result) = `[{"TITLE":"Test","VALUE":"this is a description","SELECTED":true},{"TITLE":"Test2","VALUE":"this is a new descr"}]`. @@ -508,7 +508,7 @@ CLASS ltcl_unit_test IMPLEMENTATION. DATA(ls_row) = VALUE ty_row( ). ls_row-title = `test`. - DATA(lv_json) = z2ui5_cl_util_func=>trans_json_any_2( ls_row ). + DATA(lv_json) = z2ui5_cl_util_func=>trans_json_by_any( ls_row ). IF lv_json IS INITIAL. cl_abap_unit_assert=>fail( ). @@ -729,7 +729,7 @@ CLASS ltcl_unit_test IMPLEMENTATION. METHOD test_trans_xml_any_2__w_obj. DATA(lo_obj) = NEW ltcl_test_app( ). - DATA(lv_xml) = z2ui5_cl_util_func=>trans_xml_any_2( lo_obj ). + DATA(lv_xml) = z2ui5_cl_util_func=>trans_xml_by_any( lo_obj ). IF lv_xml IS INITIAL. cl_abap_unit_assert=>fail( ). @@ -739,7 +739,7 @@ CLASS ltcl_unit_test IMPLEMENTATION. METHOD test_trans_xml_2_any__w_obj. DATA(lo_obj) = NEW ltcl_test_app( ). - DATA(lv_xml) = z2ui5_cl_util_func=>trans_xml_any_2( lo_obj ). + DATA(lv_xml) = z2ui5_cl_util_func=>trans_xml_by_any( lo_obj ). CLEAR lo_obj. z2ui5_cl_util_func=>trans_xml_2_any( @@ -771,7 +771,7 @@ CLASS ltcl_unit_test IMPLEMENTATION. DATA(ls_row) = VALUE ty_row( ). ls_row-value = `test`. - DATA(lv_xml) = z2ui5_cl_util_func=>trans_xml_any_2( ls_row ). + DATA(lv_xml) = z2ui5_cl_util_func=>trans_xml_by_any( ls_row ). IF lv_xml IS INITIAL. cl_abap_unit_assert=>fail( ). @@ -796,7 +796,7 @@ CLASS ltcl_unit_test IMPLEMENTATION. DATA(ls_row2) = VALUE ty_row( ). ls_row-value = `test`. - DATA(lv_xml) = z2ui5_cl_util_func=>trans_xml_any_2( ls_row ). + DATA(lv_xml) = z2ui5_cl_util_func=>trans_xml_by_any( ls_row ). z2ui5_cl_util_func=>trans_xml_2_any( EXPORTING diff --git a/src/00/z2ui5_cx_util_error.clas.abap b/src/00/z2ui5_cx_util_error.clas.abap index fc5349e6..397630fb 100644 --- a/src/00/z2ui5_cx_util_error.clas.abap +++ b/src/00/z2ui5_cx_util_error.clas.abap @@ -40,7 +40,7 @@ CLASS Z2UI5_CX_UTIL_ERROR IMPLEMENTATION. CATCH cx_root. ms_error-text = val. ENDTRY. - ms_error-uuid = z2ui5_cl_util_func=>func_get_uuid_32( ). + ms_error-uuid = z2ui5_cl_util_func=>uuid_get_c32( ). ENDMETHOD. diff --git a/src/01/01/z2ui5_cl_fw_binding.clas.abap b/src/01/01/z2ui5_cl_fw_binding.clas.abap index 44c37de9..37285634 100644 --- a/src/01/01/z2ui5_cl_fw_binding.clas.abap +++ b/src/01/01/z2ui5_cl_fw_binding.clas.abap @@ -178,7 +178,7 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION. result = COND #( WHEN mv_type = cs_bind_type-two_way THEN `/` && cv_model_edit_name && `/` ELSE `/` ) && bind->name_front. IF strlen( result ) > 30. - bind->name_front = z2ui5_cl_util_func=>func_get_uuid_22( ). + bind->name_front = z2ui5_cl_util_func=>uuid_Get_c22( ). result = COND #( WHEN mv_type = cs_bind_type-two_way THEN `/` && cv_model_edit_name && `/` ELSE `/` ) && bind->name_front. ENDIF. @@ -189,10 +189,10 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION. FIELD-SYMBOLS TYPE any. ASSIGN mr_data->* TO . - DATA(lv_id) = z2ui5_cl_util_func=>func_get_uuid_22( ). + DATA(lv_id) = z2ui5_cl_util_func=>uuid_Get_c22( ). INSERT VALUE #( name = lv_id - data_stringify = z2ui5_cl_util_func=>trans_json_any_2( any = mr_data compress = me->mv_compress ) + data_stringify = z2ui5_cl_util_func=>trans_json_by_any( any = mr_data compress = me->mv_compress ) bind_type = cs_bind_type-one_time ) INTO TABLE mt_attri. result = |/{ lv_id }|. diff --git a/src/01/01/z2ui5_cl_fw_client.clas.abap b/src/01/01/z2ui5_cl_fw_client.clas.abap index 453648eb..2a3aee5f 100644 --- a/src/01/01/z2ui5_cl_fw_client.clas.abap +++ b/src/01/01/z2ui5_cl_fw_client.clas.abap @@ -131,7 +131,7 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION. METHOD z2ui5_if_client~nav_app_call. mo_handler->ms_next-o_app_call = app. IF app->id_draft IS INITIAL. - app->id_app = z2ui5_cl_util_func=>func_get_uuid_32( ). + app->id_app = z2ui5_cl_util_func=>uuid_get_c32( ). ENDIF. result = app->id_app. ENDMETHOD. @@ -140,7 +140,7 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION. METHOD z2ui5_if_client~nav_app_leave. mo_handler->ms_next-o_app_leave = app. IF app->id_draft IS INITIAL. - app->id_app = z2ui5_cl_util_func=>func_get_uuid_32( ). + app->id_app = z2ui5_cl_util_func=>uuid_get_c32( ). ENDIF. result = app->id_app. ENDMETHOD. diff --git a/src/01/01/z2ui5_cl_fw_controller.clas.abap b/src/01/01/z2ui5_cl_fw_controller.clas.abap index a3774136..fd7a282a 100644 --- a/src/01/01/z2ui5_cl_fw_controller.clas.abap +++ b/src/01/01/z2ui5_cl_fw_controller.clas.abap @@ -64,6 +64,14 @@ CLASS z2ui5_cl_fw_controller DEFINITION DATA ms_actual TYPE z2ui5_if_client=>ty_s_get. DATA ms_next TYPE ty_s_next. + CLASS-METHODS main + IMPORTING + body TYPE string + RETURNING + VALUE(result) TYPE string. + + PROTECTED SECTION. + CLASS-METHODS request_begin IMPORTING body TYPE string @@ -131,7 +139,6 @@ CLASS z2ui5_cl_fw_controller DEFINITION METHODS app_client_end_db. - PROTECTED SECTION. PRIVATE SECTION. ENDCLASS. @@ -139,10 +146,46 @@ ENDCLASS. CLASS z2ui5_cl_fw_controller IMPLEMENTATION. + METHOD main. + + TRY. + DATA(lo_handler) = request_begin( body ). + CATCH cx_root INTO DATA(x). + lo_handler = app_system_factory( x ). + ENDTRY. + + DO. + TRY. + + ROLLBACK WORK. + CAST z2ui5_if_app( lo_handler->ms_db-app )->main( NEW z2ui5_cl_fw_client( lo_handler ) ). + ROLLBACK WORK. + + IF lo_handler->ms_next-o_app_leave IS NOT INITIAL. + lo_handler = lo_handler->app_leave_factory( ). + CONTINUE. + ENDIF. + + IF lo_handler->ms_next-o_app_call IS NOT INITIAL. + lo_handler = lo_handler->app_call_factory( ). + CONTINUE. + ENDIF. + + result = lo_handler->request_end( ). + + CATCH cx_root INTO x. + lo_handler = app_system_factory( x ). + CONTINUE. + ENDTRY. + + EXIT. + ENDDO. + + ENDMETHOD. METHOD app_next_factory. - app->id_draft = COND #( WHEN app->id_draft IS INITIAL THEN z2ui5_cl_util_func=>func_get_uuid_32( ) ELSE app->id_draft ). + app->id_draft = COND #( WHEN app->id_draft IS INITIAL THEN z2ui5_cl_util_func=>uuid_get_c32( ) ELSE app->id_draft ). r_result = NEW #( ). r_result->ms_db-app = app. @@ -234,7 +277,7 @@ CLASS z2ui5_cl_fw_controller IMPLEMENTATION. TRY. FIELD-SYMBOLS TYPE any. - data ls_params type ref to data. + DATA ls_params TYPE REF TO data. ls_params = location->get_attribute( `STARTUP_PARAMETERS` )->get_val_ref( ). ASSIGN ls_params->* TO . @@ -314,7 +357,7 @@ CLASS z2ui5_cl_fw_controller IMPLEMENTATION. result = NEW #( ). result->ms_db = z2ui5_cl_fw_db=>load_app( id_prev ). - result->ms_db-id = z2ui5_cl_util_func=>func_get_uuid_32( ). + result->ms_db-id = z2ui5_cl_util_func=>uuid_get_c32( ). result->ms_db-id_prev = id_prev. TRY. @@ -348,10 +391,9 @@ CLASS z2ui5_cl_fw_controller IMPLEMENTATION. TRY. DATA(lv_classname) = to_upper( so_body->get_attribute( `APP_START` )->get_val( ) ). - lv_classname = shift_left( val = lv_classname - sub = cl_abap_char_utilities=>horizontal_tab ). - lv_classname = shift_right( val = lv_classname - sub = cl_abap_char_utilities=>horizontal_tab ). + lv_classname = z2ui5_cl_util_func=>c_trim( lv_classname ). +* lv_classname = shift_left( val = lv_classname sub = cl_abap_char_utilities=>horizontal_tab ). +* lv_classname = shift_right( val = lv_classname sub = cl_abap_char_utilities=>horizontal_tab ). CATCH cx_root. ENDTRY. @@ -366,7 +408,7 @@ CLASS z2ui5_cl_fw_controller IMPLEMENTATION. TRY. result = NEW #( ). - result->ms_db-id = z2ui5_cl_util_func=>func_get_uuid_32( ). + result->ms_db-id = z2ui5_cl_util_func=>uuid_get_c32( ). lv_classname = z2ui5_cl_util_func=>c_trim_upper( lv_classname ). CREATE OBJECT result->ms_db-app TYPE (lv_classname). @@ -382,7 +424,7 @@ CLASS z2ui5_cl_fw_controller IMPLEMENTATION. METHOD app_system_factory. result = NEW #( ). - result->ms_db-id = z2ui5_cl_util_func=>func_get_uuid_32( ). + result->ms_db-id = z2ui5_cl_util_func=>uuid_get_c32( ). IF ix IS NOT BOUND AND error_text IS NOT INITIAL. ix = NEW z2ui5_cx_util_error( val = error_text ). @@ -447,7 +489,7 @@ CLASS z2ui5_cl_fw_controller IMPLEMENTATION. apos_active = abap_false ). lo_resp->add_attribute( n = `PARAMS` - v = z2ui5_cl_util_func=>trans_json_any_2( ms_next-s_set ) + v = z2ui5_cl_util_func=>trans_json_by_any( ms_next-s_set ) apos_active = abap_false ). lo_resp->add_attribute( n = `ID` diff --git a/src/01/01/z2ui5_cl_fw_controller.clas.testclasses.abap b/src/01/01/z2ui5_cl_fw_controller.clas.testclasses.abap index 95ef9608..00d8a1d5 100644 --- a/src/01/01/z2ui5_cl_fw_controller.clas.testclasses.abap +++ b/src/01/01/z2ui5_cl_fw_controller.clas.testclasses.abap @@ -9,6 +9,7 @@ CLASS ltcl_unit_test DEFINITION FINAL FOR TESTING ENDCLASS. +class z2ui5_cl_fw_controller definition local friends ltcl_unit_test. CLASS ltcl_unit_test IMPLEMENTATION. diff --git a/src/01/01/z2ui5_cl_fw_db.clas.abap b/src/01/01/z2ui5_cl_fw_db.clas.abap index 42202c7e..d8e8480d 100644 --- a/src/01/01/z2ui5_cl_fw_db.clas.abap +++ b/src/01/01/z2ui5_cl_fw_db.clas.abap @@ -79,7 +79,7 @@ CLASS z2ui5_cl_fw_db IMPLEMENTATION. id_prev = db-id_prev id_prev_app = db-id_prev_app id_prev_app_stack = db-id_prev_app_stack - uname = z2ui5_cl_util_func=>func_get_user_tech( ) + uname = z2ui5_cl_util_func=>user_get_tech( ) timestampl = z2ui5_cl_util_func=>time_get_timestampl( ) data = lv_xml ). @@ -118,7 +118,7 @@ CLASS z2ui5_cl_fw_db IMPLEMENTATION. val = `LOAD_DRAFT_FROM_DATABASE_FAILED / ATTRI_NOT_FOUND ` && lr_attri->name. ENDIF. - z2ui5_cl_util_func=>rtti_xml_set_to_data( + z2ui5_cl_util_func=>trans_srtti_xml_2_data( EXPORTING rtti_data = lr_attri->data_rtti IMPORTING @@ -160,7 +160,7 @@ CLASS z2ui5_cl_fw_db IMPLEMENTATION. METHOD trans_any_2_xml. TRY. - result = z2ui5_cl_util_func=>trans_xml_any_2( db ). + result = z2ui5_cl_util_func=>trans_xml_by_any( db ). CATCH cx_xslt_serialization_error INTO DATA(x). TRY. @@ -189,12 +189,12 @@ CLASS z2ui5_cl_fw_db IMPLEMENTATION. IF sy-subrc <> 0. CONTINUE. ENDIF. - lr_attri->data_rtti = z2ui5_cl_util_func=>rtti_xml_get_by_data( ). + lr_attri->data_rtti = z2ui5_cl_util_func=>trans_srtti_xml_by_data( ). CLEAR . CLEAR . ENDLOOP. - result = z2ui5_cl_util_func=>trans_xml_any_2( ls_db ). + result = z2ui5_cl_util_func=>trans_xml_by_any( ls_db ). CATCH z2ui5_cx_util_error INTO DATA(x_util). RAISE EXCEPTION x_util. diff --git a/src/01/01/z2ui5_cl_fw_http_handler.clas.abap b/src/01/01/z2ui5_cl_fw_http_handler.clas.abap index 975dd748..a5f57a5e 100644 --- a/src/01/01/z2ui5_cl_fw_http_handler.clas.abap +++ b/src/01/01/z2ui5_cl_fw_http_handler.clas.abap @@ -16,529 +16,38 @@ CLASS z2ui5_cl_fw_http_handler DEFINITION IMPORTING t_config TYPE z2ui5_if_client=>ty_t_name_value OPTIONAL content_security_policy TYPE clike OPTIONAL - custom_js TYPE string OPTIONAL - json_model_limit TYPE string DEFAULT '100' + custom_js TYPE clike OPTIONAL + json_model_limit TYPE clike DEFAULT '100' PREFERRED PARAMETER t_config RETURNING - VALUE(r_result) TYPE string. + VALUE(result) TYPE string. PROTECTED SECTION. - CLASS-METHODS get_js - RETURNING VALUE(result) TYPE string. PRIVATE SECTION. - ENDCLASS. -CLASS Z2UI5_CL_FW_HTTP_HANDLER IMPLEMENTATION. - - - METHOD get_js. - - result = `sap.ui.define("z2ui5/Controller", ["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/model/json/JSONModel", "sap/ui/core/BusyIndicator", "sap/m/MessageBox", "sap/m/MessageToast", "sap/ui/core/Fragment"], function(Control` && - `ler, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment) {` && |\n| && - ` "use strict";` && |\n| && - ` return Controller.extend("z2ui5.Controller", {` && |\n| && - ` async onAfterRendering() {` && |\n| && - ` try{` && |\n| && - ` if (!sap.z2ui5.oResponse.PARAMS) {` && |\n| && - ` return;` && |\n| && - ` }` && |\n| && - ` const {S_POPUP, S_VIEW_NEST, S_VIEW_NEST2, S_POPOVER} = sap.z2ui5.oResponse.PARAMS;` && |\n| && - ` if (S_POPUP?.CHECK_DESTROY) {` && |\n| && - ` sap.z2ui5.oController.PopupDestroy();` && |\n| && - ` }` && |\n| && - ` if (S_POPOVER?.CHECK_DESTROY) {` && |\n| && - ` sap.z2ui5.oController.PopoverDestroy();` && |\n| && - ` }` && |\n| && - ` if (S_POPUP?.XML) {` && |\n| && - ` sap.z2ui5.oController.PopupDestroy();` && |\n| && - ` await this.displayFragment(S_POPUP.XML, 'oViewPopup');` && |\n| && - ` }` && |\n| && - ` if (!sap.z2ui5.checkNestAfter) {` && |\n| && - ` if (S_VIEW_NEST?.XML) {` && |\n| && - ` sap.z2ui5.oController.NestViewDestroy();` && |\n| && - ` await this.displayNestedView(S_VIEW_NEST.XML, 'oViewNest', 'S_VIEW_NEST');` && |\n| && - ` sap.z2ui5.checkNestAfter = true;` && |\n| && - ` }` && |\n| && - ` }` && |\n| && - ` if (!sap.z2ui5.checkNestAfter2) {` && |\n| && - ` if (S_VIEW_NEST2?.XML) {` && |\n| && - ` sap.z2ui5.oController.NestViewDestroy2();` && |\n| && - ` await this.displayNestedView(S_VIEW_NEST2.XML, 'oViewNest2', 'S_VIEW_NEST2');` && |\n| && - ` sap.z2ui5.checkNestAfter2 = true;` && |\n| && - ` }` && |\n| && - ` }` && |\n| && - ` if (S_POPOVER?.XML) {` && |\n| && - ` await this.displayFragment(S_POPOVER.XML, 'oViewPopover', S_POPOVER.OPEN_BY_ID);` && |\n| && - ` }` && |\n| && - ` BusyIndicator.hide();` && |\n| && - ` if (sap.z2ui5.isBusy) {` && |\n| && - ` sap.z2ui5.isBusy = false;` && |\n| && - ` }` && |\n| && - ` if (sap.z2ui5.busyDialog) {` && |\n| && - ` sap.z2ui5.busyDialog.close();` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.onAfterRendering.forEach(item=>{` && |\n| && - ` if (item !== undefined) {` && |\n| && - ` item();` && |\n| && - ` }` && |\n| && - ` }` && |\n| && - ` )` && |\n| && - ` }catch(e){ BusyIndicator.hide(); MessageBox.error(e.toLocaleString()); }` && |\n| && - ` },` && |\n| && - |\n| && - ` async displayFragment(xml, viewProp, openById) {` && |\n| && - ` const oFragment = await Fragment.load({` && |\n| && - ` definition: xml,` && |\n| && - ` controller: sap.z2ui5.oController,` && |\n| && - ` });` && |\n| && - ` let oview_model = new JSONModel(sap.z2ui5.oResponse.OVIEWMODEL);` && |\n| && - ` oview_model.setSizeLimit(sap.z2ui5.JSON_MODEL_LIMIT);` && |\n| && - ` oFragment.setModel(oview_model);` && |\n| && - ` let oControl = openById ? this.getControlById(openById) : null;` && |\n| && - ` if (oControl) {` && |\n| && - ` oFragment.openBy(oControl);` && |\n| && - ` } else {` && |\n| && - ` oFragment.open();` && |\n| && - ` }` && |\n| && - ` sap.z2ui5[viewProp] = oFragment;` && |\n| && - ` },` && |\n| && - |\n| && - ` async displayNestedView(xml, viewProp, viewNestId) {` && |\n| && - ` const oView = await XMLView.create({` && |\n| && - ` definition: xml,` && |\n| && - ` controller: sap.z2ui5.oControllerNest,` && |\n| && - ` });` && |\n| && - |\n| && - ` let oview_model = new JSONModel(sap.z2ui5.oResponse.OVIEWMODEL);` && |\n| && - ` oview_model.setSizeLimit(sap.z2ui5.JSON_MODEL_LIMIT);` && |\n| && - ` oView.setModel(oview_model);` && |\n| && - |\n| && - ` let oParent = sap.z2ui5.oView.byId(sap.z2ui5.oResponse.PARAMS[viewNestId].ID);` && |\n| && - ` if (oParent) {` && |\n| && - ` try {` && |\n| && - ` oParent[sap.z2ui5.oResponse.PARAMS[viewNestId].METHOD_DESTROY]();` && |\n| && - ` } catch {}` && |\n| && - ` oParent[sap.z2ui5.oResponse.PARAMS[viewNestId].METHOD_INSERT](oView);` && |\n| && - ` }` && |\n| && - ` sap.z2ui5[viewProp] = oView;` && |\n| && - ` },` && |\n| && - |\n| && - ` getControlById(id) {` && |\n| && - ` let oControl = sap.z2ui5.oView.byId(id);` && |\n| && - ` if (!oControl) {` && |\n| && - ` oControl = sap.ui.getCore().byId(id);` && |\n| && - ` debugger ;` && |\n| && - ` }` && |\n| && - ` if (!oControl) {` && |\n| && - ` oControl = sap.z2ui5.oViewNest.byId(id) || sap.z2ui5.oViewNest2.byId(id);` && |\n| && - ` }` && |\n| && - ` return oControl;` && |\n| && - ` },` && |\n| && - |\n| && - ` PopupDestroy() {` && |\n| && - ` if (!sap.z2ui5.oViewPopup) {` && |\n| && - ` return;` && |\n| && - ` }` && |\n| && - ` if (sap.z2ui5.oViewPopup.close) {` && |\n| && - ` try {` && |\n| && - ` sap.z2ui5.oViewPopup.close();` && |\n| && - ` } catch {}` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.oViewPopup.destroy();` && |\n| && - ` },` && |\n| && - ` PopoverDestroy() {` && |\n| && - ` if (!sap.z2ui5.oViewPopover) {` && |\n| && - ` return;` && |\n| && - ` }` && |\n| && - ` if (sap.z2ui5.oViewPopover.close) {` && |\n| && - ` try {` && |\n| && - ` sap.z2ui5.oViewPopover.close();` && |\n| && - ` } catch {}` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.oViewPopover.destroy();` && |\n| && - ` },` && |\n| && - ` NestViewDestroy() {` && |\n| && - ` if (!sap.z2ui5.oViewNest) {` && |\n| && - ` return;` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.oViewNest.destroy();` && |\n| && - ` },` && |\n| && - ` NestViewDestroy2() {` && |\n| && - ` if (!sap.z2ui5.oViewNest2) {` && |\n| && - ` return;` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.oViewNest2.destroy();` && |\n| && - ` },` && |\n| && - ` ViewDestroy() {` && |\n| && - ` if (!sap.z2ui5.oView) {` && |\n| && - ` return;` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.oView.destroy();` && |\n| && - ` },` && |\n| && - ` onEventFrontend(...args) {` && |\n| && - |\n| && - ` sap.z2ui5.onBeforeEventFrontend.forEach(item => {` && |\n| && - ` if (item !== undefined) {` && |\n| && - ` item(args);` && |\n| && - ` }` && |\n| && - ` }` && |\n| && - ` )` && |\n| && - |\n| && - ` let oCrossAppNavigator;` && |\n| && - ` switch (args[0].EVENT) {` && |\n| && - ` case 'CROSS_APP_NAV_TO_PREV_APP':` && |\n| && - ` oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");` && |\n| && - ` oCrossAppNavigator.backToPreviousApp();` && |\n| && - ` break;` && |\n| && - ` case 'CROSS_APP_NAV_TO_EXT':` && |\n| && - ` oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");` && |\n| && - ` const hash = (oCrossAppNavigator.hrefForExternal({` && |\n| && - ` target: args[1],` && |\n| && - ` params: args[2]` && |\n| && - ` })) || "";` && |\n| && - ` if (args[3] === 'EXT') {` && |\n| && - ` let url = window.location.href.split('#')[0] + hash;` && |\n| && - ` sap.m.URLHelper.redirect(url, true);` && |\n| && - ` } else {` && |\n| && - ` oCrossAppNavigator.toExternal({` && |\n| && - ` target: {` && |\n| && - ` shellHash: hash` && |\n| && - ` }` && |\n| && - ` });` && |\n| && - ` }` && |\n| && - ` break;` && |\n| && - ` case 'LOCATION_RELOAD':` && |\n| && - ` window.location = args[1];` && |\n| && - ` break;` && |\n| && - ` case 'OPEN_NEW_TAB':` && |\n| && - ` window.open(args[1], '_blank');` && |\n| && - ` break;` && |\n| && - ` case 'POPUP_CLOSE':` && |\n| && - ` sap.z2ui5.oController.PopupDestroy();` && |\n| && - ` break;` && |\n| && - ` case 'POPOVER_CLOSE':` && |\n| && - ` sap.z2ui5.oController.PopoverDestroy();` && |\n| && - ` break;` && |\n| && - ` case 'NAV_CONTAINER_TO':` && |\n| && - ` var navCon = sap.z2ui5.oView.byId(args[1]);` && |\n| && - ` var navConTo = sap.z2ui5.oView.byId(args[2]);` && |\n| && - ` navCon.to(navConTo);` && |\n| && - ` break;` && |\n| && - ` case 'NEST_NAV_CONTAINER_TO':` && |\n| && - ` navCon = sap.z2ui5.oViewNest.byId(args[1]);` && |\n| && - ` navConTo = sap.z2ui5.oViewNest.byId(args[2]);` && |\n| && - ` navCon.to(navConTo);` && |\n| && - ` break;` && |\n| && - ` case 'NEST2_NAV_CONTAINER_TO':` && |\n| && - ` navCon = sap.z2ui5.oViewNest2.byId(args[1]);` && |\n| && - ` navConTo = sap.z2ui5.oViewNest2.byId(args[2]);` && |\n| && - ` navCon.to(navConTo);` && |\n| && - ` break;` && |\n| && - ` }` && |\n| && - ` },` && |\n| && - ` onEvent(...args) {` && |\n| && - ` if (sap.z2ui5.isBusy) {` && |\n| && - ` if (sap.z2ui5.isBusy == true) {` && |\n| && - ` sap.z2ui5.busyDialog = new sap.m.BusyDialog();` && |\n| && - ` sap.z2ui5.busyDialog.open();` && |\n| && - ` return;` && |\n| && - ` }` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.isBusy = true;` && |\n| && - ` if (!window.navigator.onLine) {` && |\n| && - ` sap.m.MessageBox.alert('No internet connection! Please reconnect to the server and try again.');` && |\n| && - ` sap.z2ui5.isBusy = false;` && |\n| && - ` return;` && |\n| && - ` }` && |\n| && - ` BusyIndicator.show();` && |\n| && - ` sap.z2ui5.oBody = {};` && |\n| && - ` let isUpdated = false;` && |\n| && - ` if (sap.z2ui5.oViewPopup) {` && |\n| && -* ` if (sap.z2ui5.oViewPopup.isOpen ) { if( sap.z2ui5.oViewPopup.isOpen() == true ) {` && |\n| && -* ` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewPopup.getModel().getData().EDIT;` && |\n| && -* ` isUpdated = true;` && |\n| && -* ` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| && -* ` } }` && |\n| && - ` if (sap.z2ui5.oViewPopup.getVisible ) { if( sap.z2ui5.oViewPopup.getVisible() == true ) {` && |\n| && - ` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewPopup.getModel().getData().EDIT;` && |\n| && - ` isUpdated = true;` && |\n| && - ` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| && - ` } }` && |\n| && - ` }` && |\n| && - ` if (isUpdated == false) {` && |\n| && - ` if (sap.z2ui5.oViewPopover) {` && |\n| && - ` if (sap.z2ui5.oViewPopover.isOpen) {` && |\n| && - ` if (sap.z2ui5.oViewPopover.isOpen() == true) {` && |\n| && - ` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewPopover.getModel().getData().EDIT;` && |\n| && - ` isUpdated = true;` && |\n| && - ` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| && - ` }` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.oViewPopover.destroy();` && |\n| && - ` }` && |\n| && - ` }` && |\n| && - ` if (isUpdated == false) {` && |\n| && - ` if (sap.z2ui5.oViewNest == this.getView()) {` && |\n| && - ` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewNest.getModel().getData().EDIT;` && |\n| && - ` sap.z2ui5.oBody.VIEWNAME = 'NEST';` && |\n| && - ` isUpdated = true;` && |\n| && - ` }` && |\n| && - ` }` && |\n| && - ` if (isUpdated == false) {` && |\n| && - ` sap.z2ui5.oBody.EDIT = sap.z2ui5.oView.getModel().getData().EDIT;` && |\n| && - ` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| && - ` }` && |\n| && - |\n| && - ` sap.z2ui5.onBeforeRoundtrip.forEach(item=>{` && |\n| && - ` if (item !== undefined) {` && |\n| && - ` item();` && |\n| && - ` }` && |\n| && - ` }` && |\n| && - ` )` && |\n| && - ` if (args[0].CHECK_VIEW_DESTROY) {` && |\n| && - ` sap.z2ui5.oController.ViewDestroy();` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.oBody.ID = sap.z2ui5.oResponse.ID;` && |\n| && - ` sap.z2ui5.oBody.ARGUMENTS = args;` && |\n| && - |\n| && - ` sap.z2ui5.oResponseOld = sap.z2ui5.oResponse;` && |\n| && - ` sap.z2ui5.oResponse = {};` && |\n| && - ` sap.z2ui5.oController.Roundtrip();` && |\n| && - ` },` && |\n| && - ` responseError(response) {` && |\n| && - ` document.write(response);` && |\n| && - ` },` && |\n| && - ` updateModelIfRequired(paramKey, oView) {` && |\n| && - ` if (sap.z2ui5.oResponse.PARAMS[paramKey]?.CHECK_UPDATE_MODEL) {` && |\n| && - ` let model = new JSONModel(sap.z2ui5.oResponse.OVIEWMODEL);` && |\n| && - ` model.setSizeLimit(sap.z2ui5.JSON_MODEL_LIMIT);` && |\n| && - ` oView.setModel(model);` && |\n| && - ` }` && |\n| && - ` },` && |\n| && - ` async responseSuccess(response) {` && |\n| && - ` try{` && |\n| && - ` sap.z2ui5.oResponse = response;` && |\n| && - |\n| && - ` if (sap.z2ui5.oResponse.PARAMS?.S_VIEW?.CHECK_DESTROY) {` && |\n| && - ` sap.z2ui5.oController.ViewDestroy();` && |\n| && - ` }` && |\n| && - |\n| && - ` sap.z2ui5.oController.showMessage('S_MSG_TOAST', sap.z2ui5.oResponse.PARAMS);` && |\n| && - ` sap.z2ui5.oController.showMessage('S_MSG_BOX', sap.z2ui5.oResponse.PARAMS);` && |\n| && - ` if (sap.z2ui5.oResponse.PARAMS?.S_VIEW?.XML) { if ( sap.z2ui5.oResponse.PARAMS?.S_VIEW?.XML !== '') {` && |\n| && - ` sap.z2ui5.oController.ViewDestroy();` && |\n| && - ` await sap.z2ui5.oController.createView(sap.z2ui5.oResponse.PARAMS.S_VIEW.XML, sap.z2ui5.oResponse.OVIEWMODEL);` && |\n| && - `  return; } } ` && |\n| && -* ` } else {` && |\n| && - ` this.updateModelIfRequired('S_VIEW', sap.z2ui5.oView);` && |\n| && - ` this.updateModelIfRequired('S_VIEW_NEST', sap.z2ui5.oViewNest);` && |\n| && - ` this.updateModelIfRequired('S_VIEW_NEST2', sap.z2ui5.oViewNest2);` && |\n| && - ` this.updateModelIfRequired('S_POPUP', sap.z2ui5.oViewPopup);` && |\n| && - ` this.updateModelIfRequired('S_POPOVER', sap.z2ui5.oViewPopover);` && |\n| && - ` sap.z2ui5.oController.onAfterRendering();` && |\n| && -* ` }` && |\n| && -` }catch(e){ BusyIndicator.hide(); MessageBox.error(e.toLocaleString()); }` && |\n| && - ` },` && |\n| && - ` showMessage(msgType, params) {` && |\n| && - ` if (params[msgType]?.TEXT !== undefined) {` && |\n| && - ` if (msgType === 'S_MSG_TOAST') {` && |\n| && - ` MessageToast.show(params[msgType].TEXT);` && |\n| && - ` } else if (msgType === 'S_MSG_BOX') {` && |\n| && - ` MessageBox[params[msgType].TYPE](params[msgType].TEXT);` && |\n| && - ` }` && |\n| && - ` }` && |\n| && - ` },` && |\n| && - ` async createView(xml, viewModel) {` && |\n| && - ` const oView = await XMLView.create({` && |\n| && - ` definition: xml,` && |\n| && - ` controller: sap.z2ui5.oController,` && |\n| && - ` });` && |\n| && - ` let oview_model = new JSONModel(viewModel);` && |\n| && - ` oview_model.setSizeLimit(sap.z2ui5.JSON_MODEL_LIMIT);` && |\n| && - ` oView.setModel(oview_model);` && |\n| && - |\n| && - ` if (sap.z2ui5.oParent) {` && |\n| && - ` sap.z2ui5.oParent.removeAllPages();` && |\n| && - ` sap.z2ui5.oParent.insertPage(oView);` && |\n| && - ` } else {` && |\n| && - ` oView.placeAt("content");` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.oView = oView;` && |\n| && - ` },` && |\n| && - ` async readHttp() {` && |\n| && - ` const response = await fetch(sap.z2ui5.pathname, {` && |\n| && - ` method: 'POST',` && |\n| && - ` headers: {` && |\n| && - ` 'Content-Type': 'application/json'` && |\n| && - ` },` && |\n| && - ` body: JSON.stringify(sap.z2ui5.oBody)` && |\n| && - ` });` && |\n| && - |\n| && - ` if (!response.ok) {` && |\n| && - ` const responseText = await response.text();` && |\n| && - ` sap.z2ui5.oController.responseError(responseText);` && |\n| && - ` } else {` && |\n| && - ` const responseData = await response.json();` && |\n| && - ` sap.z2ui5.oController.responseSuccess(responseData);` && |\n| && - ` }` && |\n| && - |\n| && - ` },` && |\n| && - |\n| && - ` Roundtrip() {` && |\n| && - |\n| && - ` sap.z2ui5.checkTimerActive = false;` && |\n| && - ` sap.z2ui5.checkNestAfter = false;` && |\n| && - ` sap.z2ui5.checkNestAfter2 = false;` && |\n| && - |\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) {` && |\n| && - ` sap.z2ui5.oBody.OLOCATION.SEARCH = sap.z2ui5.search;` && |\n| && - ` }` && |\n| && - ` sap.z2ui5.oController.readHttp();` && |\n| && - ` },` && |\n| && - ` })` && |\n| && - `});` && |\n| && - |\n| && - `sap.ui.require(["z2ui5/Controller", "sap/ui/core/BusyIndicator", "sap/ui/core/mvc/XMLView", "sap/ui/core/Fragment", "sap/m/MessageToast", "sap/m/MessageBox", "sap/ui/model/json/JSONModel"], (Controller,BusyIndicator)=>{` && |\n| && - |\n| && - ` BusyIndicator.show();` && |\n| && - ` sap.z2ui5.oController = new Controller();` && |\n| && - ` sap.z2ui5.oControllerNest = new Controller();` && |\n| && - ` sap.z2ui5.oControllerNest2 = new Controller();` && |\n| && - |\n| && - ` sap.z2ui5.pathname = sap.z2ui5.pathname || window.location.pathname;` && |\n| && - ` sap.z2ui5.checkNestAfter = false;` && |\n| && - |\n| && - ` sap.z2ui5.oBody = {` && |\n| && - ` APP_START: sap.z2ui5.APP_START` && |\n| && - ` };` && |\n| && - ` sap.z2ui5.oController.Roundtrip();` && |\n| && - |\n| && - ` sap.z2ui5.onBeforeRoundtrip = [];` && |\n| && - ` sap.z2ui5.onAfterRendering = [];` && |\n| && - ` sap.z2ui5.onBeforeEventFrontend = [];` && |\n| && - ` sap.z2ui5.onAfterRoundtrip = []; }` && |\n| && - `);`. - - ENDMETHOD. - +CLASS z2ui5_cl_fw_http_handler IMPLEMENTATION. METHOD http_get. - DATA(lt_config) = t_config. - IF lt_config IS INITIAL. - lt_config = VALUE #( -* ( n = `src` v = `https://sdk.openui5.org/nightly/2/resources/sap-ui-core.js` ) - ( n = `src` v = `https://sdk.openui5.org/resources/sap-ui-cachebuster/sap-ui-core.js` ) -* ( n = `src` v = `https://ui5.sap.com/1.120.0/resources/sap-ui-core.js` ) - ( n = `data-sap-ui-theme` v = `sap_horizon` ) - ( n = `data-sap-ui-async` v = `true` ) - ( n = `data-sap-ui-bindingSyntax` v = `complex` ) - ( n = `data-sap-ui-frameOptions` v = `trusted` ) - ( n = `data-sap-ui-compatVersion` v = `edge` ) ). - ENDIF. + DATA(lo_index) = z2ui5_cl_fw_index_html=>factory( VALUE #( + t_config = t_config + content_security_policy = content_security_policy + custom_js = custom_js + json_model_limit = json_model_limit + ) ). - IF content_security_policy IS NOT SUPPLIED. - DATA(lv_sec_policy) = ``. - ELSE. - lv_sec_policy = content_security_policy. - ENDIF. - - r_result = `` && |\n| && - `` && |\n| && - `` && |\n| && - lv_sec_policy && |\n| && - ` ` && |\n| && - ` ` && |\n| && - ` ` && |\n| && - ` abap2UI5` && |\n| && - ` ` && - ` ` && |\n| && - `` && |\n| && - `
` && |\n| && - `` && |\n|. - - DATA(lv_add_js) = z2ui5_cl_fw_cc_factory=>get_js_startup( ) && custom_js. - - r_result = r_result && - `` && |\n| && - ``. - - z2ui5_cl_fw_db=>cleanup( ). + result = lo_index->get( ). ENDMETHOD. METHOD http_post. - TRY. - DATA(lo_handler) = z2ui5_cl_fw_controller=>request_begin( body ). - CATCH cx_root INTO DATA(x). - lo_handler = z2ui5_cl_fw_controller=>app_system_factory( x ). - ENDTRY. - - DO. - TRY. - - ROLLBACK WORK. - CAST z2ui5_if_app( lo_handler->ms_db-app )->main( NEW z2ui5_cl_fw_client( lo_handler ) ). - ROLLBACK WORK. - - IF lo_handler->ms_next-o_app_leave IS NOT INITIAL. - lo_handler = lo_handler->app_leave_factory( ). - CONTINUE. - ENDIF. - - IF lo_handler->ms_next-o_app_call IS NOT INITIAL. - lo_handler = lo_handler->app_call_factory( ). - CONTINUE. - ENDIF. - - result = lo_handler->request_end( ). - - CATCH cx_root INTO x. - lo_handler = z2ui5_cl_fw_controller=>app_system_factory( x ). - CONTINUE. - ENDTRY. - - EXIT. - ENDDO. + result = z2ui5_cl_fw_controller=>main( body ). ENDMETHOD. + ENDCLASS. diff --git a/src/01/01/z2ui5_cl_fw_index_html.clas.abap b/src/01/01/z2ui5_cl_fw_index_html.clas.abap new file mode 100644 index 00000000..efc12baf --- /dev/null +++ b/src/01/01/z2ui5_cl_fw_index_html.clas.abap @@ -0,0 +1,515 @@ +CLASS z2ui5_cl_fw_index_html DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + TYPES: + BEGIN OF ty_s_config, + t_config TYPE z2ui5_if_client=>ty_t_name_value, + content_security_policy TYPE string, + custom_js TYPE string, + json_model_limit TYPE string, + END OF ty_s_config. + DATA ms_config TYPE ty_s_config. + + CLASS-METHODS factory + IMPORTING + i_config TYPE ty_s_config + RETURNING + VALUE(result) TYPE REF TO z2ui5_cl_fw_index_html. + + METHODS get + RETURNING + VALUE(result) TYPE string. + + METHODS get_js + RETURNING + VALUE(result) TYPE string. + + PROTECTED SECTION. + PRIVATE SECTION. +ENDCLASS. + + + +CLASS z2ui5_cl_fw_index_html IMPLEMENTATION. + + METHOD factory. + + result = new #( ). + result->ms_config = i_config. + + ENDMETHOD. + + METHOD get. + + DATA(lt_config) = ms_config-t_config. + IF lt_config IS INITIAL. + lt_config = VALUE #( +* ( n = `src` v = `https://sdk.openui5.org/nightly/2/resources/sap-ui-core.js` ) + ( n = `src` v = `https://sdk.openui5.org/resources/sap-ui-cachebuster/sap-ui-core.js` ) +* ( n = `src` v = `https://ui5.sap.com/1.120.0/resources/sap-ui-core.js` ) + ( n = `data-sap-ui-theme` v = `sap_horizon` ) + ( n = `data-sap-ui-async` v = `true` ) + ( n = `data-sap-ui-bindingSyntax` v = `complex` ) + ( n = `data-sap-ui-frameOptions` v = `trusted` ) + ( n = `data-sap-ui-compatVersion` v = `edge` ) ). + ENDIF. + + IF ms_config-content_security_policy IS INITIAL. + DATA(lv_sec_policy) = ``. + ELSE. + lv_sec_policy = ms_config-content_security_policy. + ENDIF. + + result = `` && |\n| && + `` && |\n| && + `` && |\n| && + lv_sec_policy && |\n| && + ` ` && |\n| && + ` ` && |\n| && + ` ` && |\n| && + ` abap2UI5` && |\n| && + ` ` && + ` ` && |\n| && + `` && |\n| && + `
` && |\n| && + `` && |\n|. + + DATA(lv_add_js) = z2ui5_cl_fw_cc_factory=>get_js_startup( ) && ms_config-custom_js. + + result = result && + `` && |\n| && + ``. + + z2ui5_cl_fw_db=>cleanup( ). + + ENDMETHOD. + + METHOD get_js. + + result = `sap.ui.define("z2ui5/Controller", ["sap/ui/core/mvc/Controller", "sap/ui/core/mvc/XMLView", "sap/ui/model/json/JSONModel", "sap/ui/core/BusyIndicator", "sap/m/MessageBox", "sap/m/MessageToast", "sap/ui/core/Fragment"], function(Control` && + `ler, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment) {` && |\n| && + ` "use strict";` && |\n| && + ` return Controller.extend("z2ui5.Controller", {` && |\n| && + ` async onAfterRendering() {` && |\n| && + ` try{` && |\n| && + ` if (!sap.z2ui5.oResponse.PARAMS) {` && |\n| && + ` return;` && |\n| && + ` }` && |\n| && + ` const {S_POPUP, S_VIEW_NEST, S_VIEW_NEST2, S_POPOVER} = sap.z2ui5.oResponse.PARAMS;` && |\n| && + ` if (S_POPUP?.CHECK_DESTROY) {` && |\n| && + ` sap.z2ui5.oController.PopupDestroy();` && |\n| && + ` }` && |\n| && + ` if (S_POPOVER?.CHECK_DESTROY) {` && |\n| && + ` sap.z2ui5.oController.PopoverDestroy();` && |\n| && + ` }` && |\n| && + ` if (S_POPUP?.XML) {` && |\n| && + ` sap.z2ui5.oController.PopupDestroy();` && |\n| && + ` await this.displayFragment(S_POPUP.XML, 'oViewPopup');` && |\n| && + ` }` && |\n| && + ` if (!sap.z2ui5.checkNestAfter) {` && |\n| && + ` if (S_VIEW_NEST?.XML) {` && |\n| && + ` sap.z2ui5.oController.NestViewDestroy();` && |\n| && + ` await this.displayNestedView(S_VIEW_NEST.XML, 'oViewNest', 'S_VIEW_NEST');` && |\n| && + ` sap.z2ui5.checkNestAfter = true;` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` if (!sap.z2ui5.checkNestAfter2) {` && |\n| && + ` if (S_VIEW_NEST2?.XML) {` && |\n| && + ` sap.z2ui5.oController.NestViewDestroy2();` && |\n| && + ` await this.displayNestedView(S_VIEW_NEST2.XML, 'oViewNest2', 'S_VIEW_NEST2');` && |\n| && + ` sap.z2ui5.checkNestAfter2 = true;` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` if (S_POPOVER?.XML) {` && |\n| && + ` await this.displayFragment(S_POPOVER.XML, 'oViewPopover', S_POPOVER.OPEN_BY_ID);` && |\n| && + ` }` && |\n| && + ` BusyIndicator.hide();` && |\n| && + ` if (sap.z2ui5.isBusy) {` && |\n| && + ` sap.z2ui5.isBusy = false;` && |\n| && + ` }` && |\n| && + ` if (sap.z2ui5.busyDialog) {` && |\n| && + ` sap.z2ui5.busyDialog.close();` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.onAfterRendering.forEach(item=>{` && |\n| && + ` if (item !== undefined) {` && |\n| && + ` item();` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` )` && |\n| && + ` }catch(e){ BusyIndicator.hide(); MessageBox.error(e.toLocaleString()); }` && |\n| && + ` },` && |\n| && + |\n| && + ` async displayFragment(xml, viewProp, openById) {` && |\n| && + ` const oFragment = await Fragment.load({` && |\n| && + ` definition: xml,` && |\n| && + ` controller: sap.z2ui5.oController,` && |\n| && + ` });` && |\n| && + ` let oview_model = new JSONModel(sap.z2ui5.oResponse.OVIEWMODEL);` && |\n| && + ` oview_model.setSizeLimit(sap.z2ui5.JSON_MODEL_LIMIT);` && |\n| && + ` oFragment.setModel(oview_model);` && |\n| && + ` let oControl = openById ? this.getControlById(openById) : null;` && |\n| && + ` if (oControl) {` && |\n| && + ` oFragment.openBy(oControl);` && |\n| && + ` } else {` && |\n| && + ` oFragment.open();` && |\n| && + ` }` && |\n| && + ` sap.z2ui5[viewProp] = oFragment;` && |\n| && + ` },` && |\n| && + |\n| && + ` async displayNestedView(xml, viewProp, viewNestId) {` && |\n| && + ` const oView = await XMLView.create({` && |\n| && + ` definition: xml,` && |\n| && + ` controller: sap.z2ui5.oControllerNest,` && |\n| && + ` });` && |\n| && + |\n| && + ` let oview_model = new JSONModel(sap.z2ui5.oResponse.OVIEWMODEL);` && |\n| && + ` oview_model.setSizeLimit(sap.z2ui5.JSON_MODEL_LIMIT);` && |\n| && + ` oView.setModel(oview_model);` && |\n| && + |\n| && + ` let oParent = sap.z2ui5.oView.byId(sap.z2ui5.oResponse.PARAMS[viewNestId].ID);` && |\n| && + ` if (oParent) {` && |\n| && + ` try {` && |\n| && + ` oParent[sap.z2ui5.oResponse.PARAMS[viewNestId].METHOD_DESTROY]();` && |\n| && + ` } catch {}` && |\n| && + ` oParent[sap.z2ui5.oResponse.PARAMS[viewNestId].METHOD_INSERT](oView);` && |\n| && + ` }` && |\n| && + ` sap.z2ui5[viewProp] = oView;` && |\n| && + ` },` && |\n| && + |\n| && + ` getControlById(id) {` && |\n| && + ` let oControl = sap.z2ui5.oView.byId(id);` && |\n| && + ` if (!oControl) {` && |\n| && + ` oControl = sap.ui.getCore().byId(id);` && |\n| && + ` debugger ;` && |\n| && + ` }` && |\n| && + ` if (!oControl) {` && |\n| && + ` oControl = sap.z2ui5.oViewNest.byId(id) || sap.z2ui5.oViewNest2.byId(id);` && |\n| && + ` }` && |\n| && + ` return oControl;` && |\n| && + ` },` && |\n| && + |\n| && + ` PopupDestroy() {` && |\n| && + ` if (!sap.z2ui5.oViewPopup) {` && |\n| && + ` return;` && |\n| && + ` }` && |\n| && + ` if (sap.z2ui5.oViewPopup.close) {` && |\n| && + ` try {` && |\n| && + ` sap.z2ui5.oViewPopup.close();` && |\n| && + ` } catch {}` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.oViewPopup.destroy();` && |\n| && + ` },` && |\n| && + ` PopoverDestroy() {` && |\n| && + ` if (!sap.z2ui5.oViewPopover) {` && |\n| && + ` return;` && |\n| && + ` }` && |\n| && + ` if (sap.z2ui5.oViewPopover.close) {` && |\n| && + ` try {` && |\n| && + ` sap.z2ui5.oViewPopover.close();` && |\n| && + ` } catch {}` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.oViewPopover.destroy();` && |\n| && + ` },` && |\n| && + ` NestViewDestroy() {` && |\n| && + ` if (!sap.z2ui5.oViewNest) {` && |\n| && + ` return;` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.oViewNest.destroy();` && |\n| && + ` },` && |\n| && + ` NestViewDestroy2() {` && |\n| && + ` if (!sap.z2ui5.oViewNest2) {` && |\n| && + ` return;` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.oViewNest2.destroy();` && |\n| && + ` },` && |\n| && + ` ViewDestroy() {` && |\n| && + ` if (!sap.z2ui5.oView) {` && |\n| && + ` return;` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.oView.destroy();` && |\n| && + ` },` && |\n| && + ` onEventFrontend(...args) {` && |\n| && + |\n| && + ` sap.z2ui5.onBeforeEventFrontend.forEach(item => {` && |\n| && + ` if (item !== undefined) {` && |\n| && + ` item(args);` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` )` && |\n| && + |\n| && + ` let oCrossAppNavigator;` && |\n| && + ` switch (args[0].EVENT) {` && |\n| && + ` case 'CROSS_APP_NAV_TO_PREV_APP':` && |\n| && + ` oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");` && |\n| && + ` oCrossAppNavigator.backToPreviousApp();` && |\n| && + ` break;` && |\n| && + ` case 'CROSS_APP_NAV_TO_EXT':` && |\n| && + ` oCrossAppNavigator = sap.ushell.Container.getService("CrossApplicationNavigation");` && |\n| && + ` const hash = (oCrossAppNavigator.hrefForExternal({` && |\n| && + ` target: args[1],` && |\n| && + ` params: args[2]` && |\n| && + ` })) || "";` && |\n| && + ` if (args[3] === 'EXT') {` && |\n| && + ` let url = window.location.href.split('#')[0] + hash;` && |\n| && + ` sap.m.URLHelper.redirect(url, true);` && |\n| && + ` } else {` && |\n| && + ` oCrossAppNavigator.toExternal({` && |\n| && + ` target: {` && |\n| && + ` shellHash: hash` && |\n| && + ` }` && |\n| && + ` });` && |\n| && + ` }` && |\n| && + ` break;` && |\n| && + ` case 'LOCATION_RELOAD':` && |\n| && + ` window.location = args[1];` && |\n| && + ` break;` && |\n| && + ` case 'OPEN_NEW_TAB':` && |\n| && + ` window.open(args[1], '_blank');` && |\n| && + ` break;` && |\n| && + ` case 'POPUP_CLOSE':` && |\n| && + ` sap.z2ui5.oController.PopupDestroy();` && |\n| && + ` break;` && |\n| && + ` case 'POPOVER_CLOSE':` && |\n| && + ` sap.z2ui5.oController.PopoverDestroy();` && |\n| && + ` break;` && |\n| && + ` case 'NAV_CONTAINER_TO':` && |\n| && + ` var navCon = sap.z2ui5.oView.byId(args[1]);` && |\n| && + ` var navConTo = sap.z2ui5.oView.byId(args[2]);` && |\n| && + ` navCon.to(navConTo);` && |\n| && + ` break;` && |\n| && + ` case 'NEST_NAV_CONTAINER_TO':` && |\n| && + ` navCon = sap.z2ui5.oViewNest.byId(args[1]);` && |\n| && + ` navConTo = sap.z2ui5.oViewNest.byId(args[2]);` && |\n| && + ` navCon.to(navConTo);` && |\n| && + ` break;` && |\n| && + ` case 'NEST2_NAV_CONTAINER_TO':` && |\n| && + ` navCon = sap.z2ui5.oViewNest2.byId(args[1]);` && |\n| && + ` navConTo = sap.z2ui5.oViewNest2.byId(args[2]);` && |\n| && + ` navCon.to(navConTo);` && |\n| && + ` break;` && |\n| && + ` }` && |\n| && + ` },` && |\n| && + ` onEvent(...args) {` && |\n| && + ` if (sap.z2ui5.isBusy) {` && |\n| && + ` if (sap.z2ui5.isBusy == true) {` && |\n| && + ` sap.z2ui5.busyDialog = new sap.m.BusyDialog();` && |\n| && + ` sap.z2ui5.busyDialog.open();` && |\n| && + ` return;` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.isBusy = true;` && |\n| && + ` if (!window.navigator.onLine) {` && |\n| && + ` sap.m.MessageBox.alert('No internet connection! Please reconnect to the server and try again.');` && |\n| && + ` sap.z2ui5.isBusy = false;` && |\n| && + ` return;` && |\n| && + ` }` && |\n| && + ` BusyIndicator.show();` && |\n| && + ` sap.z2ui5.oBody = {};` && |\n| && + ` let isUpdated = false;` && |\n| && + ` if (sap.z2ui5.oViewPopup) {` && |\n| && +* ` if (sap.z2ui5.oViewPopup.isOpen ) { if( sap.z2ui5.oViewPopup.isOpen() == true ) {` && |\n| && +* ` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewPopup.getModel().getData().EDIT;` && |\n| && +* ` isUpdated = true;` && |\n| && +* ` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| && +* ` } }` && |\n| && + ` if (sap.z2ui5.oViewPopup.getVisible ) { if( sap.z2ui5.oViewPopup.getVisible() == true ) {` && |\n| && + ` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewPopup.getModel().getData().EDIT;` && |\n| && + ` isUpdated = true;` && |\n| && + ` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| && + ` } }` && |\n| && + ` }` && |\n| && + ` if (isUpdated == false) {` && |\n| && + ` if (sap.z2ui5.oViewPopover) {` && |\n| && + ` if (sap.z2ui5.oViewPopover.isOpen) {` && |\n| && + ` if (sap.z2ui5.oViewPopover.isOpen() == true) {` && |\n| && + ` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewPopover.getModel().getData().EDIT;` && |\n| && + ` isUpdated = true;` && |\n| && + ` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.oViewPopover.destroy();` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` if (isUpdated == false) {` && |\n| && + ` if (sap.z2ui5.oViewNest == this.getView()) {` && |\n| && + ` sap.z2ui5.oBody.EDIT = sap.z2ui5.oViewNest.getModel().getData().EDIT;` && |\n| && + ` sap.z2ui5.oBody.VIEWNAME = 'NEST';` && |\n| && + ` isUpdated = true;` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` if (isUpdated == false) {` && |\n| && + ` sap.z2ui5.oBody.EDIT = sap.z2ui5.oView.getModel().getData().EDIT;` && |\n| && + ` sap.z2ui5.oBody.VIEWNAME = 'MAIN';` && |\n| && + ` }` && |\n| && + |\n| && + ` sap.z2ui5.onBeforeRoundtrip.forEach(item=>{` && |\n| && + ` if (item !== undefined) {` && |\n| && + ` item();` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` )` && |\n| && + ` if (args[0].CHECK_VIEW_DESTROY) {` && |\n| && + ` sap.z2ui5.oController.ViewDestroy();` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.oBody.ID = sap.z2ui5.oResponse.ID;` && |\n| && + ` sap.z2ui5.oBody.ARGUMENTS = args;` && |\n| && + |\n| && + ` sap.z2ui5.oResponseOld = sap.z2ui5.oResponse;` && |\n| && + ` sap.z2ui5.oResponse = {};` && |\n| && + ` sap.z2ui5.oController.Roundtrip();` && |\n| && + ` },` && |\n| && + ` responseError(response) {` && |\n| && + ` document.write(response);` && |\n| && + ` },` && |\n| && + ` updateModelIfRequired(paramKey, oView) {` && |\n| && + ` if (sap.z2ui5.oResponse.PARAMS[paramKey]?.CHECK_UPDATE_MODEL) {` && |\n| && + ` let model = new JSONModel(sap.z2ui5.oResponse.OVIEWMODEL);` && |\n| && + ` model.setSizeLimit(sap.z2ui5.JSON_MODEL_LIMIT);` && |\n| && + ` oView.setModel(model);` && |\n| && + ` }` && |\n| && + ` },` && |\n| && + ` async responseSuccess(response) {` && |\n| && + ` try{` && |\n| && + ` sap.z2ui5.oResponse = response;` && |\n| && + |\n| && + ` if (sap.z2ui5.oResponse.PARAMS?.S_VIEW?.CHECK_DESTROY) {` && |\n| && + ` sap.z2ui5.oController.ViewDestroy();` && |\n| && + ` }` && |\n| && + |\n| && + ` sap.z2ui5.oController.showMessage('S_MSG_TOAST', sap.z2ui5.oResponse.PARAMS);` && |\n| && + ` sap.z2ui5.oController.showMessage('S_MSG_BOX', sap.z2ui5.oResponse.PARAMS);` && |\n| && + ` if (sap.z2ui5.oResponse.PARAMS?.S_VIEW?.XML) { if ( sap.z2ui5.oResponse.PARAMS?.S_VIEW?.XML !== '') {` && |\n| && + ` sap.z2ui5.oController.ViewDestroy();` && |\n| && + ` await sap.z2ui5.oController.createView(sap.z2ui5.oResponse.PARAMS.S_VIEW.XML, sap.z2ui5.oResponse.OVIEWMODEL);` && |\n| && + ` return; } } ` && |\n| && +* ` } else {` && |\n| && + ` this.updateModelIfRequired('S_VIEW', sap.z2ui5.oView);` && |\n| && + ` this.updateModelIfRequired('S_VIEW_NEST', sap.z2ui5.oViewNest);` && |\n| && + ` this.updateModelIfRequired('S_VIEW_NEST2', sap.z2ui5.oViewNest2);` && |\n| && + ` this.updateModelIfRequired('S_POPUP', sap.z2ui5.oViewPopup);` && |\n| && + ` this.updateModelIfRequired('S_POPOVER', sap.z2ui5.oViewPopover);` && |\n| && + ` sap.z2ui5.oController.onAfterRendering();` && |\n| && +* ` }` && |\n| && +` }catch(e){ BusyIndicator.hide(); MessageBox.error(e.toLocaleString()); }` && |\n| && + ` },` && |\n| && + ` showMessage(msgType, params) {` && |\n| && + ` if (params[msgType]?.TEXT !== undefined) {` && |\n| && + ` if (msgType === 'S_MSG_TOAST') {` && |\n| && + ` MessageToast.show(params[msgType].TEXT);` && |\n| && + ` } else if (msgType === 'S_MSG_BOX') {` && |\n| && + ` MessageBox[params[msgType].TYPE](params[msgType].TEXT);` && |\n| && + ` }` && |\n| && + ` }` && |\n| && + ` },` && |\n| && + ` async createView(xml, viewModel) {` && |\n| && + ` const oView = await XMLView.create({` && |\n| && + ` definition: xml,` && |\n| && + ` controller: sap.z2ui5.oController,` && |\n| && + ` });` && |\n| && + ` let oview_model = new JSONModel(viewModel);` && |\n| && + ` oview_model.setSizeLimit(sap.z2ui5.JSON_MODEL_LIMIT);` && |\n| && + ` oView.setModel(oview_model);` && |\n| && + |\n| && + ` if (sap.z2ui5.oParent) {` && |\n| && + ` sap.z2ui5.oParent.removeAllPages();` && |\n| && + ` sap.z2ui5.oParent.insertPage(oView);` && |\n| && + ` } else {` && |\n| && + ` oView.placeAt("content");` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.oView = oView;` && |\n| && + ` },` && |\n| && + ` async readHttp() {` && |\n| && + ` const response = await fetch(sap.z2ui5.pathname, {` && |\n| && + ` method: 'POST',` && |\n| && + ` headers: {` && |\n| && + ` 'Content-Type': 'application/json'` && |\n| && + ` },` && |\n| && + ` body: JSON.stringify(sap.z2ui5.oBody)` && |\n| && + ` });` && |\n| && + |\n| && + ` if (!response.ok) {` && |\n| && + ` const responseText = await response.text();` && |\n| && + ` sap.z2ui5.oController.responseError(responseText);` && |\n| && + ` } else {` && |\n| && + ` const responseData = await response.json();` && |\n| && + ` sap.z2ui5.oController.responseSuccess(responseData);` && |\n| && + ` }` && |\n| && + |\n| && + ` },` && |\n| && + |\n| && + ` Roundtrip() {` && |\n| && + |\n| && + ` sap.z2ui5.checkTimerActive = false;` && |\n| && + ` sap.z2ui5.checkNestAfter = false;` && |\n| && + ` sap.z2ui5.checkNestAfter2 = false;` && |\n| && + |\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) {` && |\n| && + ` sap.z2ui5.oBody.OLOCATION.SEARCH = sap.z2ui5.search;` && |\n| && + ` }` && |\n| && + ` sap.z2ui5.oController.readHttp();` && |\n| && + ` },` && |\n| && + ` })` && |\n| && + `});` && |\n| && + |\n| && + `sap.ui.require(["z2ui5/Controller", "sap/ui/core/BusyIndicator", "sap/ui/core/mvc/XMLView", "sap/ui/core/Fragment", "sap/m/MessageToast", "sap/m/MessageBox", "sap/ui/model/json/JSONModel"], (Controller,BusyIndicator)=>{` && |\n| && + |\n| && + ` BusyIndicator.show();` && |\n| && + ` sap.z2ui5.oController = new Controller();` && |\n| && + ` sap.z2ui5.oControllerNest = new Controller();` && |\n| && + ` sap.z2ui5.oControllerNest2 = new Controller();` && |\n| && + |\n| && + ` sap.z2ui5.pathname = sap.z2ui5.pathname || window.location.pathname;` && |\n| && + ` sap.z2ui5.checkNestAfter = false;` && |\n| && + |\n| && + ` sap.z2ui5.oBody = {` && |\n| && + ` APP_START: sap.z2ui5.APP_START` && |\n| && + ` };` && |\n| && + ` sap.z2ui5.oController.Roundtrip();` && |\n| && + |\n| && + ` sap.z2ui5.onBeforeRoundtrip = [];` && |\n| && + ` sap.z2ui5.onAfterRendering = [];` && |\n| && + ` sap.z2ui5.onBeforeEventFrontend = [];` && |\n| && + ` sap.z2ui5.onAfterRoundtrip = []; }` && |\n| && + `);`. + + ENDMETHOD. + +ENDCLASS. diff --git a/src/01/01/z2ui5_cl_fw_index_html.clas.xml b/src/01/01/z2ui5_cl_fw_index_html.clas.xml new file mode 100644 index 00000000..1dd8c8cc --- /dev/null +++ b/src/01/01/z2ui5_cl_fw_index_html.clas.xml @@ -0,0 +1,16 @@ + + + + + + Z2UI5_CL_FW_INDEX_HTML + E + abap2UI5 - index.html + 1 + X + X + X + + + + diff --git a/src/01/01/z2ui5_cl_fw_model.clas.abap b/src/01/01/z2ui5_cl_fw_model.clas.abap index 42855898..cf357465 100644 --- a/src/01/01/z2ui5_cl_fw_model.clas.abap +++ b/src/01/01/z2ui5_cl_fw_model.clas.abap @@ -143,7 +143,7 @@ CLASS z2ui5_cl_fw_model IMPLEMENTATION. WHEN `h`. lo_actual->add_attribute( n = lr_attri->name_front - v = z2ui5_cl_util_func=>trans_json_any_2( any = pretty_name = lr_attri->pretty_name compress = lr_attri->compress ) + v = z2ui5_cl_util_func=>trans_json_by_any( any = pretty_name = lr_attri->pretty_name compress = lr_attri->compress ) apos_active = abap_false ). WHEN OTHERS. @@ -157,7 +157,7 @@ CLASS z2ui5_cl_fw_model IMPLEMENTATION. ELSE. lo_actual->add_attribute( n = lr_attri->name_front - v = z2ui5_cl_util_func=>trans_json_any_2( any = pretty_name = lr_attri->pretty_name compress = lr_attri->compress ) + v = z2ui5_cl_util_func=>trans_json_by_any( any = pretty_name = lr_attri->pretty_name compress = lr_attri->compress ) apos_active = abap_false ). ENDIF. diff --git a/src/03/01/z2ui5_cl_popup_get_range.clas.abap b/src/03/01/z2ui5_cl_popup_get_range.clas.abap index 20537d7f..766dca6e 100644 --- a/src/03/01/z2ui5_cl_popup_get_range.clas.abap +++ b/src/03/01/z2ui5_cl_popup_get_range.clas.abap @@ -84,7 +84,7 @@ CLASS z2ui5_cl_popup_get_range IMPLEMENTATION. grid->combobox( selectedkey = `{OPTION}` - items = client->_bind_local( z2ui5_cl_util_func=>get_token_range_mapping( ) ) + items = client->_bind_local( z2ui5_cl_util_func=>filter_get_token_range_mapping( ) ) )->item( key = '{N}' text = '{N}' @@ -125,7 +125,7 @@ CLASS z2ui5_cl_popup_get_range IMPLEMENTATION. low = lr_product->low high = lr_product->high option = lr_product->option - key = z2ui5_cl_util_func=>func_get_uuid_32( ) + key = z2ui5_cl_util_func=>uuid_get_c32( ) ) INTO TABLE mt_filter. ENDLOOP. @@ -158,7 +158,7 @@ CLASS z2ui5_cl_popup_get_range IMPLEMENTATION. client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ). WHEN `POPUP_ADD`. - INSERT VALUE #( key = z2ui5_cl_util_func=>func_get_uuid_32( ) ) INTO TABLE mt_filter. + INSERT VALUE #( key = z2ui5_cl_util_func=>uuid_get_c32( ) ) INTO TABLE mt_filter. client->popup_model_update( ). WHEN `POPUP_DELETE`. diff --git a/src/03/01/z2ui5_cl_popup_get_range_multi.clas.abap b/src/03/01/z2ui5_cl_popup_get_range_multi.clas.abap index 759e2129..147a10ec 100644 --- a/src/03/01/z2ui5_cl_popup_get_range_multi.clas.abap +++ b/src/03/01/z2ui5_cl_popup_get_range_multi.clas.abap @@ -7,13 +7,13 @@ CLASS z2ui5_cl_popup_get_range_multi DEFINITION CLASS-METHODS factory IMPORTING - val TYPE z2ui5_cl_util_func=>ty_t_sql_multi + val TYPE z2ui5_cl_util_func=>ty_t_filter_multi RETURNING VALUE(r_result) TYPE REF TO z2ui5_cl_popup_get_range_multi. TYPES: BEGIN OF ty_s_result, - t_sql TYPE z2ui5_cl_util_func=>ty_t_sql_multi, + t_sql TYPE z2ui5_cl_util_func=>ty_t_filter_multi, check_confirmed TYPE abap_bool, END OF ty_s_result. @@ -107,7 +107,7 @@ CLASS z2ui5_cl_popup_get_range_multi IMPLEMENTATION. IF lo_popup->result( )-check_confirmed = abap_true. ASSIGN ms_result-t_sql[ name = mv_popup_name ] TO FIELD-SYMBOL(). -t_range = lo_popup->result( )-t_range. - -t_token = z2ui5_cl_util_func=>get_token_t_by_range_t( -t_range ). + -t_token = z2ui5_cl_util_func=>filter_get_token_t_by_range_t( -t_range ). ENDIF. popup_display( ).