mirror of
https://github.com/abap2UI5/abap2UI5.git
synced 2025-04-30 11:00:25 +08:00
fix messagetoast + filter and mapping logic (#845)
This commit is contained in:
parent
7e4cfa185b
commit
d5c331ffbb
|
@ -29,9 +29,11 @@ CLASS z2ui5_cl_fw_binding DEFINITION
|
||||||
viewname TYPE string,
|
viewname TYPE string,
|
||||||
pretty_name TYPE abap_bool,
|
pretty_name TYPE abap_bool,
|
||||||
compress TYPE string,
|
compress TYPE string,
|
||||||
compress_custom TYPE string,
|
* compress_custom TYPE string,
|
||||||
depth TYPE i,
|
depth TYPE i,
|
||||||
ajson_local TYPE REF TO z2ui5_if_ajson,
|
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.
|
END OF ty_s_attri.
|
||||||
TYPES ty_t_attri TYPE SORTED TABLE OF ty_s_attri WITH UNIQUE KEY name.
|
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
|
view TYPE clike OPTIONAL
|
||||||
pretty_name TYPE clike OPTIONAL
|
pretty_name TYPE clike OPTIONAL
|
||||||
compress 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
|
RETURNING
|
||||||
VALUE(r_result) TYPE REF TO z2ui5_cl_fw_binding.
|
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_view TYPE string.
|
||||||
DATA mv_pretty_name TYPE string.
|
DATA mv_pretty_name TYPE string.
|
||||||
DATA mv_compress 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
|
CLASS-METHODS update_attri
|
||||||
IMPORTING
|
IMPORTING
|
||||||
|
@ -178,7 +184,9 @@ CLASS z2ui5_cl_fw_binding IMPLEMENTATION.
|
||||||
bind->pretty_name = mv_pretty_name.
|
bind->pretty_name = mv_pretty_name.
|
||||||
bind->compress = mv_compress.
|
bind->compress = mv_compress.
|
||||||
bind->viewname = mv_view.
|
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.
|
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_view = view.
|
||||||
r_result->mv_pretty_name = pretty_name.
|
r_result->mv_pretty_name = pretty_name.
|
||||||
r_result->mv_compress = compress.
|
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 ).
|
IF z2ui5_cl_util_func=>rtti_check_type_kind_dref( data ).
|
||||||
RAISE EXCEPTION TYPE z2ui5_cx_util_error
|
RAISE EXCEPTION TYPE z2ui5_cx_util_error
|
||||||
|
|
|
@ -335,7 +335,9 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
|
||||||
data = val
|
data = val
|
||||||
pretty_name = pretty_mode
|
pretty_name = pretty_mode
|
||||||
compress = compress_mode
|
compress = compress_mode
|
||||||
compress_custom = compress_custom
|
* compress_custom = compress_custom
|
||||||
|
custom_mapper = custom_mapper
|
||||||
|
custom_filter = custom_filter
|
||||||
).
|
).
|
||||||
|
|
||||||
result = lo_binder->main( ).
|
result = lo_binder->main( ).
|
||||||
|
@ -410,7 +412,10 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
|
||||||
view = view
|
view = view
|
||||||
pretty_name = pretty_mode
|
pretty_name = pretty_mode
|
||||||
compress = compress_mode
|
compress = compress_mode
|
||||||
compress_custom = compress_custom ).
|
* compress_custom = compress_custom
|
||||||
|
custom_mapper = custom_mapper
|
||||||
|
custom_filter = custom_filter
|
||||||
|
).
|
||||||
|
|
||||||
result = lo_binder->main( ).
|
result = lo_binder->main( ).
|
||||||
mo_handler->ms_db-t_attri = lo_binder->mt_attri.
|
mo_handler->ms_db-t_attri = lo_binder->mt_attri.
|
||||||
|
@ -433,7 +438,10 @@ CLASS z2ui5_cl_fw_client IMPLEMENTATION.
|
||||||
data = val
|
data = val
|
||||||
pretty_name = pretty_mode
|
pretty_name = pretty_mode
|
||||||
compress = compress_mode
|
compress = compress_mode
|
||||||
compress_custom = compress_custom ).
|
* compress_custom = compress_custom
|
||||||
|
custom_mapper = custom_mapper
|
||||||
|
custom_filter = custom_filter
|
||||||
|
).
|
||||||
|
|
||||||
result = lo_binder->main( ).
|
result = lo_binder->main( ).
|
||||||
mo_handler->ms_db-t_attri = lo_binder->mt_attri.
|
mo_handler->ms_db-t_attri = lo_binder->mt_attri.
|
||||||
|
|
|
@ -126,6 +126,13 @@ CLASS Z2UI5_CL_FW_INDEX_HTML IMPLEMENTATION.
|
||||||
` async onAfterRendering() {` && |\n| &&
|
` async onAfterRendering() {` && |\n| &&
|
||||||
` try{` && |\n| &&
|
` try{` && |\n| &&
|
||||||
` if (!sap.z2ui5.oResponse.PARAMS) {` && |\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| &&
|
` return;` && |\n| &&
|
||||||
` }` && |\n| &&
|
` }` && |\n| &&
|
||||||
` const {S_POPUP, S_VIEW_NEST, S_VIEW_NEST2, S_POPOVER} = sap.z2ui5.oResponse.PARAMS;` && |\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| &&
|
` document.write(response);` && |\n| &&
|
||||||
` },` && |\n| &&
|
` },` && |\n| &&
|
||||||
` updateModelIfRequired(paramKey, oView) {` && |\n| &&
|
` updateModelIfRequired(paramKey, oView) {` && |\n| &&
|
||||||
|
` if (sap.z2ui5.oResponse.PARAMS == undefined) { return; }` && |\n| &&
|
||||||
` if (sap.z2ui5.oResponse.PARAMS[paramKey]?.CHECK_UPDATE_MODEL) {` && |\n| &&
|
` if (sap.z2ui5.oResponse.PARAMS[paramKey]?.CHECK_UPDATE_MODEL) {` && |\n| &&
|
||||||
` let model = new JSONModel(sap.z2ui5.oResponse.OVIEWMODEL);` && |\n| &&
|
` let model = new JSONModel(sap.z2ui5.oResponse.OVIEWMODEL);` && |\n| &&
|
||||||
` model.setSizeLimit(sap.z2ui5.JSON_MODEL_LIMIT);` && |\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| &&
|
` }catch(e){ BusyIndicator.hide(); MessageBox.error(e.toLocaleString()); }` && |\n| &&
|
||||||
` },` && |\n| &&
|
` },` && |\n| &&
|
||||||
` showMessage(msgType, params) {` && |\n| &&
|
` showMessage(msgType, params) {` && |\n| &&
|
||||||
|
` if (params == undefined) { return; }` && |\n| &&
|
||||||
` if (params[msgType]?.TEXT !== undefined) {` && |\n| &&
|
` if (params[msgType]?.TEXT !== undefined) {` && |\n| &&
|
||||||
` if (msgType === 'S_MSG_TOAST') {` && |\n| &&
|
` if (msgType === 'S_MSG_TOAST') {` && |\n| &&
|
||||||
` MessageToast.show(params[msgType].TEXT);` && |\n| &&
|
` MessageToast.show(params[msgType].TEXT);` && |\n| &&
|
||||||
|
|
|
@ -72,17 +72,22 @@ CLASS z2ui5_cl_fw_model_ajson IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
"(1) set pretty mode
|
"(1) set pretty mode
|
||||||
CASE lr_attri->pretty_name.
|
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 ) ).
|
||||||
WHEN z2ui5_if_client=>cs_pretty_mode-none.
|
ELSE.
|
||||||
DATA(ajson) = CAST z2ui5_if_ajson( z2ui5_cl_ajson=>create_empty( ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_upper_case( ) ) ).
|
ajson = CAST z2ui5_if_ajson( z2ui5_cl_ajson=>create_empty( ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_upper_case( ) ) ).
|
||||||
|
ENDIF.
|
||||||
WHEN z2ui5_if_client=>cs_pretty_mode-camel_case.
|
* CASE lr_attri->pretty_name.
|
||||||
ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ) ).
|
*
|
||||||
|
* WHEN z2ui5_if_client=>cs_pretty_mode-none.
|
||||||
WHEN OTHERS.
|
* DATA(ajson) = CAST z2ui5_if_ajson( z2ui5_cl_ajson=>create_empty( ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_upper_case( ) ) ).
|
||||||
ASSERT `` = `ERROR_UNKNOWN_PRETTY_MODE`.
|
*
|
||||||
ENDCASE.
|
* 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
|
"(2) read attribute of end-user app
|
||||||
|
@ -117,25 +122,30 @@ CLASS z2ui5_cl_fw_model_ajson IMPLEMENTATION.
|
||||||
|
|
||||||
"(4) set compress mode
|
"(4) set compress mode
|
||||||
"todo performance - add and filter in a single loop
|
"todo performance - add and filter in a single loop
|
||||||
IF lr_attri->compress_custom IS NOT INITIAL.
|
IF lr_attri->custom_filter IS BOUND.
|
||||||
DATA li_filter TYPE REF TO z2ui5_if_ajson_filter.
|
ajson = ajson->filter( lr_attri->custom_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.
|
ELSE.
|
||||||
ASSERT `` = `ERROR_UNKNOW_COMPRESS_MODE`.
|
ajson = ajson->filter( z2ui5_cl_ajson_filter_lib=>create_empty_filter( ) ).
|
||||||
ENDIF.
|
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
|
"(5) write into result
|
||||||
|
|
|
@ -12,7 +12,7 @@ INTERFACE z2ui5_if_client
|
||||||
nest2_nav_container_to TYPE string VALUE `NEST2_NAV_CONTAINER_TO`,
|
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_ext TYPE string VALUE `CROSS_APP_NAV_TO_EXT`,
|
||||||
cross_app_nav_to_prev_app TYPE string VALUE `CROSS_APP_NAV_TO_PREV_APP`,
|
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.
|
END OF cs_event.
|
||||||
|
|
||||||
CONSTANTS:
|
CONSTANTS:
|
||||||
|
@ -181,7 +181,9 @@ INTERFACE z2ui5_if_client
|
||||||
path TYPE abap_bool DEFAULT abap_false
|
path TYPE abap_bool DEFAULT abap_false
|
||||||
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
|
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
|
||||||
compress_mode TYPE clike DEFAULT cs_compress_mode-standard
|
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 TYPE STANDARD TABLE OPTIONAL
|
||||||
tab_index TYPE i OPTIONAL
|
tab_index TYPE i OPTIONAL
|
||||||
struc TYPE data OPTIONAL
|
struc TYPE data OPTIONAL
|
||||||
|
@ -195,7 +197,9 @@ INTERFACE z2ui5_if_client
|
||||||
view TYPE string DEFAULT cs_view-main
|
view TYPE string DEFAULT cs_view-main
|
||||||
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
|
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
|
||||||
compress_mode TYPE clike DEFAULT cs_compress_mode-standard
|
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 TYPE STANDARD TABLE OPTIONAL
|
||||||
tab_index TYPE i OPTIONAL
|
tab_index TYPE i OPTIONAL
|
||||||
struc TYPE data OPTIONAL
|
struc TYPE data OPTIONAL
|
||||||
|
@ -207,8 +211,10 @@ INTERFACE z2ui5_if_client
|
||||||
val TYPE data
|
val TYPE data
|
||||||
path TYPE abap_bool DEFAULT abap_false
|
path TYPE abap_bool DEFAULT abap_false
|
||||||
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
|
pretty_mode TYPE clike DEFAULT cs_pretty_mode-none
|
||||||
compress_custom TYPE clike OPTIONAL
|
* compress_custom TYPE clike OPTIONAL
|
||||||
compress_mode TYPE clike DEFAULT cs_compress_mode-standard
|
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
|
RETURNING
|
||||||
VALUE(result) TYPE string.
|
VALUE(result) TYPE string.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user