mirror of
https://github.com/abap2UI5/abap2UI5.git
synced 2025-04-30 07:31:54 +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
|
@ -48,6 +48,8 @@ CLASS z2ui5_cl_util DEFINITION
|
||||||
name TYPE string,
|
name TYPE string,
|
||||||
t_range TYPE ty_t_range,
|
t_range TYPE ty_t_range,
|
||||||
t_token TYPE ty_t_token,
|
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,
|
s_sql TYPE ty_S_sql,
|
||||||
sql_text TYPE string,
|
sql_text TYPE string,
|
||||||
END OF ty_s_filter_multi.
|
END OF ty_s_filter_multi.
|
||||||
|
@ -133,6 +135,12 @@ CLASS z2ui5_cl_util DEFINITION
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(result) TYPE ty_t_filter_multi.
|
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
|
CLASS-METHODS filter_get_sql_by_sql_string
|
||||||
IMPORTING
|
IMPORTING
|
||||||
val TYPE clike
|
val TYPE clike
|
||||||
|
@ -331,6 +339,13 @@ CLASS z2ui5_cl_util DEFINITION
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(result) TYPE abap_bool.
|
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
|
CLASS-METHODS filter_get_range_t_by_token_t
|
||||||
IMPORTING
|
IMPORTING
|
||||||
val TYPE ty_t_token
|
val TYPE ty_t_token
|
||||||
|
@ -738,6 +753,27 @@ CLASS z2ui5_cl_util IMPLEMENTATION.
|
||||||
ENDMETHOD.
|
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.
|
METHOD filter_get_range_t_by_token_t.
|
||||||
|
|
||||||
LOOP AT val INTO DATA(ls_token).
|
LOOP AT val INTO DATA(ls_token).
|
||||||
|
@ -1450,6 +1486,12 @@ CLASS z2ui5_cl_util IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD itab_filter_by_t_range.
|
METHOD itab_filter_by_t_range.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD filter_get_data_by_multi.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -68,7 +68,13 @@ CLASS z2ui5_cl_core_action IMPLEMENTATION.
|
||||||
METHOD factory_by_frontend.
|
METHOD factory_by_frontend.
|
||||||
|
|
||||||
result = NEW #( mo_http_post ).
|
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 ).
|
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 = z2ui5_cl_util=>uuid_get_c32( ).
|
||||||
result->mo_app->ms_draft-id_prev = mo_http_post->ms_request-s_front-id.
|
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.
|
IF stateful = abap_true.
|
||||||
mo_action->ms_next-s_set-handler_attrs-stateful-active = 1.
|
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.
|
ELSE.
|
||||||
mo_action->ms_next-s_set-handler_attrs-stateful-active = 0.
|
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.
|
ENDIF.
|
||||||
mo_action->ms_next-s_set-handler_attrs-stateful-switched = abap_true.
|
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 ).
|
mv_response = lo_json_mapper->response_abap_to_json( ms_response ).
|
||||||
|
|
||||||
CLEAR mo_action->ms_next.
|
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( ).
|
mo_action->mo_app->db_save( ).
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
@ -134,9 +137,13 @@ CLASS z2ui5_cl_core_http_post IMPLEMENTATION.
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
DATA(li_app) = CAST z2ui5_if_app( mo_action->mo_app->mo_app ).
|
DATA(li_app) = CAST z2ui5_if_app( mo_action->mo_app->mo_app ).
|
||||||
|
|
||||||
|
IF li_app->check_sticky = abap_false.
|
||||||
ROLLBACK WORK.
|
ROLLBACK WORK.
|
||||||
|
ENDIF.
|
||||||
li_app->main( li_client ).
|
li_app->main( li_client ).
|
||||||
|
IF li_app->check_sticky = abap_false.
|
||||||
ROLLBACK WORK.
|
ROLLBACK WORK.
|
||||||
|
ENDIF.
|
||||||
|
|
||||||
IF mo_action->ms_next-o_app_leave IS NOT INITIAL.
|
IF mo_action->ms_next-o_app_leave IS NOT INITIAL.
|
||||||
mo_action = mo_action->factory_stack_leave( ).
|
mo_action = mo_action->factory_stack_leave( ).
|
||||||
|
|
|
@ -63,7 +63,13 @@ CLASS z2ui5_cl_cc_multiinput IMPLEMENTATION.
|
||||||
` }` && |\n| &&
|
` }` && |\n| &&
|
||||||
` this.fireChange();` && |\n| &&
|
` this.fireChange();` && |\n| &&
|
||||||
` },` && |\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| &&
|
` if ( this.getProperty("checkInit") == true ){ return; } ` && |\n| &&
|
||||||
` this.setProperty( "checkInit" , true );` && |\n| &&
|
` this.setProperty( "checkInit" , true );` && |\n| &&
|
||||||
` table.attachTokenUpdate(this.onTokenUpdate.bind(this));` && |\n| &&
|
` table.attachTokenUpdate(this.onTokenUpdate.bind(this));` && |\n| &&
|
||||||
|
@ -73,6 +79,7 @@ CLASS z2ui5_cl_cc_multiinput IMPLEMENTATION.
|
||||||
` };` && |\n| &&
|
` };` && |\n| &&
|
||||||
` table.addValidator(fnValidator); }, ` && |\n| &&
|
` table.addValidator(fnValidator); }, ` && |\n| &&
|
||||||
` renderer(oRM, oControl) {` && |\n| &&
|
` renderer(oRM, oControl) {` && |\n| &&
|
||||||
|
* ` sap.z2ui5.onAfterRendering.push( oControl.setControl.bind(oControl) ); ` && |\n| &&
|
||||||
` }` && |\n| &&
|
` }` && |\n| &&
|
||||||
` });` && |\n| &&
|
` });` && |\n| &&
|
||||||
`}); }`.
|
`}); }`.
|
||||||
|
|
|
@ -4,6 +4,8 @@ CLASS z2ui5_cl_http_handler DEFINITION
|
||||||
|
|
||||||
PUBLIC SECTION.
|
PUBLIC SECTION.
|
||||||
|
|
||||||
|
CLASS-DATA so_sticky_handler TYPE REF TO z2ui5_cl_core_http_post.
|
||||||
|
|
||||||
CLASS-METHODS main
|
CLASS-METHODS main
|
||||||
IMPORTING
|
IMPORTING
|
||||||
body TYPE string
|
body TYPE string
|
||||||
|
@ -47,11 +49,17 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION.
|
||||||
METHOD http_post.
|
METHOD http_post.
|
||||||
CLEAR attributes.
|
CLEAR attributes.
|
||||||
|
|
||||||
|
IF so_sticky_handler IS NOT BOUND.
|
||||||
DATA(lo_post) = NEW z2ui5_cl_core_http_post( val ).
|
DATA(lo_post) = NEW z2ui5_cl_core_http_post( val ).
|
||||||
|
ELSE.
|
||||||
|
so_sticky_handler = lo_post.
|
||||||
|
ENDIF.
|
||||||
result = lo_post->main(
|
result = lo_post->main(
|
||||||
IMPORTING
|
IMPORTING
|
||||||
attributes = attributes ).
|
attributes = attributes ).
|
||||||
|
|
||||||
|
so_sticky_handler = lo_post.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD main.
|
METHOD main.
|
||||||
|
@ -61,12 +69,20 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION.
|
||||||
DATA(lo_get) = NEW z2ui5_cl_core_http_get( config ).
|
DATA(lo_get) = NEW z2ui5_cl_core_http_get( config ).
|
||||||
result = lo_get->main( ).
|
result = lo_get->main( ).
|
||||||
ELSE.
|
ELSE.
|
||||||
|
IF so_sticky_handler IS NOT BOUND.
|
||||||
DATA(lo_post) = NEW z2ui5_cl_core_http_post( body ).
|
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(
|
result = lo_post->main(
|
||||||
IMPORTING
|
IMPORTING
|
||||||
attributes = attributes ).
|
attributes = attributes ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
|
so_sticky_handler = lo_post.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -8,6 +8,7 @@ INTERFACE z2ui5_if_app PUBLIC.
|
||||||
|
|
||||||
DATA id_draft TYPE string.
|
DATA id_draft TYPE string.
|
||||||
DATA id_app TYPE string.
|
DATA id_app TYPE string.
|
||||||
|
DATA check_sticky TYPE abap_bool.
|
||||||
|
|
||||||
METHODS main
|
METHODS main
|
||||||
IMPORTING
|
IMPORTING
|
||||||
|
|
Loading…
Reference in New Issue
Block a user