Skip to content

Commit

Permalink
Update handler (abap2UI5#1428)
Browse files Browse the repository at this point in the history
* update handler

* update handler

* update

* lint fixes

* update

* Update src/01/02/z2ui5_cl_core_http_get.clas.abap

Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>

* update

* Update src/01/02/z2ui5_cl_core_http_get.clas.abap

Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>

---------

Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>
  • Loading branch information
oblomov-dev and abaplint[bot] authored Sep 14, 2024
1 parent b7b464d commit ae60329
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 1,025 deletions.
6 changes: 5 additions & 1 deletion src/01/02/z2ui5_cl_core_client.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.
mo_action->ms_next-s_set-s_view_nest2-id = id.
mo_action->ms_next-s_set-s_view_nest2-method_destroy = method_destroy.
mo_action->ms_next-s_set-s_view_nest2-method_insert = method_insert.
mo_action->ms_next-s_set-s_view_nest2-s_config = s_config.

ENDMETHOD.

Expand All @@ -191,6 +192,7 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.
mo_action->ms_next-s_set-s_view_nest-id = id.
mo_action->ms_next-s_set-s_view_nest-method_destroy = method_destroy.
mo_action->ms_next-s_set-s_view_nest-method_insert = method_insert.
mo_action->ms_next-s_set-s_view_nest-s_config = s_config.

ENDMETHOD.

Expand All @@ -214,6 +216,7 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.
mo_action->ms_next-s_set-s_popover-check_destroy = abap_false.
mo_action->ms_next-s_set-s_popover-xml = xml.
mo_action->ms_next-s_set-s_popover-open_by_id = by_id.
mo_action->ms_next-s_set-s_popover-s_config = s_config.

ENDMETHOD.

Expand All @@ -236,6 +239,7 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.

mo_action->ms_next-s_set-s_popup-check_destroy = abap_false.
mo_action->ms_next-s_set-s_popup-xml = val.
mo_action->ms_next-s_set-s_popup-s_config = s_config.

ENDMETHOD.

Expand All @@ -257,7 +261,7 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.
METHOD z2ui5_if_client~view_display.

mo_action->ms_next-s_set-s_view-xml = val.
mo_action->ms_next-s_set-s_view-t_config = t_config.
mo_action->ms_next-s_set-s_view-s_config = s_config.

ENDMETHOD.

Expand Down
226 changes: 131 additions & 95 deletions src/01/02/z2ui5_cl_core_http_get.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ CLASS z2ui5_cl_core_http_get DEFINITION
PUBLIC SECTION.

DATA ms_request TYPE z2ui5_if_types=>ty_s_http_request_get.
DATA mv_response TYPE string.

METHODS constructor
IMPORTING
Expand All @@ -17,6 +16,8 @@ CLASS z2ui5_cl_core_http_get DEFINITION
VALUE(result) TYPE string.

METHODS get_js
* IMPORTING
* cs_config TYPE z2ui5_if_types=>ty_s_http_request_get
RETURNING
VALUE(result) TYPE string.

Expand All @@ -28,18 +29,24 @@ CLASS z2ui5_cl_core_http_get DEFINITION

METHODS get_default_config
RETURNING
VALUE(result) TYPE z2ui5_if_types=>ty_s_http_request_get-t_config.
VALUE(result) TYPE z2ui5_if_types=>ty_s_http_request_get.

METHODS get_default_security_policy
METHODS main_get_config
RETURNING
VALUE(result) TYPE string.
VALUE(result) TYPE z2ui5_if_types=>ty_s_http_request_get.

METHODS main_get_index_html
IMPORTING
cs_config TYPE z2ui5_if_types=>ty_s_http_request_get
RETURNING VALUE(result) TYPE string.


PRIVATE SECTION.
ENDCLASS.



CLASS Z2UI5_CL_CORE_HTTP_GET IMPLEMENTATION.
CLASS z2ui5_cl_core_http_get IMPLEMENTATION.


METHOD constructor.
Expand All @@ -51,27 +58,135 @@ CLASS Z2UI5_CL_CORE_HTTP_GET IMPLEMENTATION.

METHOD get_default_config.

DATA(lv_csp) = `<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' data: ` &&
`ui5.sap.com *.ui5.sap.com sapui5.hana.ondemand.com *.sapui5.hana.ondemand.com openui5.hana.ondemand.com *.openui5.hana.ondemand.com ` &&
`sdk.openui5.org *.sdk.openui5.org cdn.jsdelivr.net *.cdn.jsdelivr.net cdnjs.cloudflare.com *.cdnjs.cloudflare.com schemas *.schemas"/>`.

DATA(lv_style) = ` html, body, body > div, #container, #container-uiarea {` && |\n| &&
` height: 100%;` && |\n| &&
` }` && |\n| &&
` .dbg-ltr {` && |\n| &&
` direction: ltr !important;` && |\n| &&
` }`.

result = VALUE #(
( n = `src` v = `https://sdk.openui5.org/resources/sap-ui-cachebuster/sap-ui-core.js` )
* ( n = `src` v = `https://ui5.sap.com/1.124.0/resources/sap-ui-core.js` )
( n = `data-sap-ui-theme` v = `sap_horizon` )
( n = `data-sap-ui-async` v = `true` )
( n = `data-sap-ui-bindingSyntax` v = `complex` )
( n = `data-sap-ui-frameOptions` v = `trusted` )
( n = `data-sap-ui-compatVersion` v = `edge` ) ).
t_param = VALUE #(
( n = `TITLE` v = `abap2UI5` )
( n = `STYLE` v = lv_style )
( n = `SET_SIZE_LIMIT` v = `100` )
( n = `BODY_CLASS` v = `sapUiBody sapUiSizeCompact` )
)
t_config = VALUE #(
( n = `src` v = `https://sdk.openui5.org/resources/sap-ui-cachebuster/sap-ui-core.js` )
* ( n = `src` v = `https://sdk.openui5.org/nightly/2/resources/sap-ui-core.js` )
( n = `data-sap-ui-theme` v = `sap_horizon` )
( n = `data-sap-ui-async` v = `true` )
( n = `id` v = `sap-ui-bootstrap` )
( n = `data-sap-ui-bindingSyntax` v = `complex` )
( n = `data-sap-ui-frameOptions` v = `trusted` )
( n = `data-sap-ui-compatVersion` v = `edge` ) )
content_security_policy = lv_csp ).

