Skip to content

Commit

Permalink
New Sample: Title
Browse files Browse the repository at this point in the history
  • Loading branch information
francisco-milan committed Aug 27, 2024
1 parent 4afc782 commit a05bbbb
Show file tree
Hide file tree
Showing 3 changed files with 216 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/z2ui5_cl_demo_app_000.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,13 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel->generic_tile(
header = 'Title'
press = client->_event( 'Z2UI5_CL_DEMO_APP_275' )
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel = page->panel(
expandable = abap_false
expanded = abap_true
Expand Down
193 changes: 193 additions & 0 deletions src/z2ui5_cl_demo_app_275.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
CLASS z2ui5_cl_demo_app_275 DEFINITION
PUBLIC
CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES if_serializable_object.
INTERFACES z2ui5_if_app.

TYPES:
BEGIN OF ty_fields,
productid TYPE string,
name TYPE string,
END OF ty_fields .
TYPES:
BEGIN OF ty_products,
productcollection TYPE STANDARD TABLE OF ty_fields WITH EMPTY KEY,
END OF ty_products .

DATA lt_products TYPE ty_products.
DATA omodel LIKE lt_products.
DATA check_initialized TYPE abap_bool.

PROTECTED SECTION.

DATA client TYPE REF TO z2ui5_if_client.

METHODS display_view
IMPORTING
client TYPE REF TO z2ui5_if_client.
METHODS on_event
IMPORTING
client TYPE REF TO z2ui5_if_client.
METHODS z2ui5_display_popover
IMPORTING
id TYPE string.
METHODS z2ui5_on_init.

PRIVATE SECTION.
ENDCLASS.



CLASS z2ui5_cl_demo_app_275 IMPLEMENTATION.


METHOD display_view.

DATA(page_01) = z2ui5_cl_xml_view=>factory( )->shell(
)->page(
title = 'abap2UI5 - Title'
navbuttonpress = client->_event( 'BACK' )
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL ) ).

page_01->header_content(
)->button( id = `button_hint_id`
icon = `sap-icon://hint`
tooltip = `Sample information`
press = client->_event( 'CLICK_HINT_ICON' ) ).

page_01->header_content(
)->link(
text = 'UI5 Demo Kit'
target = '_blank'
href = 'https://sapui5.hana.ondemand.com/sdk/#/entity/sap.m.Title/sample/sap.m.sample.Title' ).

DATA(page_02) = page_01->page(
enablescrolling = abap_true
title = `Page Header Title`
titlelevel = `H2`
showfooter = abap_false
)->list( items = client->_bind( omodel-productcollection )
)->header_toolbar(
)->toolbar(
)->title( level = `H3` text = `Products`
)->toolbar_spacer(
)->button( icon = `sap-icon://settings` press = client->_event( `handleButtonPress` ) )->get_parent( )->get_parent(
)->standard_list_item( title = '{NAME}' description = '{PRODUCTID}'
).

client->view_display( page_02->stringify( ) ).

ENDMETHOD.


METHOD on_event.

CASE client->get( )-event.
WHEN 'BACK'.
client->nav_app_leave( ).
WHEN 'CLICK_HINT_ICON'.
z2ui5_display_popover( `button_hint_id` ).
WHEN 'handleButtonPress'.
client->message_toast_display( `Header toolbar button pressed.` ).
ENDCASE.

ENDMETHOD.


METHOD z2ui5_display_popover.

DATA(view) = z2ui5_cl_xml_view=>factory_popup( ).
view->quick_view( placement = `Bottom` width = `auto`
)->quick_view_page( pageid = `sampleInformationId`
header = `Sample information`
description = `The Title control is a simple one line text with additional semantic information about ` &&
`the level of the following section in the page structure for accessibility purposes.` ).

client->popover_display(
xml = view->stringify( )
by_id = id
).

ENDMETHOD.


METHOD z2ui5_if_app~main.

me->client = client.

IF check_initialized = abap_false.
check_initialized = abap_true.
display_view( client ).
z2ui5_on_init( ).
ENDIF.

on_event( client ).

ENDMETHOD.


METHOD z2ui5_on_init.

DATA: lv_url TYPE string,
lv_json TYPE string,
lo_http_client TYPE REF TO if_http_client,

Check failure on line 136 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Variable "LO_HTTP_CLIENT" contains unknown: REF, unable to resolve if_http_client

https://rules.abaplint.org/unknown_types

Check failure on line 136 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_standard_readiness

Variable "LO_HTTP_CLIENT" contains unknown: REF, unable to resolve if_http_client

https://rules.abaplint.org/unknown_types

Check failure on line 136 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Variable "LO_HTTP_CLIENT" contains unknown: REF, unable to resolve if_http_client

https://rules.abaplint.org/unknown_types
lv_response TYPE string,
lv_status TYPE i.

lv_url = 'https://raw.githubusercontent.com/SAP/openui5/master/src/sap.ui.documentation/test/sap/ui/documentation/sdk/products.json'.

" Create HTTP client instance
CALL METHOD cl_http_client=>create_by_url

Check failure on line 143 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Class cl_http_client not found

https://rules.abaplint.org/check_syntax

Check failure on line 143 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_standard_readiness

Class cl_http_client not found

https://rules.abaplint.org/check_syntax

Check failure on line 143 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Class cl_http_client not found

https://rules.abaplint.org/check_syntax
EXPORTING
url = lv_url
IMPORTING
client = lo_http_client
EXCEPTIONS
OTHERS = 1.

Check failure on line 149 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Use functional writing style for method calls

https://rules.abaplint.org/functional_writing
IF sy-subrc <> 0.
WRITE: / 'Error in creating HTTP client'.

Check failure on line 151 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Statement does not exist in ABAPCloud(or a parser error), "WRITE"

https://rules.abaplint.org/parser_error
RETURN.
ENDIF.

" Send HTTP GET request
CALL METHOD lo_http_client->send

Check failure on line 156 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Not an object reference, attribute name

https://rules.abaplint.org/check_syntax

Check failure on line 156 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Method or attribute "send" not found, MethodSource

https://rules.abaplint.org/check_syntax

Check failure on line 156 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_standard_readiness

Not an object reference, attribute name

https://rules.abaplint.org/check_syntax

Check failure on line 156 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_standard_readiness

Method or attribute "send" not found, MethodSource

https://rules.abaplint.org/check_syntax

Check failure on line 156 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Not an object reference, attribute name

https://rules.abaplint.org/check_syntax

Check failure on line 156 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Method or attribute "send" not found, MethodSource

https://rules.abaplint.org/check_syntax
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.

Check failure on line 161 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Use functional writing style for method calls

https://rules.abaplint.org/functional_writing
IF sy-subrc <> 0.
WRITE: / 'Error in sending HTTP request'.

Check failure on line 163 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Statement does not exist in ABAPCloud(or a parser error), "WRITE"

https://rules.abaplint.org/parser_error
RETURN.
ENDIF.

" Receive HTTP response
CALL METHOD lo_http_client->receive

Check failure on line 168 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Not an object reference, attribute name

https://rules.abaplint.org/check_syntax

Check failure on line 168 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Method or attribute "receive" not found, MethodSource

https://rules.abaplint.org/check_syntax

Check failure on line 168 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_standard_readiness

Not an object reference, attribute name

https://rules.abaplint.org/check_syntax

Check failure on line 168 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_standard_readiness

Method or attribute "receive" not found, MethodSource

https://rules.abaplint.org/check_syntax

Check failure on line 168 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Not an object reference, attribute name

https://rules.abaplint.org/check_syntax

Check failure on line 168 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Method or attribute "receive" not found, MethodSource

https://rules.abaplint.org/check_syntax
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.

Check failure on line 173 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Use functional writing style for method calls

https://rules.abaplint.org/functional_writing
IF sy-subrc <> 0.
WRITE: / 'Error in receiving HTTP response'.

Check failure on line 175 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Statement does not exist in ABAPCloud(or a parser error), "WRITE"

https://rules.abaplint.org/parser_error
RETURN.
ENDIF.

" Get the response body
lv_response = lo_http_client->response->get_cdata( ).

Check failure on line 180 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Not an object reference, field chain

https://rules.abaplint.org/check_syntax

Check failure on line 180 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_standard_readiness

Not an object reference, field chain

https://rules.abaplint.org/check_syntax

Check failure on line 180 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Not an object reference, field chain

https://rules.abaplint.org/check_syntax

" Clean up HTTP client
lo_http_client->close( ).

Check failure on line 183 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint

Method "close" not found, methodCallChain

https://rules.abaplint.org/check_syntax

Check failure on line 183 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_standard_readiness

Method "close" not found, methodCallChain

https://rules.abaplint.org/check_syntax

Check failure on line 183 in src/z2ui5_cl_demo_app_275.clas.abap

View check run for this annotation

abaplint / abaplint / abap_cloud_readiness

Method "close" not found, methodCallChain

https://rules.abaplint.org/check_syntax

DATA(var_data) = lv_response.

/ui2/cl_json=>deserialize( EXPORTING json = var_data
pretty_name = /ui2/cl_json=>pretty_mode-camel_case
CHANGING data = omodel
).

ENDMETHOD.
ENDCLASS.
16 changes: 16 additions & 0 deletions src/z2ui5_cl_demo_app_275.clas.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>Z2UI5_CL_DEMO_APP_275</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Title</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

0 comments on commit a05bbbb

Please sign in to comment.