Downport 752 (#164)

* fixes

* clean up view helper

* add shell to view

* 752 gen data fix
This commit is contained in:
oblomov 2023-04-11 15:42:38 +02:00
parent ee3b0b824a
commit f5e742d918
14 changed files with 80 additions and 88 deletions

View File

@ -41,9 +41,9 @@ CLASS z2ui5_cl_app_demo_00 IMPLEMENTATION.
shownavbutton = abap_true shownavbutton = abap_true
)->header_content( )->header_content(
)->toolbar_spacer( )->toolbar_spacer(
)->link( text = 'SCN' href = 'https://blogs.sap.com/tag/abap2ui5/' )->link( text = 'SCN' target = '_blank' href = 'https://blogs.sap.com/tag/abap2ui5/'
)->link( text = 'Twitter' href = 'https://twitter.com/OblomovDev' )->link( text = 'Twitter' target = '_blank' href = 'https://twitter.com/OblomovDev'
)->link( text = 'GitHub' href = 'https://github.com/oblomov-dev/abap2ui5' )->link( text = 'GitHub' target = '_blank' href = 'https://github.com/oblomov-dev/abap2ui5'
)->get_parent( ). )->get_parent( ).
DATA(grid) = page->grid( 'L3 M6 S12' DATA(grid) = page->grid( 'L3 M6 S12'

View File

@ -47,7 +47,7 @@ CLASS Z2UI5_CL_APP_DEMO_03 IMPLEMENTATION.
client->nav_app_leave( client->get_app( client->get( )-id_prev_app_stack ) ). client->nav_app_leave( client->get_app( client->get( )-id_prev_app_stack ) ).
ENDCASE. ENDCASE.
DATA(page) = z2ui5_cl_xml_view_helper=>factory( DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell(
)->page( )->page(
title = 'abap2UI5 - List' title = 'abap2UI5 - List'
navbuttonpress = client->_event( 'BACK' ) navbuttonpress = client->_event( 'BACK' )

View File

@ -60,7 +60,7 @@ CLASS Z2UI5_CL_APP_DEMO_11 IMPLEMENTATION.
ENDCASE. ENDCASE.
DATA(page) = z2ui5_cl_xml_view_helper=>factory( DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell(
)->page( )->page(
title = 'abap2UI5 - Tables and editable' title = 'abap2UI5 - Tables and editable'
navbuttonpress = client->_event( 'BACK' ) navbuttonpress = client->_event( 'BACK' )

View File

@ -77,7 +77,7 @@ CLASS Z2UI5_CL_APP_DEMO_12 IMPLEMENTATION.
ENDCASE. ENDCASE.
DATA(lo_main) = z2ui5_cl_xml_view_helper=>factory( ). DATA(lo_main) = z2ui5_cl_xml_view_helper=>factory( )->shell( ).
CASE mv_main_view. CASE mv_main_view.

View File

@ -69,7 +69,7 @@ CLASS Z2UI5_CL_APP_DEMO_21 IMPLEMENTATION.
METHOD view_main. METHOD view_main.
DATA(page) = z2ui5_cl_xml_view_helper=>factory( DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell(
)->page( )->page(
title = 'abap2UI5 - Popups' title = 'abap2UI5 - Popups'
navbuttonpress = client->_event( 'BACK' ) navbuttonpress = client->_event( 'BACK' )

View File

@ -100,7 +100,7 @@ CLASS Z2UI5_CL_APP_DEMO_22 IMPLEMENTATION.
ENDCASE. ENDCASE.
DATA(view) = z2ui5_cl_xml_view_helper=>factory( ). DATA(view) = z2ui5_cl_xml_view_helper=>factory( )->shell( ).
DATA(page) = view->page( DATA(page) = view->page(
id = 'id_page' id = 'id_page'
title = 'abap2ui5 - Scrolling and Cursor (use the browser Chrome to avoid incompatibilities)' title = 'abap2ui5 - Scrolling and Cursor (use the browser Chrome to avoid incompatibilities)'

View File

@ -53,7 +53,7 @@ CLASS z2ui5_cl_app_demo_24 IMPLEMENTATION.
ENDCASE. ENDCASE.
DATA(view) = z2ui5_cl_xml_view_helper=>factory( DATA(view) = z2ui5_cl_xml_view_helper=>factory( )->shell(
)->page( title = 'abap2UI5 - flow logic - APP 01' navbuttonpress = client->_event( 'BACK' ) shownavbutton = abap_true )->page( title = 'abap2UI5 - flow logic - APP 01' navbuttonpress = client->_event( 'BACK' ) shownavbutton = abap_true
)->header_content( )->header_content(
)->link( text = 'Demo' target = '_blank' href = `https://twitter.com/OblomovDev/status/1640743794206228480` )->link( text = 'Demo' target = '_blank' href = `https://twitter.com/OblomovDev/status/1640743794206228480`

View File

@ -64,7 +64,7 @@ CLASS z2ui5_cl_app_demo_25 IMPLEMENTATION.
WHEN 'MAIN' OR ''. WHEN 'MAIN' OR ''.
DATA(page) = z2ui5_cl_xml_view_helper=>factory( DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell(
)->page( )->page(
title = 'abap2UI5 - flow logic - APP 02' title = 'abap2UI5 - flow logic - APP 02'
navbuttonpress = client->_event( 'BACK' ) shownavbutton = abap_true navbuttonpress = client->_event( 'BACK' ) shownavbutton = abap_true

View File

@ -98,7 +98,7 @@ CLASS Z2UI5_CL_APP_DEMO_26 IMPLEMENTATION.
WHEN 'VIEW_MAIN'. WHEN 'VIEW_MAIN'.
app-s_next-xml_main = z2ui5_cl_xml_view_helper=>factory( app-s_next-xml_main = z2ui5_cl_xml_view_helper=>factory( )->shell(
)->page( )->page(
title = 'abap2UI5 - Popover Examples' title = 'abap2UI5 - Popover Examples'
navbuttonpress = client->_event( 'BACK' ) navbuttonpress = client->_event( 'BACK' )

View File

@ -98,7 +98,7 @@ CLASS Z2UI5_CL_APP_DEMO_27 IMPLEMENTATION.
METHOD z2ui5_on_render. METHOD z2ui5_on_render.
app-s_next-xml_main = z2ui5_cl_xml_view_helper=>factory( app-s_next-xml_main = z2ui5_cl_xml_view_helper=>factory( )->shell(
)->page( )->page(
title = 'abap2UI5 - Binding Syntax' title = 'abap2UI5 - Binding Syntax'
navbuttonpress = client->_event( 'BACK' ) navbuttonpress = client->_event( 'BACK' )

View File

@ -27,7 +27,7 @@ CLASS Z2UI5_CL_APP_DEMO_34 IMPLEMENTATION.
METHOD view_main. METHOD view_main.
DATA(page) = z2ui5_cl_xml_view_helper=>factory( DATA(page) = z2ui5_cl_xml_view_helper=>factory( )->shell(
)->page( )->page(
title = 'abap2UI5 - Popups' title = 'abap2UI5 - Popups'
navbuttonpress = client->_event( 'BACK' ) navbuttonpress = client->_event( 'BACK' )

View File

@ -60,7 +60,6 @@ CLASS z2ui5_cl_xml_view_helper DEFINITION
RETURNING RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_xml_view_helper. VALUE(result) TYPE REF TO z2ui5_cl_xml_view_helper.
METHODS Dynamic_Page_Header METHODS Dynamic_Page_Header
IMPORTING IMPORTING
pinnable TYPE clike OPTIONAL pinnable TYPE clike OPTIONAL
@ -864,6 +863,27 @@ ENDCLASS.
CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION. CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
METHOD constructor.
mt_prop = VALUE #(
( n = `xmlns` v = `sap.m` )
( n = `xmlns:z2ui5` v = `z2ui5` )
( n = `xmlns:core` v = `sap.ui.core` )
( n = `xmlns:mvc` v = `sap.ui.core.mvc` )
( n = `xmlns:layout` v = `sap.ui.layout` )
( n = `xmlns:f` v = `sap.f` )
( n = `xmlns:form` v = `sap.ui.layout.form` )
( n = `xmlns:editor` v = `sap.ui.codeeditor` )
( n = `xmlns:mchart` v = `sap.suite.ui.microchart` )
( n = `xmlns:webc` v = `sap.ui.webc.main` )
( n = `xmlns:uxap` v = `sap.uxap` )
( n = `xmlns:sap` v = `sap` )
( n = `xmlns:text` v = `sap.ui.richtextedito` )
( n = `xmlns:html` v = `http://www.w3.org/1999/xhtml` )
).
ENDMETHOD.
METHOD factory. METHOD factory.
result = NEW #( ). result = NEW #( ).
@ -878,10 +898,9 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
( n = 'controllerName' v = 'z2ui5_controller' ) ( n = 'controllerName' v = 'z2ui5_controller' )
). ).
result->m_name = `View`. result->m_name = `View`.
result->m_ns = `mvc`. result->m_ns = `mvc`.
result->m_root = result.
result->m_root = result.
result->m_parent = result. result->m_parent = result.
ENDMETHOD. ENDMETHOD.
@ -956,8 +975,8 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
METHOD blocks. METHOD blocks.
result = _generic( result = _generic(
name = `blocks` name = `blocks`
ns = `uxap` ns = `uxap`
). ).
ENDMETHOD. ENDMETHOD.
@ -975,7 +994,7 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
( n = `enabled` v = _=>get_json_boolean( enabled ) ) ( n = `enabled` v = _=>get_json_boolean( enabled ) )
( n = `icon` v = icon ) ( n = `icon` v = icon )
( n = `type` v = type ) ( n = `type` v = type )
( n = `id` v = id ) ( n = `id` v = id )
( n = `class` v = class ) ( n = `class` v = class )
) ). ) ).
@ -1080,7 +1099,7 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
result = _generic( result = _generic(
`customData` `customData`
). ).
ENDMETHOD. ENDMETHOD.
@ -1354,7 +1373,7 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
( n = `showClearIcon` v = _=>get_json_boolean( showclearicon ) ) ( n = `showClearIcon` v = _=>get_json_boolean( showclearicon ) )
( n = `description` v = description ) ( n = `description` v = description )
( n = `editable` v = _=>get_json_boolean( editable ) ) ( n = `editable` v = _=>get_json_boolean( editable ) )
( n = `enabled` v = _=>get_json_boolean( enabled ) ) ( n = `enabled` v = _=>get_json_boolean( enabled ) )
( n = `valueState` v = valuestate ) ( n = `valueState` v = valuestate )
( n = `valueStateText` v = valuestatetext ) ( n = `valueStateText` v = valuestatetext )
( n = `value` v = value ) ( n = `value` v = value )
@ -1570,10 +1589,10 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
_generic( _generic(
name = `MessageStrip` name = `MessageStrip`
t_prop = VALUE #( t_prop = VALUE #(
( n = `text` v = text ) ( n = `text` v = text )
( n = `type` v = type ) ( n = `type` v = type )
( n = `showIcon` v = _=>get_json_boolean( showicon ) ) ( n = `showIcon` v = _=>get_json_boolean( showicon ) )
( n = `class` v = class ) ( n = `class` v = class )
) ). ) ).
ENDMETHOD. ENDMETHOD.
@ -1600,10 +1619,10 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
_generic( _generic(
name = `ObjectNumber` name = `ObjectNumber`
t_prop = VALUE #( t_prop = VALUE #(
( n = `emphasized` v = _=>get_json_boolean( emphasized ) ) ( n = `emphasized` v = _=>get_json_boolean( emphasized ) )
( n = `number` v = number ) ( n = `number` v = number )
( n = `state` v = state ) ( n = `state` v = state )
( n = `unit` v = unit ) ( n = `unit` v = unit )
) ). ) ).
ENDMETHOD. ENDMETHOD.
@ -2221,9 +2240,7 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
result = _generic( result = _generic(
name = `DynamicPageTitle` name = `DynamicPageTitle`
ns = `f` ns = `f`
t_prop = VALUE #( ).
" ( n = `pinnable` v = pinnable )
) ).
ENDMETHOD. ENDMETHOD.
@ -2233,7 +2250,6 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
_generic( _generic(
name = `ObjectAttribute` name = `ObjectAttribute`
" ns = `form`
t_prop = VALUE #( t_prop = VALUE #(
( n = `title` v = title ) ( n = `title` v = title )
( n = `text` v = text ) ( n = `text` v = text )
@ -2265,17 +2281,14 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
DATA(lv_url) = get-t_req_header[ name = `referer` ]-value. DATA(lv_url) = get-t_req_header[ name = `referer` ]-value.
SPLIT lv_url AT '?' INTO lv_url DATA(lv_dummy). SPLIT lv_url AT '?' INTO lv_url DATA(lv_dummy).
" result-url_app = lv_url && `?sap-client=` && sy-mandt && `&app=` && _=>get_classname_by_ref( mo_runtime->ms_db-o_app ).
result = z2ui5_cl_http_handler=>client-t_header[ name = `origin` ]-value && `/sap/bc/adt/oo/classes/` && _=>get_classname_by_ref( app ) && `/source/main`. result = z2ui5_cl_http_handler=>client-t_header[ name = `origin` ]-value && `/sap/bc/adt/oo/classes/` && _=>get_classname_by_ref( app ) && `/source/main`.
ENDMETHOD. ENDMETHOD.
METHOD additional_content. METHOD additional_content.
result = _generic( result = _generic(
name = `additionalContent` name = `additionalContent`
). ).
ENDMETHOD. ENDMETHOD.
@ -2299,39 +2312,11 @@ CLASS z2ui5_cl_xml_view_helper IMPLEMENTATION.
result->mt_prop = t_ns. result->mt_prop = t_ns.
ENDIF. ENDIF.
" result->mt_prop = VALUE #( BASE result->mt_prop
" ( n = 'displayBlock' v = 'true' )
" ( n = 'height' v = '100%' )
" ( n = 'controllerName' v = 'z2ui5_controller' )
" ).
result->m_name = `FragmentDefinition`. result->m_name = `FragmentDefinition`.
result->m_ns = `core`. result->m_ns = `core`.
result->m_root = result. result->m_root = result.
result->m_parent = result. result->m_parent = result.
ENDMETHOD. ENDMETHOD.
METHOD constructor.
mt_prop = VALUE #(
( n = `xmlns` v = `sap.m` )
( n = `xmlns:z2ui5` v = `z2ui5` )
( n = `xmlns:core` v = `sap.ui.core` )
( n = `xmlns:mvc` v = `sap.ui.core.mvc` )
( n = `xmlns:layout` v = `sap.ui.layout` )
( n = `xmlns:f` v = `sap.f` )
( n = `xmlns:form` v = `sap.ui.layout.form` )
( n = `xmlns:editor` v = `sap.ui.codeeditor` )
( n = `xmlns:mchart` v = `sap.suite.ui.microchart` )
( n = `xmlns:webc` v = `sap.ui.webc.main` )
( n = `xmlns:uxap` v = `sap.uxap` )
( n = `xmlns:sap` v = `sap` )
( n = `xmlns:text` v = `sap.ui.richtextedito` )
( n = `xmlns:html` v = `http://www.w3.org/1999/xhtml` )
).
ENDMETHOD.
ENDCLASS. ENDCLASS.

View File

@ -88,17 +88,18 @@ CLASS z2ui5_cl_http_handler IMPLEMENTATION.
` </style> ` && ` </style> ` &&
` <script src="` && library_path && `" ` && ` <script src="` && library_path && `" ` &&
` id="sap-ui-bootstrap" data-sap-ui-theme="` && theme && `" `. ` id="sap-ui-bootstrap" data-sap-ui-theme="` && theme && `" `.
if rtl is SUPPLIED.
r_result = r_result && `data-sap-ui-rtl="` && _=>get_json_boolean( rtl ) && `" `.
endif.
r_result = r_result && ` data-sap-ui-libs="sap.m" data-sap-ui-bindingSyntax="complex" data-sap-ui-frameOptions="trusted" data-sap-ui-compatVersion="edge"` && |\n| && IF rtl IS SUPPLIED.
` >` && |\n| && r_result = r_result && `data-sap-ui-rtl="` && _=>get_json_boolean( rtl ) && `" `.
` </script></head>` && |\n| && ENDIF.
`<body class="sapUiBody sapUiSizeCompact" >` && |\n| &&
` <div id="content" data-handle-validation="true" ></div>` && |\n| && r_result = r_result && ` data-sap-ui-libs="sap.m" data-sap-ui-bindingSyntax="complex" data-sap-ui-frameOptions="trusted" data-sap-ui-compatVersion="edge"` && |\n| &&
`</body>` && |\n| && ` >` && |\n| &&
`</html>` && |\n|. ` </script></head>` && |\n| &&
`<body class="sapUiBody sapUiSizeCompact" >` && |\n| &&
` <div id="content" data-handle-validation="true" ></div>` && |\n| &&
`</body>` && |\n| &&
`</html>` && |\n|.
r_result = r_result && `<script id="z2ui5">` && |\n| && r_result = r_result && `<script id="z2ui5">` && |\n| &&
` sap.ui.getCore().attachInit(function () {` && |\n| && ` sap.ui.getCore().attachInit(function () {` && |\n| &&

View File

@ -522,8 +522,8 @@ CLASS z2ui5_lcl_utility IMPLEMENTATION.
ENDIF. ENDIF.
ENDLOOP. ENDLOOP.
FIELD-SYMBOLS <row> type any. FIELD-SYMBOLS <row> TYPE any.
ASSign lr_row->* to <row>. ASSIGN lr_row->* TO <row>.
INSERT <row> INTO TABLE ct_to. INSERT <row> INTO TABLE ct_to.
ENDLOOP. ENDLOOP.
@ -1321,8 +1321,8 @@ CLASS z2ui5_lcl_db IMPLEMENTATION.
DATA(lv_name) = 'LO_APP->' && to_upper( lr_attri->name ). DATA(lv_name) = 'LO_APP->' && to_upper( lr_attri->name ).
ASSIGN (lv_name) TO <attribute>. ASSIGN (lv_name) TO <attribute>.
DATA(lr_ref2) = REF #( <attribute> ). DATA(lr_ref2) = REF #( <attribute> ).
FIELD-SYMBOLS <field> type any. FIELD-SYMBOLS <field> TYPE any.
ASSign lr_ref2->* to <field>. ASSIGN lr_ref2->* TO <field>.
CLEAR <field>. CLEAR <field>.
ENDLOOP. ENDLOOP.
@ -1634,18 +1634,18 @@ CLASS z2ui5_lcl_system_runtime IMPLEMENTATION.
ASSIGN (lv_name) TO <attribute>. ASSIGN (lv_name) TO <attribute>.
_=>raise( when = xsdbool( sy-subrc <> 0 ) v = `Attribute in App with name ` && lv_name && ` not found` ). _=>raise( when = xsdbool( sy-subrc <> 0 ) v = `Attribute in App with name ` && lv_name && ` not found` ).
data lr_ref2 type ref to data. DATA lr_ref2 TYPE REF TO data.
get reference of <attribute> into lr_ref2. GET REFERENCE OF <attribute> INTO lr_ref2.
" DATA(lr_ref2) = REF #( <attribute> ). " DATA(lr_ref2) = REF #( <attribute> ).
IF check_gen_data = abap_true. IF check_gen_data = abap_true.
TRY. TRY.
FIELD-SYMBOLS <field> type any. FIELD-SYMBOLS <field> TYPE any.
assign lr_ref2->* to <field>. ASSIGN lr_ref2->* TO <field>.
DATA(lr_ref) = CAST data( <field> ). DATA(lr_ref) = CAST data( <field> ).
IF lr_attri->gen_type IS INITIAL. IF lr_attri->gen_type IS INITIAL.
FIELD-SYMBOLS <field2> type any. FIELD-SYMBOLS <field2> TYPE any.
assign lr_ref->* to <field2>. ASSIGN lr_ref->* TO <field2>.
DATA(lo_datadescr) = cl_abap_datadescr=>describe_by_data( <field2> ). DATA(lo_datadescr) = cl_abap_datadescr=>describe_by_data( <field2> ).
lr_attri->gen_type_kind = lo_datadescr->type_kind. lr_attri->gen_type_kind = lo_datadescr->type_kind.
lr_attri->gen_kind = lo_datadescr->kind. lr_attri->gen_kind = lo_datadescr->kind.
@ -1773,13 +1773,19 @@ CLASS z2ui5_lcl_system_runtime IMPLEMENTATION.
CASE lr_attri->gen_kind. CASE lr_attri->gen_kind.
WHEN cl_abap_datadescr=>kind_elem. WHEN cl_abap_datadescr=>kind_elem.
lv_name = '<ATTRIBUTE>->*'.
FIELD-SYMBOLS <field> type any.
assign (lv_name) to <field>.
lo_actual->add_attribute( n = lr_attri->name lo_actual->add_attribute( n = lr_attri->name
v = _=>get_abap_2_json( <attribute>->* ) v = _=>get_abap_2_json( <field> )
apos_active = abap_false ). apos_active = abap_false ).
WHEN cl_abap_datadescr=>kind_table. WHEN cl_abap_datadescr=>kind_table.
lv_name = '<ATTRIBUTE>->*'.
" FIELD-SYMBOLS <field> type any.
assign (lv_name) to <field>.
lo_actual->add_attribute( n = lr_attri->name lo_actual->add_attribute( n = lr_attri->name
v = _=>trans_any_2_json( <attribute>->* ) v = _=>trans_any_2_json( <field> )
apos_active = abap_false ). apos_active = abap_false ).
ENDCASE. ENDCASE.