Skip to content

Commit 74d4ae4

Browse files
oblomov-devclaude
andauthored
Add sample for image_editor_popup_close frontend action (01/02) (#681)
Add a self-contained demo (z2ui5_cl_demo_app_383) in the "framework - action" package that showcases the IMAGE_EDITOR_POPUP_CLOSE frontend action directly, without the z2ui5_cl_pop_image_editor helper class. The Save button binds client->_event_client( cs_event-image_editor_popup_close ), which reads the edited image from the ImageEditor control on the client (getImagePngDataURL), closes the popup and returns the PNG data URL to the server as the SAVE event argument. Regenerate the src/01 overview catalog for the new tile. Claude-Session: https://claude.ai/code/session_01HbhPYiga7hfH54P1U4Y4ou Co-authored-by: Claude <noreply@anthropic.com>
1 parent ec1efe0 commit 74d4ae4

3 files changed

Lines changed: 131 additions & 0 deletions

File tree

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
CLASS z2ui5_cl_demo_app_383 DEFINITION PUBLIC.
2+
3+
PUBLIC SECTION.
4+
INTERFACES z2ui5_if_app.
5+
6+
DATA image TYPE string.
7+
8+
PROTECTED SECTION.
9+
DATA client TYPE REF TO z2ui5_if_client.
10+
11+
METHODS view_display.
12+
METHODS popup_display.
13+
METHODS on_event.
14+
15+
PRIVATE SECTION.
16+
ENDCLASS.
17+
18+
19+
20+
CLASS z2ui5_cl_demo_app_383 IMPLEMENTATION.
21+
22+
23+
METHOD z2ui5_if_app~main.
24+
25+
me->client = client.
26+
27+
IF client->check_on_init( ).
28+
29+
image = `https://raw.githubusercontent.com/abap2UI5/abap2UI5/main/docs/images/logo.png`.
30+
view_display( ).
31+
32+
ELSEIF client->check_on_event( ).
33+
on_event( ).
34+
ENDIF.
35+
36+
ENDMETHOD.
37+
38+
39+
METHOD view_display.
40+
41+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
42+
43+
view->shell(
44+
)->page(
45+
title = `abap2UI5 - Frontend Action - Image Editor Popup Close`
46+
navbuttonpress = client->_event_nav_app_leave( )
47+
shownavbutton = client->check_app_prev_stack( )
48+
)->vbox( `sapUiSmallMargin`
49+
)->image(
50+
src = client->_bind( image )
51+
width = `20rem`
52+
)->button(
53+
text = `Edit Image...`
54+
icon = `sap-icon://edit`
55+
press = client->_event( `EDIT` ) ).
56+
57+
client->view_display( view->stringify( ) ).
58+
59+
ENDMETHOD.
60+
61+
62+
METHOD popup_display.
63+
64+
DATA(popup) = z2ui5_cl_xml_view=>factory_popup(
65+
)->dialog(
66+
title = `Edit Image`
67+
icon = `sap-icon://edit`
68+
contentheight = `80%`
69+
contentwidth = `80%`
70+
verticalscrolling = abap_false
71+
horizontalscrolling = abap_false ).
72+
73+
popup->image_editor_container(
74+
)->image_editor(
75+
id = `imageEditor`
76+
src = image ).
77+
78+
popup->buttons(
79+
)->button(
80+
text = `Cancel`
81+
type = `Reject`
82+
press = client->_event( `CANCEL` )
83+
)->button(
84+
text = `Save`
85+
type = `Emphasized`
86+
press = client->_event_client( client->cs_event-image_editor_popup_close ) ).
87+
88+
client->popup_display( popup->stringify( ) ).
89+
90+
ENDMETHOD.
91+
92+
93+
METHOD on_event.
94+
95+
CASE client->get( )-event.
96+
97+
WHEN `EDIT`.
98+
popup_display( ).
99+
100+
WHEN `SAVE`.
101+
102+
image = client->get_event_arg( 1 ).
103+
client->popup_destroy( ).
104+
client->view_model_update( ).
105+
client->message_toast_display( `Image saved` ).
106+
107+
WHEN `CANCEL`.
108+
client->popup_destroy( ).
109+
110+
ENDCASE.
111+
112+
ENDMETHOD.
113+
114+
ENDCLASS.
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_383</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>Image Editor - Edit in Popup and return PNG</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>

src/01/z2ui5_cl_sample_app_001.clas.abap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ CLASS z2ui5_cl_sample_app_001 IMPLEMENTATION.
245245
( group = `framework - action` header = `Browser` sub = `Title` app = `z2ui5_cl_demo_app_125` )
246246
( group = `framework - action` header = `Focus I` sub = `Set Focus in Textfield` app = `z2ui5_cl_demo_app_133` )
247247
( group = `framework - action` header = `Focus II` sub = `Jump with the focus` app = `z2ui5_cl_demo_app_189` )
248+
( group = `framework - action` header = `Image Editor` sub = `Edit in Popup and return PNG` app = `z2ui5_cl_demo_app_383` )
248249
( group = `framework - action` header = `Input` sub = `Clipboard` app = `z2ui5_cl_demo_app_325` )
249250
( group = `framework - action` header = `Input` sub = `Hide/show Soft Keyboard` app = `z2ui5_cl_demo_app_352` )
250251
( group = `framework - action` header = `Scroll I` sub = `Scroll to position` app = `z2ui5_cl_demo_app_362` )

0 commit comments

Comments
 (0)