mirror of
https://github.com/abap2UI5/abap2UI5.git
synced 2025-04-30 00:36:14 +08:00
refactoring - filter functions - sticky functions (#1437)
* refactoring - filter fucntions - sticky functions * update * udpate * update
This commit is contained in:
parent
1fba55457c
commit
4940a26a46
|
@ -45,11 +45,13 @@ CLASS z2ui5_cl_util DEFINITION
|
|||
|
||||
TYPES:
|
||||
BEGIN OF ty_s_filter_multi,
|
||||
name TYPE string,
|
||||
t_range TYPE ty_t_range,
|
||||
t_token TYPE ty_t_token,
|
||||
s_sql TYPE ty_S_sql,
|
||||
sql_text TYPE string,
|
||||
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.
|
||||
TYPES ty_t_filter_multi TYPE STANDARD TABLE OF ty_s_filter_multi WITH EMPTY KEY.
|
||||
|
||||
|
@ -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.
|
||||
|
|
|
@ -68,7 +68,13 @@ CLASS z2ui5_cl_core_action IMPLEMENTATION.
|
|||
METHOD factory_by_frontend.
|
||||
|
||||
result = NEW #( mo_http_post ).
|
||||
result->mo_app = z2ui5_cl_core_app=>db_load( mo_http_post->ms_request-s_front-id ).
|
||||
|
||||
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.
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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.
|
||||
mo_action->mo_app->db_save( ).
|
||||
|
||||
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 ).
|
||||
|
||||
ROLLBACK WORK.
|
||||
IF li_app->check_sticky = abap_false.
|
||||
ROLLBACK WORK.
|
||||
ENDIF.
|
||||
li_app->main( li_client ).
|
||||
ROLLBACK WORK.
|
||||
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( ).
|
||||
|
|
|
@ -41,7 +41,7 @@ CLASS z2ui5_cl_cc_multiinput IMPLEMENTATION.
|
|||
` },` && |\n| &&
|
||||
|\n| &&
|
||||
` init() {` && |\n| &&
|
||||
` sap.z2ui5.onAfterRendering.push( this.setControl.bind(this) ); ` && |\n| &&
|
||||
` sap.z2ui5.onAfterRendering.push( this.setControl.bind(this) ); ` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
|\n| &&
|
||||
` onTokenUpdate(oEvent) { ` && |\n| &&
|
||||
|
@ -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| &&
|
||||
`}); }`.
|
||||
|
|
|
@ -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.
|
||||
|
||||
DATA(lo_post) = NEW z2ui5_cl_core_http_post( val ).
|
||||
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.
|
||||
DATA(lo_post) = NEW z2ui5_cl_core_http_post( body ).
|
||||
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.
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user