From 42c917fbedf72d15d037defde759bc7e2f4f4976 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Mil=C3=A1n?= <36721657+francisco-milan@users.noreply.github.com> Date: Tue, 8 Oct 2024 00:56:25 -0600 Subject: [PATCH] New Sample: Select - Validation states (#399) --- src/z2ui5_cl_demo_app_000.clas.abap | 8 ++ src/z2ui5_cl_demo_app_295.clas.abap | 24 ++-- src/z2ui5_cl_demo_app_297.clas.abap | 69 +++++---- src/z2ui5_cl_demo_app_298.clas.abap | 208 ++++++++++++++++++++++++++++ src/z2ui5_cl_demo_app_298.clas.xml | 16 +++ 5 files changed, 274 insertions(+), 51 deletions(-) create mode 100644 src/z2ui5_cl_demo_app_298.clas.abap create mode 100644 src/z2ui5_cl_demo_app_298.clas.xml diff --git a/src/z2ui5_cl_demo_app_000.clas.abap b/src/z2ui5_cl_demo_app_000.clas.abap index de1b5219..9419c354 100644 --- a/src/z2ui5_cl_demo_app_000.clas.abap +++ b/src/z2ui5_cl_demo_app_000.clas.abap @@ -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 diff --git a/src/z2ui5_cl_demo_app_295.clas.abap b/src/z2ui5_cl_demo_app_295.clas.abap index c71ab644..288704fe 100644 --- a/src/z2ui5_cl_demo_app_295.clas.abap +++ b/src/z2ui5_cl_demo_app_295.clas.abap @@ -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. diff --git a/src/z2ui5_cl_demo_app_297.clas.abap b/src/z2ui5_cl_demo_app_297.clas.abap index 7d8853ab..3163b053 100644 --- a/src/z2ui5_cl_demo_app_297.clas.abap +++ b/src/z2ui5_cl_demo_app_297.clas.abap @@ -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. @@ -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( @@ -81,7 +80,7 @@ CLASS Z2UI5_CL_DEMO_APP_297 IMPLEMENTATION. ENDMETHOD. - METHOD ON_EVENT. + METHOD on_event. CASE client->get( )-event. WHEN 'BACK'. @@ -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` @@ -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. @@ -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. diff --git a/src/z2ui5_cl_demo_app_298.clas.abap b/src/z2ui5_cl_demo_app_298.clas.abap new file mode 100644 index 00000000..ee7184a1 --- /dev/null +++ b/src/z2ui5_cl_demo_app_298.clas.abap @@ -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. diff --git a/src/z2ui5_cl_demo_app_298.clas.xml b/src/z2ui5_cl_demo_app_298.clas.xml new file mode 100644 index 00000000..9ac2f0f2 --- /dev/null +++ b/src/z2ui5_cl_demo_app_298.clas.xml @@ -0,0 +1,16 @@ + + + + + + Z2UI5_CL_DEMO_APP_298 + E + Select - Validation states + 1 + X + X + X + + + +