refactoring and cleanup (#812)

* refactoring and cleanup

* lint fixes
This commit is contained in:
oblomov 2024-01-25 10:03:17 +01:00 committed by GitHub
parent fbd89e6178
commit 31a376b4fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 768 additions and 646 deletions

View File

@ -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 <tab> TYPE STANDARD TABLE.
ASSIGN result->* TO <tab>.
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(<row>).
ASSIGN COMPONENT sy-tabix OF STRUCTURE <row> TO FIELD-SYMBOL(<field>).
<field> = lr_col->*.
ENDLOOP.
INSERT <row> INTO TABLE <tab>.
ENDLOOP.
ENDMETHOD.
METHOD itab_get_csv_by_itab.
FIELD-SYMBOLS <tab> TYPE table.
ASSIGN val TO <tab>.
DATA lr_row TYPE REF TO data.
DATA(tab) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_data( <tab> ) ).
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 <tab> REFERENCE INTO lr_row.
DATA(lv_index) = 1.
DO.
ASSIGN lr_row->* TO FIELD-SYMBOL(<row>).
ASSIGN COMPONENT lv_index OF STRUCTURE <row> TO FIELD-SYMBOL(<field>).
IF sy-subrc <> 0.
EXIT.
ENDIF.
lv_index = lv_index + 1.
result = result && <field> && ';'.
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 <from> TYPE data.
FIELD-SYMBOLS <result> 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(<row>).
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 <any> 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

View File

@ -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

View File

@ -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.

View File

@ -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 <any> TYPE any.
ASSIGN mr_data->* TO <any>.
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 }|.

View File

@ -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.

View File

@ -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 <struc> 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 <struc>.
@ -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`

View File

@ -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.

View File

@ -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( <deref_attri> ).
lr_attri->data_rtti = z2ui5_cl_util_func=>trans_srtti_xml_by_data( <deref_attri> ).
CLEAR <deref_attri>.
CLEAR <attri>.
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.

View File

@ -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) = `<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' data: ` &&
`ui5.sap.com *.ui5.sap.com sapui5.hana.ondemand.com *.sapui5.hana.ondemand.com sdk.openui5.org *.sdk.openui5.org cdn.jsdelivr.net *.cdn.jsdelivr.net cdnjs.cloudflare.com *.cdnjs.cloudflare.com"/>`.
ELSE.
lv_sec_policy = content_security_policy.
ENDIF.
r_result = `<!DOCTYPE html>` && |\n| &&
`<html lang="en">` && |\n| &&
`<head>` && |\n| &&
lv_sec_policy && |\n| &&
` <meta charset="UTF-8">` && |\n| &&
` <meta name="viewport" content="width=device-width, initial-scale=1.0">` && |\n| &&
` <meta http-equiv="X-UA-Compatible" content="IE=edge">` && |\n| &&
` <title>abap2UI5</title>` && |\n| &&
` <style>` && |\n| &&
` html, body, body > div, #container, #container-uiarea {` && |\n| &&
` height: 100%;` && |\n| &&
` }` && |\n| &&
` .dbg-ltr {` && |\n| &&
` direction: ltr !important;` && |\n| &&
` }` && |\n| &&
` </style> ` &&
` <script id="sap-ui-bootstrap"`.
LOOP AT lt_config REFERENCE INTO DATA(lr_config).
r_result = r_result && | { lr_config->n }="{ lr_config->v }"|.
ENDLOOP.
r_result = r_result &&
` ></script></head>` && |\n| &&
`<body class="sapUiBody sapUiSizeCompact" >` && |\n| &&
` <div id="content" data-handle-validation="true" ></div>` && |\n| &&
`<abc/>` && |\n|.
DATA(lv_add_js) = z2ui5_cl_fw_cc_factory=>get_js_startup( ) && custom_js.
r_result = r_result &&
`<script> sap.z2ui5 = sap.z2ui5 || {};` && |\n| &&
get_js( ) && |\n| &&
lv_add_js && |\n| &&
` sap.z2ui5.JSON_MODEL_LIMIT = ` && json_model_limit && `;`.
r_result = r_result &&
z2ui5_cl_fw_cc_debugging_tools=>get_js( ) &&
` sap.ui.require(["z2ui5/DebuggingTools","z2ui5/Controller"], (DebuggingTools) => { sap.z2ui5.DebuggingTools = new DebuggingTools(); ` && |\n| &&
` });`.
r_result = r_result && |\n| &&
`</script>` && |\n| &&
`<abc/></body></html>`.
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.