ENDMETHOD.


METHOD get_default_security_policy.
METHOD get_js_cc_startup.

result = `<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' data: ` &&
`ui5.sap.com *.ui5.sap.com sapui5.hana.ondemand.com *.sapui5.hana.ondemand.com openui5.hana.ondemand.com *.openui5.hana.ondemand.com ` &&
`sdk.openui5.org *.sdk.openui5.org cdn.jsdelivr.net *.cdn.jsdelivr.net cdnjs.cloudflare.com *.cdnjs.cloudflare.com schemas *.schemas"/>`.
result = ` ` &&
z2ui5_cl_cc_timer=>get_js( ) &&
z2ui5_cl_cc_focus=>get_js( ) &&
z2ui5_cl_cc_title=>get_js( ) &&
z2ui5_cl_cc_lp_title=>get_js( ) &&
z2ui5_cl_cc_history=>get_js( ) &&
z2ui5_cl_cc_scrolling=>get_js( ) &&
z2ui5_cl_cc_info=>get_js( ) &&
z2ui5_cl_cc_geoloc=>get_js( ) &&
z2ui5_cl_cc_file_upl=>get_js( ) &&
z2ui5_cl_cc_multiinput=>get_js( ) &&
z2ui5_cl_cc_uitable=>get_js( ) &&
z2ui5_cl_cc_util=>get_js( ) &&
z2ui5_cl_cc_favicon=>get_js( ) &&
z2ui5_cl_cc_dirty=>get_js( ) &&
` `.

ENDMETHOD.

METHOD main_get_config.

result = get_default_config( ).

LOOP AT ms_request-t_param REFERENCE INTO DATA(lr_param).
TRY.
result-t_param[ n = lr_param->n ]-v = lr_param->v.
CATCH cx_root.
INSERT lr_param->* INTO TABLE result-t_param.
ENDTRY.
ENDLOOP.

LOOP AT ms_request-t_config REFERENCE INTO DATA(lr_option).
TRY.
result-t_config[ n = lr_option->n ]-v = lr_option->v.
CATCH cx_root.
INSERT lr_option->* INTO TABLE result-t_config.
ENDTRY.
ENDLOOP.

IF ms_request-content_security_policy IS NOT INITIAL.
result-content_security_policy = ms_request-content_security_policy.
ENDIF.

IF ms_request-custom_js IS NOT INITIAL.
result-custom_js = ms_request-custom_js.
ENDIF.

ENDMETHOD.


METHOD main_get_index_html.

result = `<!DOCTYPE html>` && |\n| &&
`<html lang="en">` && |\n| &&
`<head>` && |\n| &&
cs_config-content_security_policy && |\n| &&
` <meta charset="UTF-8">` && |\n| &&
` <meta name="viewport" content="width=device-width, initial-scale=1.0">` && |\n| &&
` <meta http-equiv="X-UA-Compatible" content="IE=edge">` && |\n| &&
| <title>{ cs_config-t_param[ n = `TITLE` ]-v }</title> \n| &&
| <style>{ cs_config-t_param[ n = `STYLE` ]-v }</style> \n| &&
` <script id="sap-ui-bootstrap"`.

LOOP AT cs_config-t_config REFERENCE INTO DATA(lr_config).
result = result && | { lr_config->n }='{ lr_config->v }'|.
ENDLOOP.

result = result &&
` ></script></head>` && |\n| &&
`<body class="sapUiBody sapUiSizeCompact" >` && |\n| &&
` <div id="content" data-handle-validation="true" ></div>` && |\n| &&
`<abc/>` && |\n|.

