refactoring - filter functions - sticky functions (#1437)

* refactoring - filter fucntions - sticky functions

* update

* udpate

* update
This commit is contained in:
oblomov-dev 2024-09-17 19:38:43 +02:00 committed by GitHub
parent 1fba55457c
commit 4940a26a46
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 94 additions and 13 deletions

View File

@ -48,6 +48,8 @@ CLASS z2ui5_cl_util DEFINITION
name TYPE string,
t_range TYPE ty_t_range,
t_token TYPE ty_t_token,
t_token_added TYPE ty_t_token,
t_token_removed TYPE ty_t_token,
s_sql TYPE ty_S_sql,
sql_text TYPE string,
END OF ty_s_filter_multi.
@ -133,6 +135,12 @@ CLASS z2ui5_cl_util DEFINITION
RETURNING
VALUE(result) TYPE ty_t_filter_multi.
CLASS-METHODS filter_get_data_by_multi
IMPORTING
val TYPE ty_t_filter_multi
RETURNING
VALUE(result) TYPE ty_t_filter_multi.
CLASS-METHODS filter_get_sql_by_sql_string
IMPORTING
val TYPE clike
@ -331,6 +339,13 @@ CLASS z2ui5_cl_util DEFINITION
RETURNING
VALUE(result) TYPE abap_bool.
CLASS-METHODS filter_update_tokens
IMPORTING
val TYPE ty_t_filter_multi
name TYPE string
RETURNING
VALUE(result) TYPE ty_t_filter_multi.
CLASS-METHODS filter_get_range_t_by_token_t
IMPORTING
val TYPE ty_t_token
@ -738,6 +753,27 @@ CLASS z2ui5_cl_util IMPLEMENTATION.
ENDMETHOD.
METHOD filter_update_tokens.
result = val.
DATA(lr_filter) = REF #( result[ name = name ] ).
LOOP AT lr_filter->t_token_removed INTO DATA(ls_token).
DELETE lr_filter->t_token WHERE key = ls_token-key.
ENDLOOP.
LOOP AT lr_filter->t_token_added INTO ls_token.
INSERT VALUE #( key = ls_token-key text = ls_token-text visible = abap_true editable = abap_true ) INTO TABLE lr_filter->t_token.
ENDLOOP.
CLEAR lr_filter->t_token_removed.
CLEAR lr_filter->t_token_added.
data(lt_token) = result[ name = name ]-t_token.
data(lt_range) = z2ui5_cl_util=>filter_get_range_t_by_token_t( result[ name = name ]-t_token ).
lr_filter->t_range = lt_range.
ENDMETHOD.
METHOD filter_get_range_t_by_token_t.
LOOP AT val INTO DATA(ls_token).
@ -1450,6 +1486,12 @@ CLASS z2ui5_cl_util IMPLEMENTATION.
METHOD itab_filter_by_t_range.
ENDMETHOD.
METHOD filter_get_data_by_multi.
ENDMETHOD.
ENDCLASS.

View File

@ -68,7 +68,13 @@ CLASS z2ui5_cl_core_action IMPLEMENTATION.
METHOD factory_by_frontend.
result = NEW #( mo_http_post ).
IF mo_http_post->mo_action->mo_app->mo_app IS BOUND.
result->mo_app = mo_http_post->mo_action->mo_app.
ELSE.
result->mo_app = z2ui5_cl_core_app=>db_load( mo_http_post->ms_request-s_front-id ).
ENDIF.
result->mo_app->ms_draft-id = z2ui5_cl_util=>uuid_get_c32( ).
result->mo_app->ms_draft-id_prev = mo_http_post->ms_request-s_front-id.

View File

@ -345,8 +345,10 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.
IF stateful = abap_true.
mo_action->ms_next-s_set-handler_attrs-stateful-active = 1.
CAST z2ui5_if_app( mo_action->mo_app->mo_app )->check_sticky = abap_true.
ELSE.
mo_action->ms_next-s_set-handler_attrs-stateful-active = 0.
CAST z2ui5_if_app( mo_action->mo_app->mo_app )->check_sticky = abap_false.
ENDIF.
mo_action->ms_next-s_set-handler_attrs-stateful-switched = abap_true.

View File

@ -117,7 +117,10 @@ CLASS z2ui5_cl_core_http_post IMPLEMENTATION.
mv_response = lo_json_mapper->response_abap_to_json( ms_response ).
CLEAR mo_action->ms_next.
IF CAST z2ui5_if_app( mo_action->mo_app->mo_app )->check_sticky = abap_false.
mo_action->mo_app->db_save( ).
ENDIF.
ENDMETHOD.
@ -134,9 +137,13 @@ CLASS z2ui5_cl_core_http_post IMPLEMENTATION.
ENDTRY.
DATA(li_app) = CAST z2ui5_if_app( mo_action->mo_app->mo_app ).
IF li_app->check_sticky = abap_false.
ROLLBACK WORK.
ENDIF.
li_app->main( li_client ).
IF li_app->check_sticky = abap_false.
ROLLBACK WORK.
ENDIF.
IF mo_action->ms_next-o_app_leave IS NOT INITIAL.
mo_action = mo_action->factory_stack_leave( ).

View File

@ -63,7 +63,13 @@ CLASS z2ui5_cl_cc_multiinput IMPLEMENTATION.
` }` && |\n| &&
` this.fireChange();` && |\n| &&
` },` && |\n| &&
` setControl(){ let table = sap.z2ui5.oView.byId( this.getProperty("MultiInputId"));` && |\n| &&
` renderer(oRm, oControl) { ` &&
` sap.z2ui5.onAfterRendering.push( this.setControl.bind(oControl) ); ` && |\n| &&
` },` && |\n| &&
` setControl(){ ` && |\n| &&
` let table = sap.z2ui5.oView.byId( this.getProperty("MultiInputId") );` && |\n| &&
` if (!table) { table = sap.ui.getCore().byId( this.getProperty("MultiInputId") ); } ` && |\n| &&
` if ( !table ){ return; } ` && |\n| &&
` if ( this.getProperty("checkInit") == true ){ return; } ` && |\n| &&
` this.setProperty( "checkInit" , true );` && |\n| &&
` table.attachTokenUpdate(this.onTokenUpdate.bind(this));` && |\n| &&
@ -73,6 +79,7 @@ CLASS z2ui5_cl_cc_multiinput IMPLEMENTATION.
` };` && |\n| &&
` table.addValidator(fnValidator); }, ` && |\n| &&
` renderer(oRM, oControl) {` && |\n| &&
* ` sap.z2ui5.onAfterRendering.push( oControl.setControl.bind(oControl) ); ` && |\n| &&
` }` && |\n| &&
` });` && |\n| &&
`}); }`.

View File

@ -4,6 +4,8 @@ CLASS z2ui5_cl_http_handler DEFINITION
PUBLIC SECTION.
CLASS-DATA so_sticky_handler TYPE REF TO z2ui5_cl_core_http_post.
CLASS-METHODS main
IMPORTING
body TYPE string
@ -47,11 +49,17 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION.
METHOD http_post.
CLEAR attributes.
IF so_sticky_handler IS NOT BOUND.
DATA(lo_post) = NEW z2ui5_cl_core_http_post( val ).
ELSE.
so_sticky_handler = lo_post.
ENDIF.
result = lo_post->main(
IMPORTING
attributes = attributes ).
so_sticky_handler = lo_post.
ENDMETHOD.
METHOD main.
@ -61,12 +69,20 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION.
DATA(lo_get) = NEW z2ui5_cl_core_http_get( config ).
result = lo_get->main( ).
ELSE.
IF so_sticky_handler IS NOT BOUND.
DATA(lo_post) = NEW z2ui5_cl_core_http_post( body ).
ELSE.
lo_post = so_sticky_handler.
lo_post->mv_request_json = body.
ENDIF.
* DATA(lo_post) = NEW z2ui5_cl_core_http_post( body ).
result = lo_post->main(
IMPORTING
attributes = attributes ).
ENDIF.
so_sticky_handler = lo_post.
ENDMETHOD.
ENDCLASS.

View File

@ -8,6 +8,7 @@ INTERFACE z2ui5_if_app PUBLIC.
DATA id_draft TYPE string.
DATA id_app TYPE string.
DATA check_sticky TYPE abap_bool.
METHODS main
IMPORTING