Skip to content

Commit 5ea7bc0

Browse files
authored
update samples (#357)
1 parent efff523 commit 5ea7bc0

File tree

4 files changed

+253
-56
lines changed

4 files changed

+253
-56
lines changed

src/z2ui5_cl_demo_app_000.clas.abap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
120120
mode = 'LineMode'
121121
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom' ).
122122

123+
panel->generic_tile(
124+
header = 'setSizeLimit'
125+
* subheader = 'Table Cell Level'
126+
press = client->_event( 'z2ui5_cl_demo_app_071' )
127+
mode = 'LineMode'
128+
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom' ).
123129

124130
panel = page->panel(
125131
expandable = abap_false
@@ -254,6 +260,13 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
254260
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
255261
).
256262

263+
panel->generic_tile(
264+
header = 'Message III'
265+
subheader = 'Message Box & Events'
266+
press = client->_event( 'z2ui5_cl_demo_app_084' )
267+
mode = 'LineMode'
268+
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
269+
).
257270

258271
page = page2->panel(
259272
expandable = abap_true

src/z2ui5_cl_demo_app_002.clas.abap

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -60,30 +60,8 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION.
6060

6161
IF check_initialized = abap_false.
6262
check_initialized = abap_true.
63-
64-
DATA(lv_script) = `` && |\n| &&
65-
`function setInputFIlter(){` && |\n| &&
66-
` var inp = sap.z2ui5.oView.byId('suggInput');` && |\n| &&
67-
` inp.setFilterFunction(function(sValue, oItem){` && |\n| &&
68-
` var aSplit = sValue.split(" ");` && |\n| &&
69-
` if (aSplit.length > 0) {` && |\n| &&
70-
` var sTermNew = aSplit.slice(-1)[0];` && |\n| &&
71-
` sTermNew.trim();` && |\n| &&
72-
` if (sTermNew) {` && |\n| &&
73-
` return oItem.getText().match(new RegExp(sTermNew, "i"));` && |\n| &&
74-
` }` && |\n| &&
75-
` }` && |\n| &&
76-
` });` && |\n| &&
77-
`}`.
78-
79-
80-
client->view_display( z2ui5_cl_xml_view=>factory(
81-
)->_z2ui5( )->timer( client->_event( `START` )
82-
)->_generic( ns = `html` name = `script` )->_cc_plain_xml( lv_script
83-
)->stringify( ) ).
84-
85-
8663
z2ui5_on_init( ).
64+
z2ui5_on_rendering( ).
8765
RETURN.
8866
ENDIF.
8967

@@ -95,13 +73,7 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION.
9573
METHOD z2ui5_on_event.
9674

9775
CASE client->get( )-event.
98-
WHEN 'START'.
99-
z2ui5_on_rendering( ).
100-
WHEN 'BUTTON_MCUSTOM'.
101-
* send type = '' is mandatory in order to not break current implementation
102-
client->message_box_display( type = '' text = 'Custom MessageBox' icon = `SUCCESS`
103-
title = 'Custom MessageBox' actions = VALUE #( ( `First Button` ) ( `Second Button` ) ) emphasizedaction = `First Button`
104-
onclose = `callMessageToast()` details = `<h3>these are details</h3>`).
76+
10577
WHEN 'BUTTON_MCONFIRM'.
10678
client->message_box_display( type = 'confirm' text = 'Confirm MessageBox' ).
10779
WHEN 'BUTTON_MALERT'.
@@ -153,7 +125,6 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION.
153125
METHOD z2ui5_on_rendering.
154126

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

264235
page->footer( )->overflow_toolbar(
265-
)->text( text = `MessageBox Types`
266-
)->button(
267-
text = 'Confirm'
268-
press = client->_event( 'BUTTON_MCONFIRM' )
269-
)->button(
270-
text = 'Alert'
271-
press = client->_event( 'BUTTON_MALERT' )
272-
)->button(
273-
text = 'Error'
274-
press = client->_event( 'BUTTON_MERROR' )
275-
)->button(
276-
text = 'Information'
277-
press = client->_event( 'BUTTON_MINFO' )
278-
)->button(
279-
text = 'Warning'
280-
press = client->_event( 'BUTTON_MWARNING' )
281-
)->button(
282-
text = 'Success'
283-
press = client->_event( 'BUTTON_MSUCCESS' )
284-
)->button(
285-
text = 'Custom'
286-
press = client->_event( 'BUTTON_MCUSTOM' )
287236
)->toolbar_spacer(
288237
)->button(
289238
text = 'Clear'
@@ -295,9 +244,6 @@ CLASS z2ui5_cl_demo_app_002 IMPLEMENTATION.
295244
press = client->_event( 'BUTTON_SEND' )
296245
type = 'Success' ).
297246

298-
299-
view->_generic( name = `script` ns = `html` )->_cc_plain_xml( `setInputFIlter()` ).
300-
301247
client->view_display( page->stringify( ) ).
302248

303249
ENDMETHOD.
Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
CLASS z2ui5_cl_demo_app_084 DEFINITION PUBLIC.
2+
3+
PUBLIC SECTION.
4+
5+
INTERFACES z2ui5_if_app.
6+
7+
DATA:
8+
BEGIN OF screen,
9+
check_is_active TYPE abap_bool,
10+
colour TYPE string,
11+
combo_key TYPE string,
12+
combo_key2 TYPE string,
13+
segment_key TYPE string,
14+
date TYPE string,
15+
date_time TYPE string,
16+
time_start TYPE string,
17+
time_end TYPE string,
18+
check_switch_01 TYPE abap_bool VALUE abap_false,
19+
check_switch_02 TYPE abap_bool VALUE abap_false,
20+
END OF screen.
21+
22+
TYPES:
23+
BEGIN OF s_suggestion_items,
24+
value TYPE string,
25+
descr TYPE string,
26+
END OF s_suggestion_items.
27+
DATA mt_suggestion TYPE STANDARD TABLE OF s_suggestion_items WITH EMPTY KEY.
28+
29+
TYPES:
30+
BEGIN OF s_combobox,
31+
key TYPE string,
32+
text TYPE string,
33+
END OF s_combobox.
34+
35+
TYPES ty_t_combo TYPE STANDARD TABLE OF s_combobox WITH EMPTY KEY.
36+
37+
38+
39+
DATA check_initialized TYPE abap_bool.
40+
41+
DATA client TYPE REF TO z2ui5_if_client.
42+
43+
PROTECTED SECTION.
44+
45+
METHODS z2ui5_on_rendering.
46+
METHODS z2ui5_on_event.
47+
METHODS z2ui5_on_init.
48+
49+
PRIVATE SECTION.
50+
ENDCLASS.
51+
52+
53+
54+
CLASS z2ui5_cl_demo_app_084 IMPLEMENTATION.
55+
56+
57+
METHOD z2ui5_if_app~main.
58+
59+
me->client = client.
60+
61+
IF check_initialized = abap_false.
62+
check_initialized = abap_true.
63+
64+
DATA(lv_script) = `` && |\n| &&
65+
`function setInputFIlter(){` && |\n| &&
66+
` var inp = sap.z2ui5.oView.byId('suggInput');` && |\n| &&
67+
` inp.setFilterFunction(function(sValue, oItem){` && |\n| &&
68+
` var aSplit = sValue.split(" ");` && |\n| &&
69+
` if (aSplit.length > 0) {` && |\n| &&
70+
` var sTermNew = aSplit.slice(-1)[0];` && |\n| &&
71+
` sTermNew.trim();` && |\n| &&
72+
` if (sTermNew) {` && |\n| &&
73+
` return oItem.getText().match(new RegExp(sTermNew, "i"));` && |\n| &&
74+
` }` && |\n| &&
75+
` }` && |\n| &&
76+
` });` && |\n| &&
77+
`}`.
78+
79+
80+
client->view_display( z2ui5_cl_xml_view=>factory(
81+
)->_z2ui5( )->timer( client->_event( `START` )
82+
)->_generic( ns = `html` name = `script` )->_cc_plain_xml( lv_script
83+
)->stringify( ) ).
84+
85+
86+
z2ui5_on_init( ).
87+
RETURN.
88+
ENDIF.
89+
90+
z2ui5_on_event( ).
91+
92+
ENDMETHOD.
93+
94+
95+
METHOD z2ui5_on_event.
96+
97+
CASE client->get( )-event.
98+
WHEN 'START'.
99+
z2ui5_on_rendering( ).
100+
WHEN 'BUTTON_MCUSTOM'.
101+
* send type = '' is mandatory in order to not break current implementation
102+
client->message_box_display( type = '' text = 'Custom MessageBox' icon = `SUCCESS`
103+
title = 'Custom MessageBox' actions = VALUE #( ( `First Button` ) ( `Second Button` ) ) emphasizedaction = `First Button`
104+
onclose = `callMessageToast()` details = `<h3>these are details</h3>`).
105+
WHEN 'BUTTON_MCONFIRM'.
106+
client->message_box_display( type = 'confirm' text = 'Confirm MessageBox' ).
107+
WHEN 'BUTTON_MALERT'.
108+
client->message_box_display( type = 'alert' text = 'Alert MessageBox' ).
109+
WHEN 'BUTTON_MERROR'.
110+
client->message_box_display( type = 'error' text = 'Error MessageBox' ).
111+
WHEN 'BUTTON_MINFO'.
112+
client->message_box_display( type = 'information' text = 'Information MessageBox' ).
113+
WHEN 'BUTTON_MWARNING'.
114+
client->message_box_display( type = 'warning' text = 'Warning MessageBox' ).
115+
WHEN 'BUTTON_MSUCCESS'.
116+
client->message_box_display( type = 'success' text = 'Success MessageBox' icon = `sap-icon://accept` ).
117+
WHEN 'BUTTON_SEND'.
118+
client->message_box_display( 'success - values send to the server' ).
119+
WHEN 'BUTTON_CLEAR'.
120+
CLEAR screen.
121+
client->message_toast_display( 'View initialized' ).
122+
WHEN 'BACK'.
123+
client->nav_app_leave( ).
124+
125+
ENDCASE.
126+
127+
ENDMETHOD.
128+
129+
130+
METHOD z2ui5_on_init.
131+
132+
screen = VALUE #(
133+
check_is_active = abap_true
134+
colour = 'BLUE'
135+
combo_key = 'GRAY'
136+
segment_key = 'GREEN'
137+
date = '07.12.22'
138+
date_time = '23.12.2022, 19:27:20'
139+
time_start = '05:24:00'
140+
time_end = '17:23:57').
141+
142+
mt_suggestion = VALUE #(
143+
( descr = 'Green' value = 'GREEN' )
144+
( descr = 'Blue' value = 'BLUE' )
145+
( descr = 'Black' value = 'BLACK' )
146+
( descr = 'Gray' value = 'GRAY' )
147+
( descr = 'Blue2' value = 'BLUE2' )
148+
( descr = 'Blue3' value = 'BLUE3' ) ).
149+
150+
ENDMETHOD.
151+
152+
153+
METHOD z2ui5_on_rendering.
154+
155+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
156+
view->_generic( name = `script` ns = `html` )->_cc_plain_xml( `function callMessageToast(sAction) { sap.m.MessageToast.show('Hello there !!'); }` ).
157+
DATA(page) = view->shell(
158+
)->page(
159+
showheader = xsdbool( abap_false = client->get( )-check_launchpad_active )
160+
title = 'abap2UI5 - Selection-Screen Example'
161+
navbuttonpress = client->_event( 'BACK' )
162+
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL )
163+
).
164+
165+
DATA(grid) = page->grid( 'L6 M12 S12'
166+
)->content( 'layout' ).
167+
168+
grid->simple_form( title = 'Input' editable = abap_true
169+
)->content( 'form'
170+
)->label( 'Input with suggestion items'
171+
)->input(
172+
id = `suggInput`
173+
value = client->_bind_edit( screen-colour )
174+
placeholder = 'Fill in your favorite color'
175+
suggestionitems = client->_bind( mt_suggestion )
176+
showsuggestion = abap_true )->get(
177+
)->suggestion_items( )->get(
178+
)->list_item(
179+
text = '{VALUE}'
180+
additionaltext = '{DESCR}' ).
181+
182+
page->footer( )->overflow_toolbar(
183+
)->text( text = `MessageBox Types`
184+
)->button(
185+
text = 'Confirm'
186+
press = client->_event( 'BUTTON_MCONFIRM' )
187+
)->button(
188+
text = 'Alert'
189+
press = client->_event( 'BUTTON_MALERT' )
190+
)->button(
191+
text = 'Error'
192+
press = client->_event( 'BUTTON_MERROR' )
193+
)->button(
194+
text = 'Information'
195+
press = client->_event( 'BUTTON_MINFO' )
196+
)->button(
197+
text = 'Warning'
198+
press = client->_event( 'BUTTON_MWARNING' )
199+
)->button(
200+
text = 'Success'
201+
press = client->_event( 'BUTTON_MSUCCESS' )
202+
)->button(
203+
text = 'Custom'
204+
press = client->_event( 'BUTTON_MCUSTOM' )
205+
)->toolbar_spacer(
206+
)->button(
207+
text = 'Clear'
208+
press = client->_event( 'BUTTON_CLEAR' )
209+
type = 'Reject'
210+
icon = 'sap-icon://delete'
211+
)->button(
212+
text = 'Send to Server'
213+
press = client->_event( 'BUTTON_SEND' )
214+
type = 'Success' ).
215+
216+
217+
view->_generic( name = `script` ns = `html` )->_cc_plain_xml( `setInputFIlter()` ).
218+
219+
client->view_display( page->stringify( ) ).
220+
221+
ENDMETHOD.
222+
ENDCLASS.

src/z2ui5_cl_demo_app_084.clas.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
3+
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
4+
<asx:values>
5+
<VSEOCLASS>
6+
<CLSNAME>Z2UI5_CL_DEMO_APP_084</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>Message Box &amp; Input Functions</DESCRIPT>
9+
<STATE>1</STATE>
10+
<CLSCCINCL>X</CLSCCINCL>
11+
<FIXPT>X</FIXPT>
12+
<UNICODE>X</UNICODE>
13+
</VSEOCLASS>
14+
</asx:values>
15+
</asx:abap>
16+
</abapGit>

0 commit comments

Comments
 (0)