Skip to content

update samples #357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/z2ui5_cl_demo_app_000.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom' ).

panel->generic_tile(
header = 'setSizeLimit'
* subheader = 'Table Cell Level'
press = client->_event( 'z2ui5_cl_demo_app_071' )
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom' ).

panel = page->panel(
expandable = abap_false
Expand Down Expand Up @@ -254,6 +260,13 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel->generic_tile(
header = 'Message III'
subheader = 'Message Box & Events'
press = client->_event( 'z2ui5_cl_demo_app_084' )
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

page = page2->panel(
expandable = abap_true
Expand Down
58 changes: 2 additions & 56 deletions src/z2ui5_cl_demo_app_002.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,8 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION.

IF check_initialized = abap_false.
check_initialized = abap_true.

DATA(lv_script) = `` && |\n| &&
`function setInputFIlter(){` && |\n| &&
` var inp = sap.z2ui5.oView.byId('suggInput');` && |\n| &&
` inp.setFilterFunction(function(sValue, oItem){` && |\n| &&
` var aSplit = sValue.split(" ");` && |\n| &&
` if (aSplit.length > 0) {` && |\n| &&
` var sTermNew = aSplit.slice(-1)[0];` && |\n| &&
` sTermNew.trim();` && |\n| &&
` if (sTermNew) {` && |\n| &&
` return oItem.getText().match(new RegExp(sTermNew, "i"));` && |\n| &&
` }` && |\n| &&
` }` && |\n| &&
` });` && |\n| &&
`}`.


client->view_display( z2ui5_cl_xml_view=>factory(
)->_z2ui5( )->timer( client->_event( `START` )
)->_generic( ns = `html` name = `script` )->_cc_plain_xml( lv_script
)->stringify( ) ).


z2ui5_on_init( ).
z2ui5_on_rendering( ).
RETURN.
ENDIF.

Expand All @@ -95,13 +73,7 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION.
METHOD z2ui5_on_event.

CASE client->get( )-event.
WHEN 'START'.
z2ui5_on_rendering( ).
WHEN 'BUTTON_MCUSTOM'.
* send type = '' is mandatory in order to not break current implementation
client->message_box_display( type = '' text = 'Custom MessageBox' icon = `SUCCESS`
title = 'Custom MessageBox' actions = VALUE #( ( `First Button` ) ( `Second Button` ) ) emphasizedaction = `First Button`
onclose = `callMessageToast()` details = `<h3>these are details</h3>`).

WHEN 'BUTTON_MCONFIRM'.
client->message_box_display( type = 'confirm' text = 'Confirm MessageBox' ).
WHEN 'BUTTON_MALERT'.
Expand Down Expand Up @@ -153,7 +125,6 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION.
METHOD z2ui5_on_rendering.

DATA(view) = z2ui5_cl_xml_view=>factory( ).
* view->_generic( name = `script` ns = `html` )->_cc_plain_xml( `function callMessageToast(sAction) { sap.m.MessageToast.show('Hello there !!'); }` ).
DATA(page) = view->shell(
)->page(
showheader = xsdbool( abap_false = client->get( )-check_launchpad_active )
Expand Down Expand Up @@ -262,28 +233,6 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION.
customtextoff = 'NO' ).

page->footer( )->overflow_toolbar(
)->text( text = `MessageBox Types`
)->button(
text = 'Confirm'
press = client->_event( 'BUTTON_MCONFIRM' )
)->button(
text = 'Alert'
press = client->_event( 'BUTTON_MALERT' )
)->button(
text = 'Error'
press = client->_event( 'BUTTON_MERROR' )
)->button(
text = 'Information'
press = client->_event( 'BUTTON_MINFO' )
)->button(
text = 'Warning'
press = client->_event( 'BUTTON_MWARNING' )
)->button(
text = 'Success'
press = client->_event( 'BUTTON_MSUCCESS' )
)->button(
text = 'Custom'
press = client->_event( 'BUTTON_MCUSTOM' )
)->toolbar_spacer(
)->button(
text = 'Clear'
Expand All @@ -295,9 +244,6 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION.
press = client->_event( 'BUTTON_SEND' )
type = 'Success' ).


view->_generic( name = `script` ns = `html` )->_cc_plain_xml( `setInputFIlter()` ).

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

ENDMETHOD.
Expand Down
222 changes: 222 additions & 0 deletions src/z2ui5_cl_demo_app_084.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
CLASS z2ui5_cl_demo_app_084 DEFINITION PUBLIC.

PUBLIC SECTION.

INTERFACES z2ui5_if_app.

DATA:
BEGIN OF screen,
check_is_active TYPE abap_bool,
colour TYPE string,
combo_key TYPE string,
combo_key2 TYPE string,
segment_key TYPE string,
date TYPE string,
date_time TYPE string,
time_start TYPE string,
time_end TYPE string,
check_switch_01 TYPE abap_bool VALUE abap_false,
check_switch_02 TYPE abap_bool VALUE abap_false,
END OF screen.

TYPES:
BEGIN OF s_suggestion_items,
value TYPE string,
descr TYPE string,
END OF s_suggestion_items.
DATA mt_suggestion TYPE STANDARD TABLE OF s_suggestion_items WITH EMPTY KEY.

TYPES:
BEGIN OF s_combobox,
key TYPE string,
text TYPE string,
END OF s_combobox.

TYPES ty_t_combo TYPE STANDARD TABLE OF s_combobox WITH EMPTY KEY.



DATA check_initialized TYPE abap_bool.

DATA client TYPE REF TO z2ui5_if_client.

PROTECTED SECTION.

METHODS z2ui5_on_rendering.
METHODS z2ui5_on_event.
METHODS z2ui5_on_init.

PRIVATE SECTION.
ENDCLASS.



CLASS z2ui5_cl_demo_app_084 IMPLEMENTATION.


METHOD z2ui5_if_app~main.

me->client = client.

IF check_initialized = abap_false.
check_initialized = abap_true.

DATA(lv_script) = `` && |\n| &&
`function setInputFIlter(){` && |\n| &&
` var inp = sap.z2ui5.oView.byId('suggInput');` && |\n| &&
` inp.setFilterFunction(function(sValue, oItem){` && |\n| &&
` var aSplit = sValue.split(" ");` && |\n| &&
` if (aSplit.length > 0) {` && |\n| &&
` var sTermNew = aSplit.slice(-1)[0];` && |\n| &&
` sTermNew.trim();` && |\n| &&
` if (sTermNew) {` && |\n| &&
` return oItem.getText().match(new RegExp(sTermNew, "i"));` && |\n| &&
` }` && |\n| &&
` }` && |\n| &&
` });` && |\n| &&
`}`.


client->view_display( z2ui5_cl_xml_view=>factory(
)->_z2ui5( )->timer( client->_event( `START` )
)->_generic( ns = `html` name = `script` )->_cc_plain_xml( lv_script
)->stringify( ) ).


z2ui5_on_init( ).
RETURN.
ENDIF.

z2ui5_on_event( ).

ENDMETHOD.


METHOD z2ui5_on_event.

CASE client->get( )-event.
WHEN 'START'.
z2ui5_on_rendering( ).
WHEN 'BUTTON_MCUSTOM'.
* send type = '' is mandatory in order to not break current implementation
client->message_box_display( type = '' text = 'Custom MessageBox' icon = `SUCCESS`
title = 'Custom MessageBox' actions = VALUE #( ( `First Button` ) ( `Second Button` ) ) emphasizedaction = `First Button`
onclose = `callMessageToast()` details = `<h3>these are details</h3>`).
WHEN 'BUTTON_MCONFIRM'.
client->message_box_display( type = 'confirm' text = 'Confirm MessageBox' ).
WHEN 'BUTTON_MALERT'.
client->message_box_display( type = 'alert' text = 'Alert MessageBox' ).
WHEN 'BUTTON_MERROR'.
client->message_box_display( type = 'error' text = 'Error MessageBox' ).
WHEN 'BUTTON_MINFO'.
client->message_box_display( type = 'information' text = 'Information MessageBox' ).
WHEN 'BUTTON_MWARNING'.
client->message_box_display( type = 'warning' text = 'Warning MessageBox' ).
WHEN 'BUTTON_MSUCCESS'.
client->message_box_display( type = 'success' text = 'Success MessageBox' icon = `sap-icon://accept` ).
WHEN 'BUTTON_SEND'.
client->message_box_display( 'success - values send to the server' ).
WHEN 'BUTTON_CLEAR'.
CLEAR screen.
client->message_toast_display( 'View initialized' ).
WHEN 'BACK'.
client->nav_app_leave( ).

ENDCASE.

ENDMETHOD.


METHOD z2ui5_on_init.

screen = VALUE #(
check_is_active = abap_true
colour = 'BLUE'
combo_key = 'GRAY'
segment_key = 'GREEN'
date = '07.12.22'
date_time = '23.12.2022, 19:27:20'
time_start = '05:24:00'
time_end = '17:23:57').

mt_suggestion = VALUE #(
( descr = 'Green' value = 'GREEN' )
( descr = 'Blue' value = 'BLUE' )
( descr = 'Black' value = 'BLACK' )
( descr = 'Gray' value = 'GRAY' )
( descr = 'Blue2' value = 'BLUE2' )
( descr = 'Blue3' value = 'BLUE3' ) ).

ENDMETHOD.


METHOD z2ui5_on_rendering.

DATA(view) = z2ui5_cl_xml_view=>factory( ).
view->_generic( name = `script` ns = `html` )->_cc_plain_xml( `function callMessageToast(sAction) { sap.m.MessageToast.show('Hello there !!'); }` ).
DATA(page) = view->shell(
)->page(
showheader = xsdbool( abap_false = client->get( )-check_launchpad_active )
title = 'abap2UI5 - Selection-Screen Example'
navbuttonpress = client->_event( 'BACK' )
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL )
).

DATA(grid) = page->grid( 'L6 M12 S12'
)->content( 'layout' ).

grid->simple_form( title = 'Input' editable = abap_true
)->content( 'form'
)->label( 'Input with suggestion items'
)->input(
id = `suggInput`
value = client->_bind_edit( screen-colour )
placeholder = 'Fill in your favorite color'
suggestionitems = client->_bind( mt_suggestion )
showsuggestion = abap_true )->get(
)->suggestion_items( )->get(
)->list_item(
text = '{VALUE}'
additionaltext = '{DESCR}' ).

page->footer( )->overflow_toolbar(
)->text( text = `MessageBox Types`
)->button(
text = 'Confirm'
press = client->_event( 'BUTTON_MCONFIRM' )
)->button(
text = 'Alert'
press = client->_event( 'BUTTON_MALERT' )
)->button(
text = 'Error'
press = client->_event( 'BUTTON_MERROR' )
)->button(
text = 'Information'
press = client->_event( 'BUTTON_MINFO' )
)->button(
text = 'Warning'
press = client->_event( 'BUTTON_MWARNING' )
)->button(
text = 'Success'
press = client->_event( 'BUTTON_MSUCCESS' )
)->button(
text = 'Custom'
press = client->_event( 'BUTTON_MCUSTOM' )
)->toolbar_spacer(
)->button(
text = 'Clear'
press = client->_event( 'BUTTON_CLEAR' )
type = 'Reject'
icon = 'sap-icon://delete'
)->button(
text = 'Send to Server'
press = client->_event( 'BUTTON_SEND' )
type = 'Success' ).


view->_generic( name = `script` ns = `html` )->_cc_plain_xml( `setInputFIlter()` ).

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

ENDMETHOD.
ENDCLASS.
16 changes: 16 additions & 0 deletions src/z2ui5_cl_demo_app_084.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_084</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Message Box &amp; Input Functions</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>