DATA(lv_add_js) = get_js_cc_startup( ) && cs_config-custom_js.
result = result &&
| <script> sap.z2ui5 = sap.z2ui5 \|\| \{\} ; if ( typeof z2ui5 == "undefined" ) \{ var z2ui5 = \{\}; \}; \n| &&
| { get_js( ) } \n| &&
| { lv_add_js } \n| &&
| { z2ui5_cl_cc_debug_tool=>get_js( ) } \n| &&
| sap.z2ui5.JSON_MODEL_LIMIT = { cs_config-t_param[ n = `SET_SIZE_LIMIT` ]-v };| &&
* | sap.z2ui5.NAME_TWO_WAY_MODEL = "{ z2ui5_if_core_types=>cs_ui5-two_way_model }" ;| &&
| { z2ui5_cl_cc_debug_tool=>get_js( ) } \n| &&
| </script><abc/></body></html> |.

ENDMETHOD.


METHOD main.

DATA(ls_config) = main_get_config( ).
result = main_get_index_html( ls_config ).
NEW z2ui5_cl_core_draft_srv( )->cleanup( ).

ENDMETHOD.

METHOD get_js.

DATA(lv_two_way_model) = z2ui5_if_core_types=>cs_ui5-two_way_model.
Expand Down Expand Up @@ -566,83 +681,4 @@ CLASS Z2UI5_CL_CORE_HTTP_GET IMPLEMENTATION.
ENDMETHOD.


METHOD get_js_cc_startup.

result = ` ` &&
z2ui5_cl_cc_timer=>get_js( ) &&
z2ui5_cl_cc_focus=>get_js( ) &&
z2ui5_cl_cc_title=>get_js( ) &&
z2ui5_cl_cc_lp_title=>get_js( ) &&
z2ui5_cl_cc_history=>get_js( ) &&
z2ui5_cl_cc_scrolling=>get_js( ) &&
z2ui5_cl_cc_info=>get_js( ) &&
z2ui5_cl_cc_geoloc=>get_js( ) &&
z2ui5_cl_cc_file_upl=>get_js( ) &&
z2ui5_cl_cc_multiinput=>get_js( ) &&
z2ui5_cl_cc_uitable=>get_js( ) &&
z2ui5_cl_cc_util=>get_js( ) &&
z2ui5_cl_cc_favicon=>get_js( ) &&
z2ui5_cl_cc_dirty=>get_js( ) &&
` `.

ENDMETHOD.


METHOD main.

DATA(lt_config) = COND #( WHEN ms_request-t_config IS INITIAL
THEN get_default_config( )
ELSE ms_request-t_config ).

DATA(lv_sec_policy) = COND #( WHEN ms_request-content_security_policy IS INITIAL
THEN get_default_security_policy( )
ELSE ms_request-content_security_policy ).

mv_response = `<!DOCTYPE html>` && |\n| &&
`<html lang="en">` && |\n| &&
`<head>` && |\n| &&
lv_sec_policy && |\n| &&
` <meta charset="UTF-8">` && |\n| &&
` <meta name="viewport" content="width=device-width, initial-scale=1.0">` && |\n| &&
` <meta http-equiv="X-UA-Compatible" content="IE=edge">` && |\n| &&
` <title>abap2UI5</title>` && |\n| &&
` <style>` && |\n| &&
` html, body, body > div, #container, #container-uiarea {` && |\n| &&
` height: 100%;` && |\n| &&
` }` && |\n| &&
` .dbg-ltr {` && |\n| &&
` direction: ltr !important;` && |\n| &&
` }` && |\n| &&
` </style> ` &&
` <script id="sap-ui-bootstrap"`.

LOOP AT lt_config REFERENCE INTO DATA(lr_config).
mv_response = mv_response && | { lr_config->n }='{ lr_config->v }'|.
ENDLOOP.

mv_response = mv_response &&
` ></script></head>` && |\n| &&
`<body class="sapUiBody sapUiSizeCompact" >` && |\n| &&
` <div id="content" data-handle-validation="true" ></div>` && |\n| &&
`<abc/>` && |\n|.

DATA(lv_add_js) = get_js_cc_startup( ) && ms_request-custom_js.

mv_response = mv_response &&
`<script> sap.z2ui5 = sap.z2ui5 || {} ; if ( typeof z2ui5 == "undefined" ) { var z2ui5 = {}; };` && |\n| &&
get_js( ) && |\n| &&
lv_add_js && |\n| &&
` sap.z2ui5.JSON_MODEL_LIMIT = ` && COND #( WHEN ms_request-json_model_limit IS NOT INITIAL THEN ms_request-json_model_limit ELSE 100 ) && `;`.

mv_response = mv_response &&
z2ui5_cl_cc_debug_tool=>get_js( ).

mv_response = mv_response && |\n| &&
`</script>` && |\n| &&
`<abc/></body></html>`.

NEW z2ui5_cl_core_draft_srv( )->cleanup( ).
result = mv_response.

ENDMETHOD.
ENDCLASS.
Loading

0 comments on commit ae60329

Please sign in to comment.