fix messagetoast + filter and mapping logic (#845)

This commit is contained in:
oblomov 2024-02-02 23:47:36 +01:00 committed by GitHub
parent 7e4cfa185b
commit d5c331ffbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 94 additions and 53 deletions

View File

@ -29,9 +29,11 @@ CLASS z2ui5_cl_fw_binding DEFINITION
viewname TYPE string,
pretty_name TYPE abap_bool,
compress TYPE string,
compress_custom TYPE string,
* compress_custom TYPE string,
depth TYPE i,
ajson_local TYPE REF TO z2ui5_if_ajson,
custom_filter TYPE REF TO z2ui5_if_ajson_filter,
custom_mapper TYPE REF TO z2ui5_if_ajson_mapping,
END OF ty_s_attri.
TYPES ty_t_attri TYPE SORTED TABLE OF ty_s_attri WITH UNIQUE KEY name.
@ -45,7 +47,9 @@ CLASS z2ui5_cl_fw_binding DEFINITION
view TYPE clike OPTIONAL
pretty_name TYPE clike OPTIONAL
compress TYPE clike OPTIONAL
compress_custom TYPE clike OPTIONAL
* compress_custom TYPE clike OPTIONAL
custom_filter TYPE REF TO z2ui5_if_ajson_filter OPTIONAL
custom_mapper TYPE REF TO z2ui5_if_ajson_mapping OPTIONAL
RETURNING
VALUE(r_result) TYPE REF TO z2ui5_cl_fw_binding.
@ -61,7 +65,9 @@ CLASS z2ui5_cl_fw_binding DEFINITION
DATA mv_view TYPE string.
DATA mv_pretty_name TYPE string.
DATA mv_compress TYPE string.
DATA mv_compress_custom TYPE string.
* DATA mv_compress_custom TYPE string.
DATA mo_custom_filter TYPE REF TO z2ui5_if_ajson_filter.
DATA mo_custom_mapper TYPE REF TO z2ui5_if_ajson_mapping.
CLASS-METHODS update_attri
IMPORTING
@ -178,7 +184,9 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
bind->pretty_name = mv_pretty_name.
bind->compress = mv_compress.
bind->viewname = mv_view.
bind->compress_custom = mv_compress_custom.
bind->custom_filter = mo_custom_filter.
bind->custom_mapper = mo_custom_mapper.
* bind->compress_custom = mv_compress_custom.
IF z2ui5_cl_fw_controller=>cv_check_ajson = abap_false.
@ -321,8 +329,8 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
r_result->mv_view = view.
r_result->mv_pretty_name = pretty_name.
r_result->mv_compress = compress.
r_result->mv_compress_custom = to_upper( compress_custom ).
r_result->mo_custom_filter = custom_filter.
r_result->mo_custom_mapper = custom_mapper.
IF z2ui5_cl_util_func=>rtti_check_type_kind_dref( data ).
RAISE EXCEPTION TYPE z2ui5_cx_util_error

View File

@ -335,7 +335,9 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
data = val
pretty_name = pretty_mode
compress = compress_mode
compress_custom = compress_custom
* compress_custom = compress_custom
custom_mapper = custom_mapper
custom_filter = custom_filter
).
result = lo_binder->main( ).
@ -410,7 +412,10 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
view = view
pretty_name = pretty_mode
compress = compress_mode
compress_custom = compress_custom ).
* compress_custom = compress_custom
custom_mapper = custom_mapper
custom_filter = custom_filter
).
result = lo_binder->main( ).
mo_handler->ms_db-t_attri = lo_binder->mt_attri.
@ -433,7 +438,10 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
data = val
pretty_name = pretty_mode
compress = compress_mode
compress_custom = compress_custom ).
* compress_custom = compress_custom
custom_mapper = custom_mapper
custom_filter = custom_filter
).
result = lo_binder->main( ).
mo_handler->ms_db-t_attri = lo_binder->mt_attri.

View File

