Skip to content
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

Data loss feature #344

Merged
merged 3 commits into from
Aug 31, 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
7 changes: 7 additions & 0 deletions src/z2ui5_cl_demo_app_000.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,13 @@ CLASS z2ui5_cl_demo_app_000 IMPLEMENTATION.
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel->generic_tile(
header = `Data Loss Protection`
press = client->_event( 'z2ui5_cl_demo_app_279' )
mode = 'LineMode'
class = 'sapUiTinyMarginEnd sapUiTinyMarginBottom'
).

panel = page->panel(
expandable = abap_false
expanded = abap_true
Expand Down
133 changes: 133 additions & 0 deletions src/z2ui5_cl_demo_app_279.clas.abap
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
CLASS z2ui5_cl_demo_app_279 DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES if_serializable_object .
INTERFACES z2ui5_if_app .

DATA text_input TYPE string .
DATA dirty TYPE abap_bool.

PRIVATE SECTION.
DATA client TYPE REF TO z2ui5_if_client.
DATA initialized TYPE abap_bool.

METHODS display_view.
METHODS on_event.
METHODS render_popup.

ENDCLASS.



CLASS z2ui5_cl_demo_app_279 IMPLEMENTATION.


METHOD display_view.

DATA(page) = z2ui5_cl_xml_view=>factory(
)->shell(
)->page(
title = 'abap2UI5 - data loss protection'
navbuttonpress = client->_event( 'BACK' )
shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL ) ).

DATA(box) = page->flex_box( direction = `Row` alignitems = `Start` class = 'sapUiTinyMargin' ).

box->input(
id = `input`
value = client->_bind_edit( text_input )
submit = client->_event( 'submit' )
width = `40rem`
placeholder = `Enter data, submit and navigate back to trigger data loss protection` ).

box->info_label(
text = 'dirty'
colorscheme = '8'
icon = 'sap-icon://message-success'
class = `sapUiSmallMarginBegin sapUiTinyMarginTop`
visible = client->_bind( dirty ) ).

box->button(
text = 'Reset'
press = client->_event( 'reset' )
class = `sapUiSmallMarginBegin`
visible = client->_bind( dirty ) ).

page->_z2ui5( )->focus( focusid = `input` ).

* page->_z2ui5( )->dirty( dirty ).
page->_z2ui5( )->dirty( client->_bind( dirty ) ).

Check failure on line 63 in src/z2ui5_cl_demo_app_279.clas.abap

View check run for this annotation

abaplint / abaplint

Method "dirty" not found, methodCallChain

https://rules.abaplint.org/check_syntax
* page->_z2ui5( )->dirty( '{= $' && client->_bind_Edit( text_input ) && ' !== "" }' ).

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

ENDMETHOD.


METHOD on_event.

CASE client->get( )-event.
WHEN 'BACK'.
IF text_input IS NOT INITIAL.
render_popup( ).
ELSE.
client->nav_app_leave( ).
ENDIF.
WHEN 'submit'.
dirty = xsdbool( text_input IS NOT INITIAL ).
WHEN 'reset'.
CLEAR:
dirty,
text_input.
WHEN 'popup_decide_cancel'.
CLEAR: dirty.
client->popup_destroy( ).
client->nav_app_leave( ).
WHEN 'popup_decide_continue'.
client->popup_destroy( ).
ENDCASE.

ENDMETHOD.


METHOD render_popup.

DATA(popup) = z2ui5_cl_xml_view=>factory_popup( ).
popup->dialog( title = 'Warning' icon = 'sap-icon://status-critical'
)->vbox(
)->text( text = 'Your entries will be lost when you leave this page.'
class ='sapUiSmallMargin'
)->get_parent(
)->buttons(
)->button(
text = 'Leave Page'
type = 'Emphasized'
press = client->_event( 'popup_decide_cancel' )
)->button(
text = 'Cancel'
press = client->_event( 'popup_decide_continue' ) ).

client->popup_display( popup->stringify( ) ).

ENDMETHOD.


METHOD z2ui5_if_app~main.

me->client = client.

on_event( ).

IF initialized = abap_false.
initialized = abap_true.
display_view( ).
ELSE.
client->view_model_update( ).
ENDIF.

ENDMETHOD.
ENDCLASS.
16 changes: 16 additions & 0 deletions src/z2ui5_cl_demo_app_279.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_279</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>Data loss protection</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>