Skip to content

Commit 9af2e59

Browse files
oblomov-devchristianguenter2abaplint[bot]
authored
Data loss feature (#344)
* New example data loss protection (#342) * New example data loss protection fixup rename * Update src/z2ui5_cl_demo_app_279.clas.abap Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * cleanup * fixup --------- Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com> * data loss sample update * improve example with regular binding (#343) * improve example * update binding * cleanup --------- Co-authored-by: Christian Günter <[email protected]> Co-authored-by: abaplint[bot] <24845621+abaplint[bot]@users.noreply.github.com>
1 parent 6ce3c58 commit 9af2e59

File tree

3 files changed

+156
-0
lines changed

3 files changed

+156
-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
@@ -227,6 +227,13 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
227227
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
228228
).
229229

230+
panel->generic_tile(
231+
header = `Data Loss Protection`
232+
press = client->_event( 'z2ui5_cl_demo_app_279' )
233+
mode = 'LineMode'
234+
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
235+
).
236+
230237
panel = page->panel(
231238
expandable = abap_false
232239
expanded = abap_true
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
CLASS z2ui5_cl_demo_app_279 DEFINITION
2+
PUBLIC
3+
FINAL
4+
CREATE PUBLIC .
5+
6+
PUBLIC SECTION.
7+
8+
INTERFACES if_serializable_object .
9+
INTERFACES z2ui5_if_app .
10+
11+
DATA text_input TYPE string .
12+
DATA dirty TYPE abap_bool.
13+
14+
PRIVATE SECTION.
15+
DATA client TYPE REF TO z2ui5_if_client.
16+
DATA initialized TYPE abap_bool.
17+
18+
METHODS display_view.
19+
METHODS on_event.
20+
METHODS render_popup.
21+
22+
ENDCLASS.
23+
24+
25+
26+
CLASS z2ui5_cl_demo_app_279 IMPLEMENTATION.
27+
28+
29+
METHOD display_view.
30+
31+
DATA(page) = z2ui5_cl_xml_view=>factory(
32+
)->shell(
33+
)->page(
34+
title = 'abap2UI5 - data loss protection'
35+
navbuttonpress = client->_event( 'BACK' )
36+
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL ) ).
37+
38+
DATA(box) = page->flex_box( direction = `Row` alignitems = `Start` class = 'sapUiTinyMargin' ).
39+
40+
box->input(
41+
id = `input`
42+
value = client->_bind_edit( text_input )
43+
submit = client->_event( 'submit' )
44+
width = `40rem`
45+
placeholder = `Enter data, submit and navigate back to trigger data loss protection` ).
46+
47+
box->info_label(
48+
text = 'dirty'
49+
colorscheme = '8'
50+
icon = 'sap-icon://message-success'
51+
class = `sapUiSmallMarginBegin sapUiTinyMarginTop`
52+
visible = client->_bind( dirty ) ).
53+
54+
box->button(
55+
text = 'Reset'
56+
press = client->_event( 'reset' )
57+
class = `sapUiSmallMarginBegin`
58+
visible = client->_bind( dirty ) ).
59+
60+
page->_z2ui5( )->focus( focusid = `input` ).
61+
62+
* page->_z2ui5( )->dirty( dirty ).
63+
page->_z2ui5( )->dirty( client->_bind( dirty ) ).
64+
* page->_z2ui5( )->dirty( '{= $' && client->_bind_Edit( text_input ) && ' !== "" }' ).
65+
66+
client->view_display( page->stringify( ) ).
67+
68+
ENDMETHOD.
69+
70+
71+
METHOD on_event.
72+
73+
CASE client->get( )-event.
74+
WHEN 'BACK'.
75+
IF text_input IS NOT INITIAL.
76+
render_popup( ).
77+
ELSE.
78+
client->nav_app_leave( ).
79+
ENDIF.
80+
WHEN 'submit'.
81+
dirty = xsdbool( text_input IS NOT INITIAL ).
82+
WHEN 'reset'.
83+
CLEAR:
84+
dirty,
85+
text_input.
86+
WHEN 'popup_decide_cancel'.
87+
CLEAR: dirty.
88+
client->popup_destroy( ).
89+
client->nav_app_leave( ).
90+
WHEN 'popup_decide_continue'.
91+
client->popup_destroy( ).
92+
ENDCASE.
93+
94+
ENDMETHOD.
95+
96+
97+
METHOD render_popup.
98+
99+
DATA(popup) = z2ui5_cl_xml_view=>factory_popup( ).
100+
popup->dialog( title = 'Warning' icon = 'sap-icon://status-critical'
101+
)->vbox(
102+
)->text( text = 'Your entries will be lost when you leave this page.'
103+
class ='sapUiSmallMargin'
104+
)->get_parent(
105+
)->buttons(
106+
)->button(
107+
text = 'Leave Page'
108+
type = 'Emphasized'
109+
press = client->_event( 'popup_decide_cancel' )
110+
)->button(
111+
text = 'Cancel'
112+
press = client->_event( 'popup_decide_continue' ) ).
113+
114+
client->popup_display( popup->stringify( ) ).
115+
116+
ENDMETHOD.
117+
118+
119+
METHOD z2ui5_if_app~main.
120+
121+
me->client = client.
122+
123+
on_event( ).
124+
125+
IF initialized = abap_false.
126+
initialized = abap_true.
127+
display_view( ).
128+
ELSE.
129+
client->view_model_update( ).
130+
ENDIF.
131+
132+
ENDMETHOD.
133+
ENDCLASS.

src/z2ui5_cl_demo_app_279.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_279</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>Data loss protection</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)