Skip to content

Commit

Permalink
New Sample: Select (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
francisco-milan authored Sep 21, 2024
1 parent af695f4 commit 4b6d6f8
Show file tree
Hide file tree
Showing 3 changed files with 213 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/z2ui5_cl_demo_app_000.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,12 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

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

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

PUBLIC SECTION.

INTERFACES z2ui5_if_app .

TYPES:
BEGIN OF ty_product_collection,
product_id TYPE string,
name TYPE string,
END OF ty_product_collection .

DATA check_initialized TYPE abap_bool.
DATA editable TYPE abap_bool.
DATA enabled TYPE abap_bool.
DATA lt_product_collection TYPE TABLE OF ty_product_collection.
DATA lt_product_collection2 TYPE TABLE OF ty_product_collection.
DATA lt_product_collection3 TYPE TABLE OF ty_product_collection.
DATA selected_product TYPE string.
DATA selected_product2 TYPE string.
DATA selected_product3 TYPE string.

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.

PRIVATE SECTION.
ENDCLASS.



CLASS z2ui5_cl_demo_app_288 IMPLEMENTATION.


METHOD display_view.

DATA(page_01) = z2ui5_cl_xml_view=>factory( )->shell(
)->page(
title = `abap2UI5 - Sample: Select`
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.Select/sample/sap.m.sample.Select' ).

DATA(page_02) = page_01->page(
showheader = abap_false
class = `sapUiContentPadding`
)->sub_header(
)->toolbar(
)->toolbar_spacer(
)->select(
forceselection = abap_false
selectedkey = client->_bind( selected_product )
items = client->_bind( lt_product_collection )
)->item( key = '{PRODUCT_ID}' text = '{NAME}'
)->get_parent(
)->get_parent(
)->get_parent(
)->content(
)->hbox( justifyContent = `SpaceAround`
)->select(
enabled = client->_bind( enabled )
editable = client->_bind( editable )
forceselection = abap_false
selectedkey = client->_bind( selected_product2 )
items = client->_bind( lt_product_collection2 )
)->item( key = '{PRODUCT_ID}' text = '{NAME}'
)->get_parent(
)->vbox(
)->hbox( alignitems = `Center`
)->label( text = `Enabled:` class = `sapUiTinyMarginEnd`
)->switch( type = `AcceptReject` state = client->_bind( enabled )
)->get_parent(
)->hbox( alignitems = `Center`
)->label( text = `Editable:` class = `sapUiTinyMarginEnd`
)->switch( type = `AcceptReject` state = client->_bind( editable )
)->get_parent(
)->get_parent(
)->get_parent(
)->get_parent(
)->footer(
)->toolbar(
)->toolbar_spacer(
)->select(
forceselection = abap_false
selectedkey = client->_bind( selected_product3 )
type = `IconOnly`
icon = `sap-icon://filter`
autoadjustwidth = abap_true
items = client->_bind( lt_product_collection3 )
)->item( key = '{PRODUCT_ID}' text = '{NAME}'
).

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` ).
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 = `Illustrates the usage of a Select in header, footer and content of a page. Note the different display options.` ).

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 ).

selected_product = `HT-1001`.
selected_product2 = `HT-1001`.
selected_product3 = `HT-1001`.

" Populate the internal tables
lt_product_collection = VALUE #( ( product_id = 'HT-1000' name = 'Notebook Basic 15' )
( product_id = 'HT-1001' name = 'Notebook Basic 17' )
( product_id = 'HT-1002' name = 'Notebook Basic 18' )
( product_id = 'HT-1003' name = 'Notebook Basic 19' )
( product_id = 'HT-1007' name = 'ITelO Vault' ) ).
SORT lt_product_collection BY name.

lt_product_collection2 = VALUE #( ( product_id = 'HT-1000' name = 'Notebook Basic 15' )
( product_id = 'HT-1001' name = 'Notebook Basic 17' )
( product_id = 'HT-1002' name = 'Notebook Basic 18' )
( product_id = 'HT-1003' name = 'Notebook Basic 19' )
( product_id = 'HT-1007' name = 'ITelO Vault' ) ).
SORT lt_product_collection2 BY name.

lt_product_collection3 = VALUE #( ( product_id = 'HT-1000' name = 'Notebook Basic 15' )
( product_id = 'HT-1001' name = 'Notebook Basic 17' )
( product_id = 'HT-1002' name = 'Notebook Basic 18' )
( product_id = 'HT-1003' name = 'Notebook Basic 19' )
( product_id = 'HT-1007' name = 'ITelO Vault' ) ).
SORT lt_product_collection3 BY name.

editable = abap_true.
enabled = abap_true.

ENDIF.

on_event( client ).

ENDMETHOD.
ENDCLASS.
16 changes: 16 additions & 0 deletions src/z2ui5_cl_demo_app_288.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_288</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Select</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

0 comments on commit 4b6d6f8

Please sign in to comment.