@ -126,6 +126,13 @@ CLASS Z2UI5_CL_FW_INDEX_HTML IMPLEMENTATION.
` async onAfterRendering() {` && |\n| &&
` try{` && |\n| &&
` if (!sap.z2ui5.oResponse.PARAMS) {` && |\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| &&
` return;` && |\n| &&
` }` && |\n| &&
` const {S_POPUP, S_VIEW_NEST, S_VIEW_NEST2, S_POPOVER} = sap.z2ui5.oResponse.PARAMS;` && |\n| &&
@ -417,6 +424,7 @@ CLASS Z2UI5_CL_FW_INDEX_HTML IMPLEMENTATION.
` document.write(response);` && |\n| &&
` },` && |\n| &&
` updateModelIfRequired(paramKey, oView) {` && |\n| &&
` if (sap.z2ui5.oResponse.PARAMS == undefined) { return; }` && |\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| &&
@ -446,6 +454,7 @@ CLASS Z2UI5_CL_FW_INDEX_HTML IMPLEMENTATION.
` }catch(e){ BusyIndicator.hide(); MessageBox.error(e.toLocaleString()); }` && |\n| &&
` },` && |\n| &&
` showMessage(msgType, params) {` && |\n| &&
` if (params == undefined) { return; }` && |\n| &&
` if (params[msgType]?.TEXT !== undefined) {` && |\n| &&
` if (msgType === 'S_MSG_TOAST') {` && |\n| &&
` MessageToast.show(params[msgType].TEXT);` && |\n| &&

View File

@ -72,17 +72,22 @@ CLASS z2ui5_cl_fw_model_ajson IMPLEMENTATION.
"(1) set pretty mode
CASE lr_attri->pretty_name.
WHEN z2ui5_if_client=>cs_pretty_mode-none.
DATA(ajson) = CAST z2ui5_if_ajson( z2ui5_cl_ajson=>create_empty( ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_upper_case( ) ) ).
WHEN z2ui5_if_client=>cs_pretty_mode-camel_case.
ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ) ).
WHEN OTHERS.
ASSERT `` = `ERROR_UNKNOWN_PRETTY_MODE`.
ENDCASE.
IF lr_attri->custom_mapper IS BOUND.
DATA(ajson) = CAST z2ui5_if_ajson( z2ui5_cl_ajson=>create_empty( ii_custom_mapping = lr_attri->custom_mapper ) ).
ELSE.
ajson = CAST z2ui5_if_ajson( z2ui5_cl_ajson=>create_empty( ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_upper_case( ) ) ).
ENDIF.
* CASE lr_attri->pretty_name.
*
* WHEN z2ui5_if_client=>cs_pretty_mode-none.
* DATA(ajson) = CAST z2ui5_if_ajson( z2ui5_cl_ajson=>create_empty( ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_upper_case( ) ) ).
*
* WHEN z2ui5_if_client=>cs_pretty_mode-camel_case.
* ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ) ).
*
* WHEN OTHERS.
* ASSERT `` = `ERROR_UNKNOWN_PRETTY_MODE`.
* ENDCASE.
"(2) read attribute of end-user app
@ -117,25 +122,30 @@ CLASS z2ui5_cl_fw_model_ajson IMPLEMENTATION.
"(4) set compress mode
"todo performance - add and filter in a single loop
IF lr_attri->compress_custom IS NOT INITIAL.
DATA li_filter TYPE REF TO z2ui5_if_ajson_filter.
CREATE OBJECT li_filter TYPE (lr_attri->compress_custom).
ajson = ajson->filter( li_filter ).
ELSEIF lr_attri->compress = z2ui5_if_client=>cs_compress_mode-full.
"obsolete - is this still needed? use compress_custom instead
ASSERT `` = `OBSOLET_COMPRESS_MODE_USE_CUSTOM_INSTEAD`.
ELSEIF lr_attri->compress = z2ui5_if_client=>cs_compress_mode-standard.
ajson = ajson->filter( z2ui5_cl_ajson_filter_lib=>create_empty_filter( ) ).
ELSEIF lr_attri->compress = z2ui5_if_client=>cs_compress_mode-none.
"obsolete - is this still needed? use compress_custom instead
ASSERT `` = `OBSOLET_COMPRESS_MODE_USE_CUSTOM_INSTEAD`.
IF lr_attri->custom_filter IS BOUND.
ajson = ajson->filter( lr_attri->custom_filter ).
ELSE.
ASSERT `` = `ERROR_UNKNOW_COMPRESS_MODE`.
ajson = ajson->filter( z2ui5_cl_ajson_filter_lib=>create_empty_filter( ) ).
ENDIF.
* IF lr_attri->compress_custom IS NOT INITIAL.
* DATA li_filter TYPE REF TO z2ui5_if_ajson_filter.
* CREATE OBJECT li_filter TYPE (lr_attri->compress_custom).
* ajson = ajson->filter( li_filter ).
*
* ELSEIF lr_attri->compress = z2ui5_if_client=>cs_compress_mode-full.
* "obsolete - is this still needed? use compress_custom instead
* ASSERT `` = `OBSOLET_COMPRESS_MODE_USE_CUSTOM_INSTEAD`.
*
* ELSEIF lr_attri->compress = z2ui5_if_client=>cs_compress_mode-standard.
* ajson = ajson->filter( z2ui5_cl_ajson_filter_lib=>create_empty_filter( ) ).
*
* ELSEIF lr_attri->compress = z2ui5_if_client=>cs_compress_mode-none.
* "obsolete - is this still needed? use compress_custom instead
* ASSERT `` = `OBSOLET_COMPRESS_MODE_USE_CUSTOM_INSTEAD`.
*
* ELSE.
* ASSERT `` = `ERROR_UNKNOW_COMPRESS_MODE`.
* ENDIF.
"(5) write into result

