update control structure in event (#963)

* update control structure in event

* update
This commit is contained in:
oblomov 2024-02-27 18:56:34 +01:00 committed by GitHub
parent 650b62a163
commit 527158f728
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 52 additions and 25 deletions

View File

@ -7,9 +7,9 @@ CLASS z2ui5_cl_core_event_srv DEFINITION
METHODS get_event
IMPORTING
!val TYPE clike OPTIONAL
!check_view_destroy TYPE abap_bool DEFAULT abap_false
!t_arg TYPE string_table OPTIONAL
!val TYPE clike OPTIONAL
!t_arg TYPE string_table OPTIONAL
!s_cnt TYPE z2ui5_if_types=>ty_s_event_control OPTIONAL
PREFERRED PARAMETER val
RETURNING
VALUE(result) TYPE string.
@ -37,8 +37,19 @@ CLASS z2ui5_cl_core_event_srv IMPLEMENTATION.
METHOD get_event.
result = |{ z2ui5_if_core_types=>cs_ui5-event_backend_function }(['{ val }'{ COND #( WHEN check_view_destroy = abap_true THEN `,true`) }]|.
result = result && get_t_arg( t_arg ).
result = |{ z2ui5_if_core_types=>cs_ui5-event_backend_function }(['{ val }'|.
IF s_cnt-check_allow_parallel_events = abap_true.
IF s_cnt-check_view_destroy = abap_true.
result = result && `,true,true`.
ELSE.
result = result && `,false,true`.
ENDIF.
ELSEIF s_cnt-check_view_destroy = abap_true.
result = result && `,true`.
ENDIF.
result = result && `]` && get_t_arg( t_arg ).
ENDMETHOD.

View File

@ -215,11 +215,11 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.
mo_action->ms_next-s_set-s_view-check_update_model = abap_true.
IF path IS NOT INITIAL.
try.
DATA(lv_bind) = z2ui5_if_client~_bind( val = path path = abap_true ).
catch cx_root.
lv_bind = z2ui5_if_client~_bind_edit( val = path path = abap_true ).
endtry.
TRY.
DATA(lv_bind) = z2ui5_if_client~_bind( val = path path = abap_true ).
CATCH cx_root.
lv_bind = z2ui5_if_client~_bind_edit( val = path path = abap_true ).
ENDTRY.
SHIFT lv_bind LEFT DELETING LEADING `/`.
SPLIT lv_bind AT `/` INTO TABLE mo_action->ms_next-s_set-s_view-update_path.
ENDIF.
@ -287,8 +287,8 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.
DATA(lo_ui5) = NEW z2ui5_cl_core_event_srv( ).
result = lo_ui5->get_event(
val = val
check_view_destroy = check_view_destroy
t_arg = t_arg ).
t_arg = t_arg
s_cnt = s_cnt ).
ENDMETHOD.

View File

@ -73,8 +73,9 @@ CLASS Z2UI5_CL_CORE_HTTP_GET 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| &&
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", "sap/m/BusyDialog` &&
`" ], function(Control` &&
`ler, XMLView, JSONModel, BusyIndicator, MessageBox, MessageToast, Fragment, mBusyDialog ) {` && |\n| &&
` "use strict";` && |\n| &&
` return Controller.extend("z2ui5.Controller", {` && |\n| &&
` async onAfterRendering() {` && |\n| &&
@ -299,19 +300,22 @@ CLASS Z2UI5_CL_CORE_HTTP_GET IMPLEMENTATION.
` }` && |\n| &&
` },` && |\n| &&
` eB(...args) {` && |\n| &&
` if (sap.z2ui5.isBusy == true) {` && |\n| &&
` let oBusyDialog = new sap.m.BusyDialog();` && |\n| &&
` if (!window.navigator.onLine) {` && |\n| &&
` MessageBox.alert('No internet connection! Please reconnect to the server and try again.');` && |\n| &&
` return;` && |\n| &&
` }` && |\n| &&
` if (sap.z2ui5.isBusy == true) {` && |\n| &&
* ` if (args[0][2]) { setTimeout( (args , oControl) => { oControl.eB(args[0], args[1], args[2] ); } , 1000 , args , this );` && |\n| &&
* ` return; } else {` && |\n| &&
` let oBusyDialog = new mBusyDialog();` && |\n| &&
` oBusyDialog.open();` && |\n| &&
` setTimeout( (oBusyDialog) => { oBusyDialog.close() } , 100 , oBusyDialog );` && |\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| &&
* ` BusyIndicator.show();` && |\n| &&
* ` sap.z2ui5.counter += 1; ` && |\n| &&
` let appStart = sap.z2ui5.oBody.APP_START;` && |\n| &&
` sap.z2ui5.oBody = {};` && |\n| &&
` sap.z2ui5.oBody.APP_START = appStart;` && |\n| &&
@ -414,6 +418,7 @@ CLASS Z2UI5_CL_CORE_HTTP_GET IMPLEMENTATION.
` }` && |\n| &&
` },` && |\n| &&
` async readHttp() {` && |\n| &&
* ` let counter = sap.z2ui5.counter;` && |\n| &&
` const response = await fetch(sap.z2ui5.pathname, {` && |\n| &&
` method: 'POST',` && |\n| &&
` headers: {` && |\n| &&
@ -426,6 +431,9 @@ CLASS Z2UI5_CL_CORE_HTTP_GET IMPLEMENTATION.
` sap.z2ui5.oController.responseError(responseText);` && |\n| &&
` } else {` && |\n| &&
` const responseData = await response.json();` && |\n| &&
* ` if ( counter < sap.z2ui5.counter ) {` && |\n| &&
* ` if ( counter > 2 ) {` && |\n| &&
* ` return };` && |\n| &&
` sap.z2ui5.responseData = responseData;` && |\n| &&
` if( !sap.z2ui5.oBody.APP_START ) { sap.z2ui5.oBody.APP_START = sap.z2ui5.responseData.S_FRONT.APP; }` && |\n| &&
` sap.z2ui5.oController.responseSuccess({` && |\n| &&
@ -483,7 +491,9 @@ CLASS Z2UI5_CL_CORE_HTTP_GET IMPLEMENTATION.
` sap.z2ui5.onBeforeRoundtrip = [];` && |\n| &&
` sap.z2ui5.onAfterRendering = [];` && |\n| &&
` sap.z2ui5.onBeforeEventFrontend = [];` && |\n| &&
` sap.z2ui5.onAfterRoundtrip = []; }` && |\n| &&
` sap.z2ui5.onAfterRoundtrip = []; ` && |\n| &&
* ` sap.z2ui5.counter = 0; ` && |\n| &&
` }` && |\n| &&
`);`.
ENDMETHOD.

View File

@ -53,7 +53,6 @@ CLASS z2ui5_cl_core_http_post IMPLEMENTATION.
EXIT.
ENDIF.
ENDDO.
* result = main_end( ).
result = mv_response.
ENDMETHOD.

View File

@ -109,7 +109,8 @@ INTERFACE z2ui5_if_client
IMPORTING
val TYPE clike OPTIONAL
t_arg TYPE string_table OPTIONAL
check_view_destroy TYPE abap_bool DEFAULT abap_false
check_view_destroy TYPE abap_bool OPTIONAL
s_cnt TYPE z2ui5_if_types=>ty_s_event_control OPTIONAL
PREFERRED PARAMETER val
RETURNING
VALUE(result) TYPE string.

View File

@ -43,4 +43,10 @@ INTERFACE z2ui5_if_types
s_config TYPE ty_s_config,
END OF ty_s_get.
TYPES:
BEGIN OF ty_s_event_control,
check_view_destroy TYPE abap_bool,
check_allow_parallel_events TYPE abap_bool,
END OF ty_s_event_control.
ENDINTERFACE.