Skip to content

Commit

Permalink
New Sample: Select - Validation states (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
francisco-milan authored Oct 8, 2024
1 parent 8d829b2 commit 42c917f
Show file tree
Hide file tree
Showing 5 changed files with 274 additions and 51 deletions.
8 changes: 8 additions & 0 deletions src/z2ui5_cl_demo_app_000.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,14 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel->generic_tile(
header = 'Select'
subheader = 'Validation states'
press = client->_event( 'Z2UI5_CL_DEMO_APP_298' )
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel = page->panel(
expandable = abap_false
expanded = abap_true
Expand Down
24 changes: 8 additions & 16 deletions src/z2ui5_cl_demo_app_295.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,13 @@ CLASS z2ui5_cl_demo_app_295 IMPLEMENTATION.
s_text = 'DateRangeSelection with valueState '.

" Append entries to the internal table
APPEND VALUE #( label = s_text && 'None'
value_state = 'None' ) TO lt_a_data.

APPEND VALUE #( label = s_text && 'Information'
value_state = 'Information' ) TO lt_a_data.

APPEND VALUE #( label = s_text && 'Success'
value_state = 'Success' ) TO lt_a_data.

APPEND VALUE #( label = s_text && 'Warning and long valueStateText'
value_state = 'Warning'
value_state_text = 'Warning message. This is an extra long text used as a warning message. ' &&
'It illustrates how the text wraps into two or more lines without truncation to show the full length of the message.' ) TO lt_a_data.

APPEND VALUE #( label = s_text && 'Error'
value_state = 'Error' ) TO lt_a_data.
lt_a_data = VALUE #(
( label = s_text && 'None' value_state = 'None' )
( label = s_text && 'Information' value_state = 'Information' )
( label = s_text && 'Success' value_state = 'Success' )
( label = s_text && 'Warning and long valueStateText' value_state = 'Warning'
value_state_text = 'Warning message. This is an extra long text used as a warning message. ' &&
'It illustrates how the text wraps into two or more lines without truncation to show the full length of the message.' )
( label = s_text && 'Error' value_state = 'Error' ) ).
ENDMETHOD.
ENDCLASS.
69 changes: 34 additions & 35 deletions src/z2ui5_cl_demo_app_297.clas.abap
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
class Z2UI5_CL_DEMO_APP_297 definition
public
create public .
CLASS z2ui5_cl_demo_app_297 DEFINITION
PUBLIC
CREATE PUBLIC.

public section.
PUBLIC SECTION.

interfaces IF_SERIALIZABLE_OBJECT .
interfaces Z2UI5_IF_APP .
INTERFACES z2ui5_if_app.

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

DATA check_initialized TYPE abap_bool.
DATA lt_product_collection TYPE TABLE OF ty_product_collection.
DATA selected_product TYPE string.

data CHECK_INITIALIZED type ABAP_BOOL .
data:
lt_product_collection TYPE TABLE OF ty_product_collection .
data SELECTED_PRODUCT type STRING .
PROTECTED SECTION.

DATA client TYPE REF TO z2ui5_if_client.
Expand All @@ -38,10 +37,10 @@ ENDCLASS.



CLASS Z2UI5_CL_DEMO_APP_297 IMPLEMENTATION.
CLASS z2ui5_cl_demo_app_297 IMPLEMENTATION.


METHOD DISPLAY_VIEW.
METHOD display_view.

