Skip to content

Commit 54d3b36

Browse files
authored
Added Sample: URL Helper (#454)
1 parent ea0c57c commit 54d3b36

File tree

3 files changed

+183
-0
lines changed

3 files changed

+183
-0
lines changed

src/z2ui5_cl_demo_app_000.clas.abap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,13 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
788788
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
789789
).
790790

791+
panel->generic_tile( header = 'URL Helper'
792+
subheader = `Trigger a phone's native apps like Email, Telephone and SMS`
793+
press = client->_event( 'Z2UI5_CL_DEMO_APP_316' )
794+
mode = 'LineMode'
795+
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
796+
).
797+
791798
panel = page->panel( expandable = abap_false
792799
expanded = abap_true
793800
headertext = 'Formatting & Calculations'
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
CLASS z2ui5_cl_demo_app_316 DEFINITION
2+
PUBLIC
3+
CREATE PUBLIC.
4+
5+
PUBLIC SECTION.
6+
INTERFACES if_serializable_object.
7+
INTERFACES z2ui5_if_app.
8+
9+
DATA check_initialized TYPE abap_bool.
10+
11+
DATA phone TYPE string.
12+
DATA mobile TYPE string.
13+
14+
DATA: BEGIN OF email,
15+
email TYPE string,
16+
subject TYPE string,
17+
body TYPE string,
18+
cc TYPE string,
19+
bcc TYPE string,
20+
new_window TYPE string,
21+
END OF email.
22+
23+
DATA: BEGIN OF url,
24+
url TYPE string,
25+
new_window TYPE string,
26+
END OF url.
27+
28+
PROTECTED SECTION.
29+
METHODS display_view
30+
IMPORTING !client TYPE REF TO z2ui5_if_client.
31+
32+
METHODS on_event
33+
IMPORTING !client TYPE REF TO z2ui5_if_client.
34+
35+
PRIVATE SECTION.
36+
37+
ENDCLASS.
38+
39+
40+
CLASS z2ui5_cl_demo_app_316 IMPLEMENTATION.
41+
METHOD display_view.
42+
url = VALUE #( url = `http://www.sap.com`
43+
new_window = `true` ).
44+
email = VALUE #( email = `email@email.com`
45+
subject = `subject`
46+
body = `body`
47+
new_window = `true` ).
48+
49+
DATA(page) = z2ui5_cl_xml_view=>factory(
50+
)->_z2ui5( )->title( `URL Helper Sample`
51+
)->shell(
52+
)->page( title = 'abap2UI5 - Sample: URL Helper'
53+
navbuttonpress = client->_event( 'BACK' )
54+
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL ) ).
55+
56+
DATA(layout) = page->vertical_layout( class = `sapUiContentPadding`
57+
width = `100%` ).
58+
59+
DATA(email_form) = layout->simple_form( title = `Trigger E-Mail` ).
60+
61+
email_form->label( text = `E-Mail`
62+
labelfor = `inputEmail` ).
63+
email_form->input( id = `inputEmail`
64+
value = client->_bind_edit( email-email )
65+
type = `Email`
66+
placeholder = `Enter email`
67+
class = `sapUiSmallMarginBottom` ).
68+
69+
email_form->input( id = `inputCcEmail`
70+
value = client->_bind_edit( email-cc )
71+
type = `Email`
72+
placeholder = `Enter cc email`
73+
class = `sapUiSmallMarginBottom` ).
74+
75+
email_form->input( id = `inputBccEmail`
76+
value = client->_bind_edit( email-bcc )
77+
type = `Email`
78+
placeholder = `Enter bcc email`
79+
class = `sapUiSmallMarginBottom` ).
80+
81+
email_form->label( text = `Subject`
82+
labelfor = `inputText` ).
83+
email_form->input( id = `inputText`
84+
value = client->_bind_edit( email-subject )
85+
placeholder = `Enter text`
86+
class = `sapUiSmallMarginBottom` ).
87+
88+
email_form->label( `Mail Body`
89+
)->text_area( valueliveupdate = abap_true
90+
value = client->_bind_edit( email-body )
91+
growing = abap_true
92+
growingmaxlines = '7'
93+
width = '100%' ).
94+
95+
email_form->button( text = `Trigger Email`
96+
press = client->_event_client( val = client->cs_event-urlhelper
97+
t_arg = VALUE #( ( `TRIGGER_EMAIL` )
98+
( |${ client->_bind_edit( email ) }| ) ) ) ).
99+
100+
DATA(telephone_form) = layout->simple_form( title = `Trigger Telephone` ).
101+
102+
telephone_form->label( text = `Telephone`
103+
labelfor = `inputTel` ).
104+
telephone_form->input( id = `inputTel`
105+
value = client->_bind_edit( phone )
106+
type = `Tel`
107+
placeholder = `Enter telephone number`
108+
class = `sapUiSmallMarginBottom` ).
109+
telephone_form->button(
110+
text = `Trigger Telephone`
111+
press = client->_event_client( val = client->cs_event-urlhelper
112+
t_arg = VALUE #( ( `TRIGGER_TEL` )
113+
( |${ client->_bind_edit( phone ) }| ) ) ) ).
114+
115+
DATA(mobile_form) = layout->simple_form( title = `Trigger SMS` ).
116+
117+
mobile_form->label( text = `Number`
118+
labelfor = `inputNumber` ).
119+
mobile_form->input( id = `inputNumber`
120+
value = client->_bind_edit( mobile )
121+
type = `Number`
122+
placeholder = `Enter a number`
123+
class = `sapUiSmallMarginBottom` ).
124+
mobile_form->button( text = `Trigger SMS`
125+
press = client->_event_client( val = client->cs_event-urlhelper
126+
t_arg = VALUE #( ( `TRIGGER_SMS` )
127+
( |${ client->_bind_edit( mobile ) }| ) ) ) ).
128+
129+
DATA(url_form) = layout->simple_form( title = `Redirect` ).
130+
url_form->label( text = `URL`
131+
labelfor = `inputUrl` ).
132+
url_form->input( id = `inputUrl`
133+
value = client->_bind_edit( url-url )
134+
type = `Url`
135+
placeholder = `Enter URL`
136+
class = `sapUiSmallMarginBottom` ).
137+
url_form->button( text = `Redirect`
138+
press = client->_event_client( val = client->cs_event-urlhelper
139+
t_arg = VALUE #( ( `REDIRECT` )
140+
( |${ client->_bind_edit( url ) }| ) ) ) ).
141+
142+
client->view_display( page->stringify( ) ).
143+
ENDMETHOD.
144+
145+
METHOD on_event.
146+
CASE client->get( )-event.
147+
WHEN 'BACK'.
148+
client->nav_app_leave( ).
149+
ENDCASE.
150+
ENDMETHOD.
151+
152+
METHOD z2ui5_if_app~main.
153+
IF check_initialized = abap_false.
154+
check_initialized = abap_true.
155+
display_view( client ).
156+
ENDIF.
157+
158+
on_event( client ).
159+
ENDMETHOD.
160+
ENDCLASS.

src/z2ui5_cl_demo_app_316.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_316</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>URL Helper</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)