View File

@ -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) = `<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' data: ` &&
`ui5.sap.com *.ui5.sap.com sapui5.hana.ondemand.com *.sapui5.hana.ondemand.com sdk.openui5.org *.sdk.openui5.org cdn.jsdelivr.net *.cdn.jsdelivr.net cdnjs.cloudflare.com *.cdnjs.cloudflare.com"/>`.
ELSE.
lv_sec_policy = ms_config-content_security_policy.
ENDIF.
result = `<!DOCTYPE html>` && |\n| &&
`<html lang="en">` && |\n| &&
`<head>` && |\n| &&
lv_sec_policy && |\n| &&
` <meta charset="UTF-8">` && |\n| &&
` <meta name="viewport" content="width=device-width, initial-scale=1.0">` && |\n| &&
` <meta http-equiv="X-UA-Compatible" content="IE=edge">` && |\n| &&
` <title>abap2UI5</title>` && |\n| &&
` <style>` && |\n| &&
` html, body, body > div, #container, #container-uiarea {` && |\n| &&
` height: 100%;` && |\n| &&
` }` && |\n| &&
` .dbg-ltr {` && |\n| &&
` direction: ltr !important;` && |\n| &&
` }` && |\n| &&
` </style> ` &&
` <script id="sap-ui-bootstrap"`.
LOOP AT lt_config REFERENCE INTO DATA(lr_config).
result = result && | { lr_config->n }="{ lr_config->v }"|.
ENDLOOP.
result = result &&
` ></script></head>` && |\n| &&
`<body class="sapUiBody sapUiSizeCompact" >` && |\n| &&
` <div id="content" data-handle-validation="true" ></div>` && |\n| &&
`<abc/>` && |\n|.
DATA(lv_add_js) = z2ui5_cl_fw_cc_factory=>get_js_startup( ) && ms_config-custom_js.
result = result &&
`<script> sap.z2ui5 = sap.z2ui5 || {};` && |\n| &&
get_js( ) && |\n| &&
lv_add_js && |\n| &&
` sap.z2ui5.JSON_MODEL_LIMIT = ` && ms_config-json_model_limit && `;`.
result = result &&
z2ui5_cl_fw_cc_debugging_tools=>get_js( ) &&
` sap.ui.require(["z2ui5/DebuggingTools","z2ui5/Controller"], (DebuggingTools) => { sap.z2ui5.DebuggingTools = new DebuggingTools(); ` && |\n| &&
` });`.
result = result && |\n| &&
`</script>` && |\n| &&
`<abc/></body></html>`.
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.

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>Z2UI5_CL_FW_INDEX_HTML</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>abap2UI5 - index.html</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

View File

@ -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 = <attribute> pretty_name = lr_attri->pretty_name compress = lr_attri->compress )
v = z2ui5_cl_util_func=>trans_json_by_any( any = <attribute> 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 = <attribute> pretty_name = lr_attri->pretty_name compress = lr_attri->compress )
v = z2ui5_cl_util_func=>trans_json_by_any( any = <attribute> pretty_name = lr_attri->pretty_name compress = lr_attri->compress )
apos_active = abap_false ).
ENDIF.

View File

@ -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`.

View File

@ -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(<tab>).
<tab>-t_range = lo_popup->result( )-t_range.
<tab>-t_token = z2ui5_cl_util_func=>get_token_t_by_range_t( <tab>-t_range ).
<tab>-t_token = z2ui5_cl_util_func=>filter_get_token_t_by_range_t( <tab>-t_range ).
ENDIF.
popup_display( ).