DATA(page_01) = z2ui5_cl_xml_view=>factory( )->shell(
)->page(
Expand Down Expand Up @@ -81,7 +80,7 @@ CLASS Z2UI5_CL_DEMO_APP_297 IMPLEMENTATION.
ENDMETHOD.


METHOD ON_EVENT.
METHOD on_event.

CASE client->get( )-event.
WHEN 'BACK'.
Expand All @@ -93,7 +92,7 @@ CLASS Z2UI5_CL_DEMO_APP_297 IMPLEMENTATION.
ENDMETHOD.


METHOD Z2UI5_DISPLAY_POPOVER.
METHOD z2ui5_display_popover.

DATA(view) = z2ui5_cl_xml_view=>factory_popup( ).
view->quick_view( placement = `Bottom` width = `auto`
Expand All @@ -109,7 +108,7 @@ CLASS Z2UI5_CL_DEMO_APP_297 IMPLEMENTATION.
ENDMETHOD.


METHOD Z2UI5_IF_APP~MAIN.
METHOD z2ui5_if_app~main.

me->client = client.

Expand All @@ -124,27 +123,27 @@ CLASS Z2UI5_CL_DEMO_APP_297 IMPLEMENTATION.
ENDMETHOD.


METHOD Z2UI5_SET_DATA.
METHOD z2ui5_set_data.

CLEAR selected_product.
CLEAR lt_product_collection.

selected_product = `HT-1001`.

" Populate the internal tables
lt_product_collection = VALUE #(
( product_id = 'HT-1001' name = 'Notebook Basic 17' icon = 'sap-icon://paper-plane' )
( product_id = 'HT-1002' name = 'Notebook Basic 18' icon = 'sap-icon://add-document' )
( product_id = 'HT-1003' name = 'Notebook Basic 19' icon = 'sap-icon://doctor' )
( product_id = 'HT-1007' name = 'ITelO Vault' icon = 'sap-icon://sys-find-next')
( product_id = 'HT-1010' name = 'Notebook Professional 15' icon = 'sap-icon://add-product')
( product_id = 'HT-1011' name = 'Notebook Professional 17' icon = 'sap-icon://add-product')
( product_id = 'HT-1020' name = 'ITelO Vault Net' icon = 'sap-icon://add-product' )
( product_id = 'HT-1021' name = 'ITelO Vault SAT' icon = 'sap-icon://add-product' )
( product_id = 'HT-1022' name = 'Comfort Easy' icon = 'sap-icon://add-product' )
( product_id = 'HT-1023' name = 'Comfort Senior' icon = 'sap-icon://add-product' )
).
SORT lt_product_collection BY name.
selected_product = `HT-1001`.

" Populate the internal table
lt_product_collection = VALUE #(
( product_id = 'HT-1001' name = 'Notebook Basic 17' icon = 'sap-icon://paper-plane' )
( product_id = 'HT-1002' name = 'Notebook Basic 18' icon = 'sap-icon://add-document' )
( product_id = 'HT-1003' name = 'Notebook Basic 19' icon = 'sap-icon://doctor' )
( product_id = 'HT-1007' name = 'ITelO Vault' icon = 'sap-icon://sys-find-next')
( product_id = 'HT-1010' name = 'Notebook Professional 15' icon = 'sap-icon://add-product')
( product_id = 'HT-1011' name = 'Notebook Professional 17' icon = 'sap-icon://add-product')
( product_id = 'HT-1020' name = 'ITelO Vault Net' icon = 'sap-icon://add-product' )
( product_id = 'HT-1021' name = 'ITelO Vault SAT' icon = 'sap-icon://add-product' )
( product_id = 'HT-1022' name = 'Comfort Easy' icon = 'sap-icon://add-product' )
( product_id = 'HT-1023' name = 'Comfort Senior' icon = 'sap-icon://add-product' )
).
SORT lt_product_collection BY name.

ENDMETHOD.
ENDCLASS.
208 changes: 208 additions & 0 deletions src/z2ui5_cl_demo_app_298.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
CLASS z2ui5_cl_demo_app_298 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 lt_a_products TYPE TABLE OF ty_product_collection.
DATA selectedproducterrorcollection TYPE string.
DATA selectedproductwrnngcollection TYPE string.
DATA selectedproductsccsscollection TYPE string.
DATA selectedproductinforcollection TYPE string.

PROTECTED SECTION.

DATA client TYPE REF TO z2ui5_if_client.

METHODS z2ui5_set_data.
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_298 IMPLEMENTATION.


METHOD display_view.

