From d5f94eab7df175f1845a79e29d37dc2c31715c8b Mon Sep 17 00:00:00 2001 From: oblomov <102328295+oblomov-dev@users.noreply.github.com> Date: Fri, 1 Dec 2023 16:26:47 +0100 Subject: [PATCH] Popups (#699) * popups * abaplint fixes * popups * abaplint fixes --- src/00/z2ui5_cl_util_func.clas.abap | 4 +- src/01/01/z2ui5_cl_fw_binding.clas.abap | 33 +++++- src/02/02/z2ui5_cl_cc_bwipjs.clas.abap | 2 +- src/04/z2ui5_cl_ui_pop_messages.clas.abap | 109 ++++++++++++++++++++ src/04/z2ui5_cl_ui_pop_messages.clas.xml | 16 +++ src/04/z2ui5_cl_ui_pop_to_confirm.clas.abap | 2 + src/99/z2ui5_cl_test_features.clas.abap | 107 +++++++++++++++++++ src/99/z2ui5_cl_test_features.clas.xml | 16 +++ 8 files changed, 285 insertions(+), 4 deletions(-) create mode 100644 src/04/z2ui5_cl_ui_pop_messages.clas.abap create mode 100644 src/04/z2ui5_cl_ui_pop_messages.clas.xml create mode 100644 src/99/z2ui5_cl_test_features.clas.abap create mode 100644 src/99/z2ui5_cl_test_features.clas.xml diff --git a/src/00/z2ui5_cl_util_func.clas.abap b/src/00/z2ui5_cl_util_func.clas.abap index 3073d883..84423f16 100644 --- a/src/00/z2ui5_cl_util_func.clas.abap +++ b/src/00/z2ui5_cl_util_func.clas.abap @@ -161,10 +161,10 @@ CLASS z2ui5_cl_util_func DEFINITION IMPORTING !val TYPE any RETURNING - VALUE(result) TYPE string . + VALUE(result) TYPE string. + PROTECTED SECTION. PRIVATE SECTION. - ENDCLASS. diff --git a/src/01/01/z2ui5_cl_fw_binding.clas.abap b/src/01/01/z2ui5_cl_fw_binding.clas.abap index 2e8a1581..950b05e1 100644 --- a/src/01/01/z2ui5_cl_fw_binding.clas.abap +++ b/src/01/01/z2ui5_cl_fw_binding.clas.abap @@ -81,6 +81,13 @@ CLASS z2ui5_cl_fw_binding DEFINITION RETURNING VALUE(result) TYPE ty_t_attri. + METHODS get_t_attri_by_include + IMPORTING + type TYPE REF TO cl_abap_datadescr + attri TYPE clike + RETURNING + VALUE(result) TYPE ty_t_attri. + METHODS get_t_attri_by_oref IMPORTING val TYPE clike OPTIONAL @@ -314,6 +321,24 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION. ENDMETHOD. + METHOD get_t_attri_by_include. + + data(sdescr) = cast cl_abap_structdescr( cl_abap_typedescr=>describe_by_name( type->absolute_name ) ). + + LOOP AT sdescr->components REFERENCE INTO DATA(lr_comp). + + DATA(lv_element) = attri && lr_comp->name. + + DATA(ls_attri) = VALUE ty_s_attri( + name = lv_element + type_kind = lr_comp->type_kind ). + INSERT ls_attri INTO TABLE result. + + ENDLOOP. + + + ENDMETHOD. + METHOD get_t_attri_by_struc. DATA(lv_name) = `MO_APP->` && val. @@ -322,6 +347,7 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION. z2ui5_cl_util_func=>x_check_raise( xsdbool( sy-subrc <> 0 ) ). DATA(lt_comp) = z2ui5_cl_util_func=>rtti_get_t_comp_by_struc( ). + DATA(lv_attri) = z2ui5_cl_util_func=>c_replace_assign_struc( val ). LOOP AT lt_comp REFERENCE INTO DATA(lr_comp). @@ -331,7 +357,12 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION. OR lr_comp->type->type_kind = cl_abap_classdescr=>typekind_struct2 OR lr_comp->type->type_kind = cl_abap_classdescr=>typekind_struct1. - DATA(lt_attri) = get_t_attri_by_struc( lv_element ). + IF lr_comp->name IS INITIAL. + DATA(lt_attri) = me->get_t_attri_by_include( type = lr_comp->type attri = lv_attri ). + ELSE. + lt_attri = get_t_attri_by_struc( lv_element ). + ENDIF. + INSERT LINES OF lt_attri INTO TABLE result. ELSE. diff --git a/src/02/02/z2ui5_cl_cc_bwipjs.clas.abap b/src/02/02/z2ui5_cl_cc_bwipjs.clas.abap index 04ee0bd4..d2a27b9a 100644 --- a/src/02/02/z2ui5_cl_cc_bwipjs.clas.abap +++ b/src/02/02/z2ui5_cl_cc_bwipjs.clas.abap @@ -95,7 +95,7 @@ CLASS Z2UI5_CL_CC_BWIPJS IMPLEMENTATION. ` });` && |\n| && ` },` && |\n| && ` renderer: function (oRm, oControl) {` && |\n| && -` debugger; oRm.write( "<canvas id='mycanvas' />");` && |\n| && |\n| && + ` oRm.write( "<canvas id='mycanvas' />");` && |\n| && |\n| && ` // The return value is the canvas element` && |\n| && ` }` && |\n| && ` });` && |\n| && diff --git a/src/04/z2ui5_cl_ui_pop_messages.clas.abap b/src/04/z2ui5_cl_ui_pop_messages.clas.abap new file mode 100644 index 00000000..e03eb4ae --- /dev/null +++ b/src/04/z2ui5_cl_ui_pop_messages.clas.abap @@ -0,0 +1,109 @@ +CLASS z2ui5_cl_ui_pop_messages DEFINITION + PUBLIC + FINAL + CREATE PUBLIC . + + PUBLIC SECTION. + + INTERFACES z2ui5_if_app. + + TYPES: + BEGIN OF ty_s_msg, + type TYPE string, + id TYPE string, + number TYPE string, + message TYPE string, + log_no TYPE string, + log_msg_no TYPE string, + message_v1 TYPE string, + message_v2 TYPE string, + message_v3 TYPE string, + message_v4 TYPE string, + parameter TYPE string, + row TYPE string, + field TYPE string, + system TYPE string, + END OF ty_s_msg. + TYPES ty_t_msg TYPE STANDARD TABLE OF ty_s_msg. + + DATA mt_msg TYPE ty_t_msg. + + CLASS-METHODS factory + IMPORTING + i_messages TYPE ty_t_msg + i_title TYPE string DEFAULT `abap2UI5 - Message Popup` + RETURNING + VALUE(r_result) TYPE REF TO z2ui5_cl_ui_pop_messages. + + PROTECTED SECTION. + DATA client TYPE REF TO z2ui5_if_client. + DATA title TYPE string. + DATA check_initialized TYPE abap_bool. + + METHODS view_display. + PRIVATE SECTION. +ENDCLASS. + + + +CLASS z2ui5_cl_ui_pop_messages IMPLEMENTATION. + + + METHOD factory. + + r_result = NEW #( ). + r_result->mt_msg = i_messages. + r_result->title = i_title. + + ENDMETHOD. + + + METHOD view_display. + + DATA(popup) = z2ui5_cl_xml_view=>factory_popup( client )->dialog( title + )->table( + mode = 'SingleSelectLeft' + items = client->_bind_edit( mt_msg ) + )->columns( + )->column( )->text( 'Title' )->get_parent( + )->column( )->text( 'Color' )->get_parent( + )->column( )->text( 'Info' )->get_parent( + )->column( )->text( 'Description' )->get_parent( + )->get_parent( + )->items( )->column_list_item( selected = '{SELKZ}' + )->cells( + )->text( '{TYPE}' + )->text( '{ID}' + )->text( '{NUMBER}' + )->text( '{MESSAGE}' + )->get_parent( )->get_parent( )->get_parent( )->get_parent( + )->footer( )->overflow_toolbar( + )->toolbar_spacer( + )->button( + text = 'continue' + press = client->_event( 'BUTTON_CONTINUE' ) + type = 'Emphasized' ). + + client->popup_display( popup->stringify( ) ). + + ENDMETHOD. + + + METHOD z2ui5_if_app~main. + + me->client = client. + + IF check_initialized = abap_false. + check_initialized = abap_true. + view_display( ). + RETURN. + ENDIF. + + CASE client->get( )-event. + WHEN `BUTTON_CONTINUE`. + client->popup_destroy( ). + client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ). + ENDCASE. + + ENDMETHOD. +ENDCLASS. diff --git a/src/04/z2ui5_cl_ui_pop_messages.clas.xml b/src/04/z2ui5_cl_ui_pop_messages.clas.xml new file mode 100644 index 00000000..e30787fb --- /dev/null +++ b/src/04/z2ui5_cl_ui_pop_messages.clas.xml @@ -0,0 +1,16 @@ + + + + + + Z2UI5_CL_UI_POP_MESSAGES + E + ui - popup messages + 1 + X + X + X + + + + diff --git a/src/04/z2ui5_cl_ui_pop_to_confirm.clas.abap b/src/04/z2ui5_cl_ui_pop_to_confirm.clas.abap index 410e0f77..094818fc 100644 --- a/src/04/z2ui5_cl_ui_pop_to_confirm.clas.abap +++ b/src/04/z2ui5_cl_ui_pop_to_confirm.clas.abap @@ -96,9 +96,11 @@ CLASS Z2UI5_CL_UI_POP_TO_CONFIRM IMPLEMENTATION. CASE client->get( )-event. WHEN `BUTTON_CONFIRM`. check_result_confirmed = abap_true. + client->popup_destroy( ). client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ). WHEN `BUTTON_CANCEL`. check_result_confirmed = abap_false. + client->popup_destroy( ). client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ). ENDCASE. diff --git a/src/99/z2ui5_cl_test_features.clas.abap b/src/99/z2ui5_cl_test_features.clas.abap new file mode 100644 index 00000000..bbc715ab --- /dev/null +++ b/src/99/z2ui5_cl_test_features.clas.abap @@ -0,0 +1,107 @@ +CLASS z2ui5_cl_test_features DEFINITION PUBLIC. + + PUBLIC SECTION. + + INTERFACES z2ui5_if_app. + + DATA mv_input TYPE string. + DATA mv_input2 TYPE string. + DATA mv_check_popup_active TYPE abap_bool. + DATA mv_check_initialized TYPE abap_bool. + PROTECTED SECTION. + + METHODS display_view + IMPORTING + client TYPE REF TO z2ui5_if_client. + + PRIVATE SECTION. +ENDCLASS. + + + +CLASS Z2UI5_CL_TEST_FEATURES IMPLEMENTATION. + + + METHOD display_view. + + DATA(view) = z2ui5_cl_xml_view=>factory( ). + view->shell( + )->page( title = 'abap2UI5 - flow logic - APP 01' navbuttonpress = client->_event( val = 'BACK' check_view_destroy = abap_true ) shownavbutton = abap_true + )->grid( 'L6 M12 S12' )->content( 'layout' + )->simple_form( 'Controller' )->content( 'form' + )->label( 'Test' + )->button( text = 'z2ui5_cl_ui_pop_to_confirm' press = client->_event( 'z2ui5_cl_ui_pop_to_confirm' ) + )->label( 'Test' + )->button( text = 'z2ui5_cl_ui_pop_messages' press = client->_event( 'z2ui5_cl_ui_pop_messages' ) + )->label( 'Demo' + )->button( text = 'z2ui5_cl_ui_pop_to_select' press = client->_event( 'z2ui5_cl_ui_pop_to_select' ) + )->label( 'Demo' + )->input( client->_bind_edit( mv_input ) + )->button( text = 'call new app (set data)' press = client->_event( 'CALL_NEW_APP_READ' ) + )->label( 'some data, you can read it in the next app' + )->input( client->_bind_edit( mv_input2 ) + ). + + client->view_display( view->stringify( ) ). + + ENDMETHOD. + + + METHOD z2ui5_if_app~main. + + if mv_check_initialized = abap_false. + mv_check_initialized = abap_true. + display_view( client ). + endif. +* IF client->get( )-check_on_navigated = abap_true. +* display_view( client ). +* ENDIF. + + IF mv_check_popup_active = abap_true. + + DATA(lo_prev) = client->get_app( client->get( )-s_draft-id_prev_app ). + + TRY. + DATA(lo_popup_decide) = CAST z2ui5_cl_ui_pop_to_confirm( lo_prev ). + client->message_box_display( `the result is ` && lo_popup_decide->check_result( ) ). + CATCH cx_root. + ENDTRY. + + ENDIF. + + mv_check_popup_active = abap_false. + + CASE client->get( )-event. + + WHEN 'z2ui5_cl_ui_pop_messages'. + data(lo_popup_msg) = z2ui5_cl_ui_pop_messages=>factory( + i_messages = VALUE #( + ( message = 'An empty Report field causes an empty XML Message to be sent' type = 'E' id = 'MSG1' number = '001' ) + ( message = 'Check was executed for wrong Scenario' type = 'E' id = 'MSG1' number = '002' ) + ( message = 'Request was handled without errors' type = 'S' id = 'MSG1' number = '003' ) + ( message = 'product activated' type = 'S' id = 'MSG4' number = '375' ) + ( message = 'check the input values' type = 'W' id = 'MSG2' number = '375' ) + ( message = 'product already in use' type = 'I' id = 'MSG2' number = '375' ) + ) + ). + + client->nav_app_call( lo_popup_msg ). + + WHEN 'z2ui5_cl_ui_pop_to_confirm'. + DATA(lo_app) = z2ui5_cl_ui_pop_to_confirm=>factory( + i_question_text = `this is a question` + ). + mv_check_popup_active = abap_true. + client->nav_app_call( lo_app ). + + WHEN 'BACK'. + DATA(lo_prev_stack_app) = client->get_app( client->get( )-s_draft-id_prev_app_stack ). + client->nav_app_leave( lo_prev_stack_app ). + + WHEN OTHERS. + + + ENDCASE. + + ENDMETHOD. +ENDCLASS. diff --git a/src/99/z2ui5_cl_test_features.clas.xml b/src/99/z2ui5_cl_test_features.clas.xml new file mode 100644 index 00000000..05b752c7 --- /dev/null +++ b/src/99/z2ui5_cl_test_features.clas.xml @@ -0,0 +1,16 @@ + + + + + + Z2UI5_CL_TEST_FEATURES + E + abap2UI5 - test more features + 1 + X + X + X + + + +