View File

@ -12,7 +12,7 @@ INTERFACE z2ui5_if_client
nest2_nav_container_to TYPE string VALUE `NEST2_NAV_CONTAINER_TO`,
cross_app_nav_to_ext TYPE string VALUE `CROSS_APP_NAV_TO_EXT`,
cross_app_nav_to_prev_app TYPE string VALUE `CROSS_APP_NAV_TO_PREV_APP`,
POPUP_NAV_CONTAINER_TO TYPE string VALUE `POPUP_NAV_CONTAINER_TO`,
popup_nav_container_to TYPE string VALUE `POPUP_NAV_CONTAINER_TO`,
END OF cs_event.
CONSTANTS:
@ -177,16 +177,18 @@ INTERFACE z2ui5_if_client
METHODS _bind
IMPORTING
val TYPE data
path TYPE abap_bool DEFAULT abap_false
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
compress_mode TYPE clike DEFAULT cs_compress_mode-standard
compress_custom TYPE clike OPTIONAL
tab TYPE STANDARD TABLE OPTIONAL
tab_index TYPE i OPTIONAL
struc TYPE data OPTIONAL
val TYPE data
path TYPE abap_bool DEFAULT abap_false
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
compress_mode TYPE clike DEFAULT cs_compress_mode-standard
* compress_custom TYPE clike OPTIONAL
custom_mapper TYPE REF TO z2ui5_if_ajson_mapping optional
custom_filter TYPE REF TO z2ui5_if_ajson_filter optional
tab TYPE STANDARD TABLE OPTIONAL
tab_index TYPE i OPTIONAL
struc TYPE data OPTIONAL
RETURNING
VALUE(result) TYPE string.
VALUE(result) TYPE string.
METHODS _bind_edit
IMPORTING
@ -195,7 +197,9 @@ INTERFACE z2ui5_if_client
view TYPE string DEFAULT cs_view-main
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
compress_mode TYPE clike DEFAULT cs_compress_mode-standard
compress_custom TYPE clike OPTIONAL
* compress_custom TYPE clike OPTIONAL
custom_mapper TYPE REF TO z2ui5_if_ajson_mapping optional
custom_filter TYPE REF TO z2ui5_if_ajson_filter optional
tab TYPE STANDARD TABLE OPTIONAL
tab_index TYPE i OPTIONAL
struc TYPE data OPTIONAL
@ -204,11 +208,13 @@ INTERFACE z2ui5_if_client
METHODS _bind_local
IMPORTING
val TYPE data
path TYPE abap_bool DEFAULT abap_false
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
compress_custom TYPE clike OPTIONAL
compress_mode TYPE clike DEFAULT cs_compress_mode-standard
val TYPE data
path TYPE abap_bool DEFAULT abap_false
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
* compress_custom TYPE clike OPTIONAL
compress_mode TYPE clike DEFAULT cs_compress_mode-standard
custom_mapper TYPE REF TO z2ui5_if_ajson_mapping optional
custom_filter TYPE REF TO z2ui5_if_ajson_filter optional
RETURNING
VALUE(result) TYPE string.