Popups & binding bugfixes (#786)

* popups

* bugfix binding
This commit is contained in:
oblomov 2024-01-17 10:31:12 +01:00 committed by GitHub
parent 2476813062
commit d9e18997eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 116 additions and 75 deletions

View File

@ -119,12 +119,14 @@ CLASS z2ui5_cl_util_func DEFINITION
CLASS-METHODS trans_ref_tab_2_tab
IMPORTING
!ir_tab_from TYPE REF TO data
pretty_name TYPE abap_bool DEFAULT abap_false
EXPORTING
!t_result TYPE STANDARD TABLE.
CLASS-METHODS trans_ref_struc_2_struc
IMPORTING
!ir_struc_from TYPE REF TO data
pretty_name TYPE abap_bool DEFAULT abap_false
EXPORTING
!r_result TYPE data.
@ -541,7 +543,68 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION.
METHOD trans_json_any_2.
result = /ui2/cl_json=>serialize( data = any pretty_name = CONV #( pretty_name ) compress = compress ).
result = /ui2/cl_json=>serialize(
data = any
pretty_name = CONV #( pretty_name )
compress = compress ).
ENDMETHOD.
METHOD trans_ref_struc_2_struc.
FIELD-SYMBOLS <ls_from> TYPE any.
ASSIGN ir_struc_from->* TO <ls_from>.
x_check_raise( xsdbool( sy-subrc <> 0 ) ).
CLEAR r_result.
DATA(lo_struc) = CAST cl_abap_structdescr( cl_abap_datadescr=>describe_by_data( r_result ) ).
DATA(lt_components) = lo_struc->get_components( ).
LOOP AT lt_components INTO DATA(ls_comp).
DATA(lv_from) = ls_comp-name.
IF pretty_name = abap_true.
REPLACE ALL OCCURRENCES OF `_` IN lv_from WITH ``.
ENDIF.
ASSIGN COMPONENT lv_from OF STRUCTURE <ls_from> TO FIELD-SYMBOL(<comp_from>).
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
ASSIGN COMPONENT ls_comp-name OF STRUCTURE r_result TO FIELD-SYMBOL(<comp_to>).
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
FIELD-SYMBOLS <comp_from_deref> TYPE any.
ASSIGN <comp_from>->* TO <comp_from_deref>.
DATA(lv_type_kind) = rtti_get_type_kind( <comp_to> ).
IF <comp_from_deref> IS INITIAL.
CONTINUE.
ENDIF.
CASE lv_type_kind.
WHEN cl_abap_typedescr=>typekind_table.
trans_ref_tab_2_tab(
EXPORTING
ir_tab_from = <comp_from>
pretty_name = pretty_name
IMPORTING
t_result = <comp_to> ).
WHEN cl_abap_typedescr=>typekind_struct1 OR cl_abap_typedescr=>typekind_struct2.
trans_ref_struc_2_struc(
EXPORTING
ir_struc_from = <comp_from>
IMPORTING
r_result = <comp_to> ).
WHEN OTHERS.
<comp_to> = <comp_from_deref>.
ENDCASE.
ENDLOOP.
ENDMETHOD.
@ -604,6 +667,9 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION.
ENDIF.
FIELD-SYMBOLS <comp_ui5> TYPE data.
IF pretty_name = abap_true.
REPLACE ALL OCCURRENCES OF `_` IN ls_comp-name WITH ``.
ENDIF.
ASSIGN COMPONENT ls_comp-name OF STRUCTURE <row_ui5> TO <comp_ui5>.
IF sy-subrc <> 0.
@ -615,8 +681,12 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION.
IF sy-subrc = 0.
CASE ls_comp-type->kind.
WHEN cl_abap_typedescr=>kind_table.
trans_ref_tab_2_tab( EXPORTING ir_tab_from = <comp_ui5>
IMPORTING t_result = <comp> ).
trans_ref_tab_2_tab(
EXPORTING
ir_tab_from = <comp_ui5>
pretty_name = pretty_name
IMPORTING
t_result = <comp> ).
WHEN OTHERS.
<comp> = <ls_data_ui5>.
ENDCASE.
@ -629,66 +699,9 @@ CLASS z2ui5_cl_util_func IMPLEMENTATION.
INSERT <row> INTO TABLE t_result.
ENDLOOP.
ENDMETHOD.
METHOD trans_ref_struc_2_struc.
FIELD-SYMBOLS <ls_from> TYPE any.
ASSIGN ir_struc_from->* TO <ls_from>.
x_check_raise( xsdbool( sy-subrc <> 0 ) ).
CLEAR r_result.
DATA(lo_struc) = CAST cl_abap_structdescr( cl_abap_datadescr=>describe_by_data( r_result ) ).
DATA(lt_components) = lo_struc->get_components( ).
LOOP AT lt_components INTO DATA(ls_comp).
DATA(lv_from) = ls_comp-name.
* REPLACE ALL OCCURRENCES OF `_` IN lv_from WITH ``.
ASSIGN COMPONENT lv_from OF STRUCTURE <ls_from> TO FIELD-SYMBOL(<comp_from>).
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
ASSIGN COMPONENT ls_comp-name OF STRUCTURE r_result TO FIELD-SYMBOL(<comp_to>).
IF sy-subrc <> 0.
CONTINUE.
ENDIF.
FIELD-SYMBOLS <comp_from_deref> TYPE any.
ASSIGN <comp_from>->* TO <comp_from_deref>.
DATA(lv_type_kind) = rtti_get_type_kind( <comp_to> ).
IF <comp_from_deref> IS INITIAL.
CONTINUE.
ENDIF.
CASE lv_type_kind.
WHEN cl_abap_typedescr=>typekind_table.
trans_ref_tab_2_tab(
EXPORTING
ir_tab_from = <comp_from>
IMPORTING
t_result = <comp_to> ).
WHEN cl_abap_typedescr=>typekind_struct1 OR cl_abap_typedescr=>typekind_struct2.
trans_ref_struc_2_struc(
EXPORTING
ir_struc_from = <comp_from>
IMPORTING
r_result = <comp_to> ).
WHEN OTHERS.
<comp_to> = <comp_from_deref>.
ENDCASE.
ENDLOOP.
ENDMETHOD.
METHOD trans_xml_2_any.
CALL TRANSFORMATION id

View File

@ -27,7 +27,7 @@ CLASS z2ui5_cl_fw_binding DEFINITION
check_dissolved TYPE abap_bool,
check_temp TYPE abap_bool,
viewname TYPE string,
pretty_name TYPE string,
pretty_name TYPE abap_bool,
compress TYPE abap_bool,
depth TYPE i,
END OF ty_s_attri.
@ -153,12 +153,23 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
RETURN.
ENDIF.
IF bind->bind_type <> mv_type AND bind->bind_type IS NOT INITIAL.
IF bind->bind_type IS NOT INITIAL and bind->bind_type <> mv_type.
RAISE EXCEPTION TYPE z2ui5_cx_util_error
EXPORTING
val = `<p>Binding Error - Two different binding types for same attribute used (` && bind->name && `).`.
ENDIF.
IF bind->bind_type IS NOT INITIAL and bind->pretty_name <> mv_pretty_name.
RAISE EXCEPTION TYPE z2ui5_cx_util_error
EXPORTING
val = `<p>Binding Error - Two different pretty types for same attribute used (` && bind->name && `).`.
ENDIF.
IF bind->bind_type IS NOT INITIAL.
result = COND #( WHEN mv_type = cs_bind_type-two_way THEN `/` && cv_model_edit_name && `/` ELSE `/` ) && bind->name_front.
RETURN.
ENDIF.
bind->bind_type = mv_type.
bind->pretty_name = mv_pretty_name.
bind->compress = mv_compress.
@ -444,6 +455,19 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
result = replace( val = result sub = `>` with = `_` occ = 0 ).
result = replace( val = result sub = `-` with = `_` occ = 0 ).
IF mv_pretty_name = abap_true.
SPLIT result AT `_` INTO TABLE DATA(lt_tab).
result = to_lower( lt_tab[ 1 ] ).
LOOP AT lt_tab INTO DATA(lv_val) FROM 2.
TRY.
lv_val = to_lower( lv_val ).
lv_val = to_upper( lv_val(1) ) && lv_val+1.
result = result && lv_val.
CATCH cx_root.
ENDTRY.
ENDLOOP.
ENDIF.
ENDMETHOD.

View File

@ -304,7 +304,7 @@ CLASS Z2UI5_CL_FW_CLIENT IMPLEMENTATION.
IF tab IS NOT INITIAL.
DATA(lv_name) = z2ui5_if_client~_bind_edit( val = tab path = abap_true ).
DATA(lv_name) = z2ui5_if_client~_bind_edit( val = tab path = abap_true pretty_name = pretty_name ).
result = bind_tab_cell(
iv_name = lv_name
i_tab_index = tab_index

View File

@ -77,6 +77,7 @@ CLASS z2ui5_cl_fw_model IMPLEMENTATION.
z2ui5_cl_util_func=>trans_ref_tab_2_tab(
EXPORTING
ir_tab_from = <frontend>
pretty_name = lr_attri->pretty_name
IMPORTING
t_result = <backend> ).
@ -84,6 +85,7 @@ CLASS z2ui5_cl_fw_model IMPLEMENTATION.
z2ui5_cl_util_func=>trans_ref_struc_2_struc(
EXPORTING
ir_struc_from = <frontend>
pretty_name = lr_attri->pretty_name
IMPORTING
r_result = <backend> ).

View File

@ -9,21 +9,22 @@ CLASS z2ui5_cl_popup_input_value DEFINITION
CLASS-METHODS factory
IMPORTING
i_text TYPE string
i_title TYPE string DEFAULT `Title`
i_button_text_confirm TYPE string DEFAULT `OK`
i_button_text_cancel TYPE string DEFAULT `Cancel`
text TYPE string DEFAULT `Enter New Value`
val TYPE string OPTIONAL
title TYPE string DEFAULT `Popup Input Value`
button_text_confirm TYPE string DEFAULT `OK`
button_text_cancel TYPE string DEFAULT `Cancel`
PREFERRED PARAMETER val
RETURNING
VALUE(r_result) TYPE REF TO z2ui5_cl_popup_input_value.
VALUE(r_result) TYPE REF TO z2ui5_cl_popup_input_value.
TYPES:
BEGIN OF ty_s_result,
text TYPE string,
value TYPE string,
check_cancel TYPE abap_bool,
END OF ty_s_result.
DATA ms_result TYPE ty_s_result.
METHODS result
RETURNING
VALUE(result) TYPE ty_s_result.
@ -49,11 +50,12 @@ CLASS Z2UI5_CL_POPUP_INPUT_VALUE IMPLEMENTATION.
METHOD factory.
r_result = NEW #( ).
r_result->title = i_title.
r_result->title = title.
* r_result->icon = i_icon.
r_result->question_text = i_text.
r_result->button_text_confirm = i_button_text_confirm.
r_result->button_text_cancel = i_button_text_cancel.
r_result->question_text = text.
r_result->button_text_confirm = button_text_confirm.
r_result->button_text_cancel = button_text_cancel.
r_result->ms_result-value = val.
ENDMETHOD.
@ -75,7 +77,7 @@ CLASS Z2UI5_CL_POPUP_INPUT_VALUE IMPLEMENTATION.
)->vbox( 'sapUiMediumMargin'
)->label( text = question_text
)->input(
value = client->_bind_edit( ms_result-text )
value = client->_bind_edit( ms_result-value )
submit = client->_event( 'BUTTON_CONFIRM' )
)->get_parent( )->get_parent(
)->footer( )->overflow_toolbar(