DATA(page_01) = z2ui5_cl_xml_view=>factory( )->shell(
)->page(
title = `abap2UI5 - Sample: Select - Validation states`
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://openui5.hana.ondemand.com/entity/sap.m.Select/sample/sap.m.sample.SelectValueState' ).

page_01->page( showheader = abap_false
)->content(
)->hbox( class = `sapUiMediumMarginBottom`
)->label( text = `Error state`
labelfor = `errorSelect`
class = `sapUiTinyMarginEnd sapUiTinyMarginTop`
)->select(
id = `errorSelect`
forceselection = abap_true
selectedkey = client->_bind( selectedproducterrorcollection )
valuestate = `Error`
valuestatetext = `error value state text`
items = client->_bind( lt_a_products )
)->item( key = '{PRODUCT_ID}' text = '{NAME}'
)->get_parent(
)->get_parent(
)->hbox( class = `sapUiMediumMarginBottom`
)->label( text = `Warning state`
labelfor = `warningSelect`
class = `sapUiTinyMarginEnd sapUiTinyMarginTop`
)->select(
id = `warningSelect`
forceselection = abap_true
selectedkey = client->_bind( selectedproductwrnngcollection )
valuestate = `Warning`
valuestatetext = `This is a Level 1 explanation. The items Lorem and Ipsum are not recommended from the system.`
items = client->_bind( lt_a_products )
)->item( key = '{PRODUCT_ID}' text = '{NAME}'
)->get_parent(
)->get_parent(
)->hbox( class = `sapUiMediumMarginBottom`
)->label( text = `Success state`
labelfor = `successSelect`
class = `sapUiTinyMarginEnd sapUiTinyMarginTop`
)->select(
id = `successSelect`
forceselection = abap_true
selectedkey = client->_bind( selectedproductsccsscollection )
valuestate = `Success`
valuestatetext = `success value state text`
items = client->_bind( lt_a_products )
)->item( key = '{PRODUCT_ID}' text = '{NAME}'
)->get_parent(
)->get_parent(
)->hbox( class = `sapUiMediumMarginBottom`
)->label( text = `Information state`
labelfor = `informationSelect`
class = `sapUiTinyMarginEnd sapUiTinyMarginTop`
)->select(
id = `informationSelect`
forceselection = abap_true
selectedkey = client->_bind( selectedproductinforcollection )
valuestate = `Information`
valuestatetext = `information value state text`
items = client->_bind( lt_a_products )
)->item( key = '{PRODUCT_ID}' text = '{NAME}'
)->get_parent(
)->get_parent(
)->get_parent(
).

client->view_display( page_01->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 = `Visualizes the validation state of the control, for example, Error, Warning and Success.` ).

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_set_data( ).
ENDIF.

on_event( client ).

ENDMETHOD.


METHOD z2ui5_set_data.
CLEAR selectedproducterrorcollection.
CLEAR selectedproductwrnngcollection.
CLEAR selectedproductsccsscollection.
CLEAR selectedproductinforcollection.
CLEAR lt_a_products.

selectedproducterrorcollection = `HT-998`.
selectedproductwrnngcollection = `HT-999`.
selectedproductsccsscollection = `HT-1000`.
selectedproductinforcollection = `HT-1007`.

" Populate the internal table
lt_a_products = VALUE #(
( product_id = 'HT-998' name = 'Notebook Basic 11' )
( product_id = 'HT-999' name = 'Notebook Basic 13' )
( 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' )
( product_id = 'HT-1008' name = 'Notebook Professional 11' )
( product_id = 'HT-1009' name = 'Notebook Professional 13' )
( product_id = 'HT-1010' name = 'Notebook Professional 15' )
( product_id = 'HT-1011' name = 'Notebook Professional 17' )
( product_id = 'HT-1012' name = 'Notebook Professional 19' )
( product_id = 'HT-1020' name = 'ITelO Vault Net' )
( product_id = 'HT-1021' name = 'ITelO Vault SAT' )
( product_id = 'HT-1022' name = 'Comfort Easy' )
( product_id = 'HT-1023' name = 'Comfort Senior' )
).
SORT lt_a_products BY name.

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

0 comments on commit 42c917f

Please sign in to comment.