Skip to content

Commit 8d3c220

Browse files
authored
demo 181 - cards (#142)
1 parent 9331639 commit 8d3c220

File tree

2 files changed

+167
-0
lines changed

2 files changed

+167
-0
lines changed
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
CLASS z2ui5_cl_demo_app_181 DEFINITION
2+
PUBLIC
3+
CREATE PUBLIC .
4+
5+
PUBLIC SECTION.
6+
7+
INTERFACES if_serializable_object .
8+
INTERFACES z2ui5_if_app .
9+
10+
DATA mv_initialized TYPE abap_bool .
11+
DATA mv_url TYPE string .
12+
13+
TYPES:
14+
BEGIN OF ty_cities,
15+
text TYPE string,
16+
key TYPE string,
17+
END OF ty_cities.
18+
19+
TYPES t_cities TYPE STANDARD TABLE OF ty_cities WITH DEFAULT KEY.
20+
21+
TYPES:
22+
BEGIN OF ty_product_items,
23+
title TYPE string,
24+
subtitle TYPE string,
25+
revenue TYPE string,
26+
status TYPE string,
27+
status_schema TYPE string,
28+
END OF ty_product_items.
29+
30+
TYPES t_product_items TYPE STANDARD TABLE OF ty_product_items WITH DEFAULT KEY.
31+
32+
33+
METHODS on_event .
34+
METHODS view_display .
35+
PROTECTED SECTION.
36+
37+
DATA client TYPE REF TO z2ui5_if_client.
38+
39+
PRIVATE SECTION.
40+
ENDCLASS.
41+
42+
43+
44+
CLASS Z2UI5_CL_DEMO_APP_181 IMPLEMENTATION.
45+
46+
47+
METHOD on_event.
48+
49+
CASE client->get( )-event.
50+
WHEN 'BOOK'.
51+
client->message_toast_display( 'BOOKED !!! ENJOY' ).
52+
53+
WHEN 'BACK'.
54+
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).
55+
RETURN.
56+
ENDCASE.
57+
58+
ENDMETHOD.
59+
60+
61+
METHOD view_display.
62+
63+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
64+
65+
DATA(card_1) = view->card( width = `300px` class = `sapUiMediumMargin`
66+
)->header( ns = `f`
67+
)->card_header( title = `Buy bus ticket on-line`
68+
subtitle = `Buy a single-ride ticket for a date`
69+
iconsrc = `sap-icon://bus-public-transport`
70+
)->get_parent( )->get_parent(
71+
)->content( ns = `f`
72+
)->vbox( height = `110px`
73+
class = `sapUiSmallMargin`
74+
justifycontent = `SpaceBetween`
75+
)->hbox( justifycontent = `SpaceBetween`
76+
)->combobox( width = `120px`
77+
placeholder = `From City`
78+
items = `{path:'` && client->_bind_local( val = VALUE t_cities( ( text = `Berlin` key = `BR` )
79+
( text = `London` key = `LN` )
80+
( text = `Madrid` key = `MD` )
81+
( text = `Prague` key = `PR` )
82+
( text = `Paris` key = `PS` )
83+
( text = `Sofia` key = `SF` )
84+
( text = `Vienna` key = `VN` )
85+
) path = abap_true ) && `', sorter: { path: 'TEXT' } }`
86+
)->get( )->item( key = `{KEY}` text = `{TEXT}` )->get_parent(
87+
)->combobox( width = `120px`
88+
placeholder = `To City`
89+
items = `{path:'` && client->_bind_local( val = VALUE t_cities( ( text = `Berlin` key = `BR` )
90+
( text = `London` key = `LN` )
91+
( text = `Madrid` key = `MD` )
92+
( text = `Prague` key = `PR` )
93+
( text = `Paris` key = `PS` )
94+
( text = `Sofia` key = `SF` )
95+
( text = `Vienna` key = `VN` )
96+
) path = abap_true ) && `', sorter: { path: 'TEXT' } }`
97+
)->get( )->item( key = `{KEY}` text = `{TEXT}` )->get_parent(
98+
)->get_parent(
99+
)->hbox( rendertype = `Bare` justifycontent = `SpaceBetween`
100+
)->date_picker( width = `200px`
101+
placeholder = `Choose Date ...`
102+
)->button( text = `Book`
103+
type = `Emphasized`
104+
press = client->_event( `BOOK` )
105+
class = `sapUiTinyMarginBegin` ).
106+
107+
108+
DATA(card_2) = view->card( width = `300px` class = `sapUiMediumMargin`
109+
)->header( ns = `f`
110+
)->card_header( title = `Project Cloud Transformation`
111+
subtitle = `Revenue per Product | EUR`
112+
)->get_parent( )->get_parent(
113+
)->content( ns = `f`
114+
)->list( class = `sapUiSmallMarginBottom`
115+
showseparators = `None`
116+
items = client->_bind_local( VALUE t_product_items( ( title = `Notebook HT` subtitle = `ID23452256-D44` revenue = `27.25K EUR` status = `success` status_schema = `Success` )
117+
( title = `Notebook XT` subtitle = `ID27852256-D47` revenue = `7.35K EUR` status = `exceeded` status_schema = `Error` )
118+
( title = `Notebook ST` subtitle = `ID123555587-I05` revenue = `22.89K EUR` status = `warning` status_schema = `Warning` )
119+
120+
) )
121+
)->custom_list_item(
122+
)->hbox( alignitems = `Center` justifycontent = `SpaceBetween`
123+
)->vbox( class = `sapUiSmallMarginBegin sapUiSmallMarginTopBottom`
124+
)->title( level = `H4` text = `{TITLE}`
125+
)->text( text = `{SUBTITLE}`
126+
)->get_parent(
127+
)->object_status( class = `sapUiTinyMargin sapUiSmallMarginEnd`
128+
text = `{REVENUE}`
129+
state = `{STATUS_SCHEMA}`
130+
).
131+
132+
client->view_display( view->stringify( ) ).
133+
134+
ENDMETHOD.
135+
136+
137+
METHOD z2ui5_if_app~main.
138+
139+
me->client = client.
140+
141+
IF mv_initialized = abap_false.
142+
mv_initialized = abap_true.
143+
144+
view_display( ).
145+
146+
ENDIF.
147+
148+
on_event( ).
149+
150+
ENDMETHOD.
151+
ENDCLASS.

src/z2ui5_cl_demo_app_181.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_181</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>cards demo</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)