Skip to content

Commit ec1efe0

Browse files
oblomov-devclaude
andauthored
Refactor demo apps: improve naming, add new examples, fix bugs (#680)
* demo_app_160: cell-level events over a ui.Table with rich output model Rebuild the "Events on Cell Level" sample: a wider ty_s_output row type, a 10-row model, and a sap.ui.Table whose PL_TOTAL Input submits the cell/row identifiers (source id, event.oSource.sId, row index, oParent.sId, parameters.value) to PL_TOTAL_CHANGE, shown via message_box_display. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * fix * demo_app_445: sample for the device> model (views + popups) New "framework - use cases" sample showing how to apply the device> model (a one-way JSONModel over sap.ui.Device): - a panel binding the raw device state field by field (system type, orientation, live window size, touch, browser, OS) - an expression binding that switches a MessageStrip by device type - an IconTabBar collapsed on phones via expanded="{= !${device>/system/phone} }" - a dialog that binds the same state (and its own width) - proving the device> model now reaches popups, not just the main view The device_form( ) helper builds the label/value rows once and is reused for both the main view and the popup. Overview (sample_app_001) regenerated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * demo_app_445: open the IconTabBar items aggregation IconTabBar has no default aggregation, so IconTabFilter children must go into <items>. Add ->items( ) after icon_tab_bar( ), matching app_117; without it UI5 raises "Cannot add direct child without default aggregation defined for control sap.m.IconTabBar". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * demo_app_052: fixed popover width to stop the open-time resize jump contentWidth="50%" is a percentage, so the popover first renders at the content's natural width, positions, then resolves 50% and repositions - a visible size jump, compounded by SimpleForm's post-render relayout. Use a fixed 20rem so the popover computes its geometry once. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * demo_app_052: display-only ColumnLayout form to remove residual wobble The popover form only shows text, so render it read-only (editable = abap_false) with ColumnLayout instead of the default ResponsiveGridLayout - ColumnLayout does not re-measure and re-lay-out on render, removing the second reflow that could still nudge the popover. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * demo_app_120: read-only inputs and backend geolocation error handling - Render the geo fields read-only (editable = abap_false) - they only display the values the Geolocation control writes. - Bind the control's new `error` event to a GEOLOCATION_ERROR roundtrip, passing code + message via ${$parameters>/...}, and show the reason from the backend with message_box_display. - Collapse the duplicated init/MAP_CONTAINER_DISPLAY views into one view_display( ) method. Note: the geolocation `error` parameter needs the matching abap2UI5 framework change; abaplint flags it until that is deployed to main. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * fixes * fixes * demo_app_065: add a button that isolates nest_view_model_update New "Update only nested MODEL" button changes a nest-bound field (mv_input_nest) and calls nest_view_model_update( ) - refreshing only the nested view's model copy without re-rendering its XML, so the effect of the method is visible on its own. A counter makes the value change on each press. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * demo_app_009: make the value-help demo friendlier to test - Enable the "Clear" and "Send to Server" buttons - both were enabled=abap_false, so their handlers could never be triggered. - Add an intro MessageStrip explaining the four value-help patterns. - Give "Send" a paper-plane icon to match "Clear". - The two popup "continue" handlers now toast "please select exactly one ..." instead of silently doing nothing when the selection is not a single row. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * demo_app_120: remove the dead MapContainer "Display" button The MAP_CONTAINER_DISPLAY handler is gone, so the button only fired an empty roundtrip. Drop the button and its label; the form ends at Speed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * demo_app_074: adopt the show-content upload variant and clean it up Take the simpler uploader flow (decode the file and show its text in a message box). Cleanups: drop the identical-branch COND (both sides were _bind_edit) and the two unused check flags; remove Hungarian prefixes per the style guide; put main first and merge the init/navigated branches; clear the bound fields before re-rendering; merge the duplicated column / cell loops into one. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * sample_context: don't dump on an empty search value itab_filter_by_val ran find( sub = lv_search ) with an empty search string, which raises CX_SY_STRG_PAR_VAL ("value '' not permitted for parameter SUB of FIND") - hit in demo_app_059 when the search field is cleared to empty. An empty search matches everything, so return early and leave the table unfiltered. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe * fix template * demo_app_446/447: samples for control_call and control_call_by_id Two "framework - action" samples: - 446 "Action - control_call": buttons that let the backend call global frontend objects (MessageToast.show, MessageBox.show, Theming.setTheme). - 447 "Action - control_call_by_id": focus() an input and scrollToIndex() a 30-row table, both by control id. Overview regenerated. Note: both use the new client->control_call / control_call_by_id methods; samples abaplint flags them as "method not found" until the abap2UI5 framework change is deployed to main. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAnf42GPU5rnh9A7pRpYQe --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c21b8fe commit ec1efe0

25 files changed

Lines changed: 719 additions & 310 deletions

src/00/06/z2ui5_cl_demo_app_085.clas.abap

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,8 @@ CLASS z2ui5_cl_demo_app_085 IMPLEMENTATION.
104104

105105
header_title->snapped_heading(
106106
)->flex_box( alignitems = `Center`
107-
)->image( src = c_pic_url && ls_detail-pic
108-
width = `2rem`
109-
class = `sapUiTinyMarginEnd`
107+
)->avatar( src = c_pic_url && ls_detail-pic
108+
class = `sapUiTinyMarginEnd`
110109
)->info_label( text = |Product Id | && client->_bind( ls_detail-productid )
111110
colorscheme = `9`
112111
width = `200px`
@@ -154,9 +153,9 @@ CLASS z2ui5_cl_demo_app_085 IMPLEMENTATION.
154153

155154
DATA(header_content) = page->header_content( `uxap` ).
156155
header_content->flex_box( wrap = `Wrap`
157-
)->image( src = c_pic_url && ls_detail-pic
158-
width = `5rem`
159-
class = `sapUiSmallMarginEnd`
156+
)->avatar( src = c_pic_url && ls_detail-pic
157+
class = `sapUiSmallMarginEnd`
158+
displaysize = `layout`
160159
)->vertical_layout( class = `sapUiSmallMarginBeginEnd`
161160
)->label( `Dimension`
162161
)->label( `Weight`
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
CLASS z2ui5_cl_demo_app_086 DEFINITION PUBLIC.
2+
3+
PUBLIC SECTION.
4+
INTERFACES z2ui5_if_app.
5+
6+
TYPES:
7+
BEGIN OF ty_s_tab_supplier,
8+
suppliername TYPE string,
9+
email TYPE string,
10+
phone TYPE string,
11+
zipcode TYPE string,
12+
city TYPE string,
13+
street TYPE string,
14+
country TYPE string,
15+
END OF ty_s_tab_supplier.
16+
DATA ls_detail_supplier TYPE ty_s_tab_supplier.
17+
18+
PROTECTED SECTION.
19+
PRIVATE SECTION.
20+
ENDCLASS.
21+
22+
23+
CLASS z2ui5_cl_demo_app_086 IMPLEMENTATION.
24+
25+
METHOD z2ui5_if_app~main.
26+
27+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
28+
DATA(page) = view->shell(
29+
)->page(
30+
title = `abap2UI5 - Flow Logic - APP 85`
31+
navbuttonpress = client->_event_nav_app_leave( )
32+
shownavbutton = client->check_app_prev_stack( ) ).
33+
34+
page->grid( `L6 M12 S12` )->content( `layout`
35+
)->simple_form( `Supplier` )->content( `form`
36+
)->label( `Value set by previous app`
37+
)->input( value = ls_detail_supplier-suppliername
38+
editable = `false` ).
39+
40+
client->view_display( view->stringify( ) ).
41+
42+
ENDMETHOD.
43+
44+
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_086</CLSNAME>
7+
<LANGU>E</LANGU>
8+
<DESCRIPT>ZZZ - called by 085</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/01/z2ui5_cl_demo_app_009.clas.abap

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ CLASS z2ui5_cl_demo_app_009 IMPLEMENTATION.
132132
client->message_toast_display( `value selected` ).
133133
client->popup_destroy( ).
134134

135+
ELSE.
136+
client->message_toast_display( `please select exactly one employee` ).
135137
ENDIF.
136138
WHEN `POPUP_TABLE_VALUE_CONTINUE`.
137139
DELETE t_suggestion_sel WHERE selkz = abap_false.
@@ -142,6 +144,8 @@ CLASS z2ui5_cl_demo_app_009 IMPLEMENTATION.
142144
client->message_toast_display( `value selected` ).
143145
client->popup_destroy( ).
144146

147+
ELSE.
148+
client->message_toast_display( `please select exactly one color` ).
145149
ENDIF.
146150
WHEN `BUTTON_SEND`.
147151
client->message_box_display( `success - values sent to the server` ).
@@ -164,6 +168,13 @@ CLASS z2ui5_cl_demo_app_009 IMPLEMENTATION.
164168
navbuttonpress = client->_event_nav_app_leave( )
165169
shownavbutton = client->check_app_prev_stack( ) ).
166170

171+
page->message_strip(
172+
text = `Four value-help patterns: inline suggestions, numeric-only input, a value-help popup with a selectable table, ` &&
173+
`and a custom popup with a city search. Fill the fields, then Clear resets the view and Send simulates a submit.`
174+
type = `Information`
175+
showicon = abap_true
176+
class = `sapUiSmallMargin` ).
177+
167178
DATA(form) = page->grid( `L7 M7 S7`
168179
)->content( `layout`
169180
)->simple_form( `Input with Value Help`
@@ -210,16 +221,15 @@ CLASS z2ui5_cl_demo_app_009 IMPLEMENTATION.
210221
)->overflow_toolbar(
211222
)->toolbar_spacer(
212223
)->button(
213-
text = `Clear`
214-
press = client->_event( `BUTTON_CLEAR` )
215-
type = `Reject`
216-
enabled = abap_false
217-
icon = `sap-icon://delete`
224+
text = `Clear`
225+
press = client->_event( `BUTTON_CLEAR` )
226+
type = `Reject`
227+
icon = `sap-icon://delete`
218228
)->button(
219-
text = `Send to Server`
220-
press = client->_event( `BUTTON_SEND` )
221-
enabled = abap_false
222-
type = `Success` ).
229+
text = `Send to Server`
230+
press = client->_event( `BUTTON_SEND` )
231+
type = `Success`
232+
icon = `sap-icon://paper-plane` ).
223233

224234
client->view_display( view->stringify( ) ).
225235

src/01/01/z2ui5_cl_demo_app_052.clas.abap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ CLASS z2ui5_cl_demo_app_052 IMPLEMENTATION.
3838

3939
lo_popover->popover( placement = `Right`
4040
title = |abap2UI5 - Popover - { mv_product }|
41-
contentwidth = `50%`
42-
)->simple_form( editable = abap_true
41+
contentwidth = `20rem`
42+
)->simple_form( editable = abap_false
43+
layout = `ColumnLayout`
4344
)->content( `form`
4445
)->label( `Product`
4546
)->text( mv_product

src/01/01/z2ui5_cl_demo_app_065.clas.abap

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CLASS z2ui5_cl_demo_app_065 DEFINITION PUBLIC.
55

66
DATA mv_input_main TYPE string.
77
DATA mv_input_nest TYPE string.
8+
DATA mv_count TYPE i.
89

910
PROTECTED SECTION.
1011
PRIVATE SECTION.
@@ -34,14 +35,14 @@ CLASS z2ui5_cl_demo_app_065 IMPLEMENTATION.
3435
press = client->_event( `MAIN` )
3536
)->button( text = `Rerender only nested view`
3637
press = client->_event( `NEST` )
38+
)->button( text = `Update only nested MODEL (nest_view_model_update)`
39+
press = client->_event( `NEST_MODEL` )
3740
)->input( client->_bind_edit( mv_input_main ) ).
3841

3942
DATA(lo_view_nested) = z2ui5_cl_xml_view=>factory(
4043
)->page( `Nested View`
4144
)->button( text = `event`
4245
press = client->_event( `TEST` )
43-
)->button( text = `frontend event`
44-
press = client->_event_client( val = client->cs_event-open_new_tab t_arg = VALUE #( ( `https://github.com/abap2UI5/abap2UI5/` ) ) )
4546
)->input( client->_bind_edit( mv_input_nest ) ).
4647

4748
IF client->check_on_init( ).
@@ -67,6 +68,15 @@ CLASS z2ui5_cl_demo_app_065 IMPLEMENTATION.
6768
client->nest_view_display( val = lo_view_nested->stringify( )
6869
id = `test`
6970
method_insert = `addContent` ).
71+
72+
WHEN `NEST_MODEL`.
73+
" change only a nest-bound field and refresh the nested view's model
74+
" copy (no re-render of the nested XML) - this isolates the effect of
75+
" nest_view_model_update. Press "Rerender only nested view" first so
76+
" the nested view exists.
77+
mv_count = mv_count + 1.
78+
mv_input_nest = |nest model updated #{ mv_count }|.
79+
client->nest_view_model_update( ).
7080
ENDCASE.
7181

7282
ENDMETHOD.

src/01/01/z2ui5_cl_demo_app_097.clas.abap

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CLASS z2ui5_cl_demo_app_097 DEFINITION PUBLIC.
55

66
TYPES:
77
BEGIN OF ty_s_row,
8+
uuid TYPE string,
89
title TYPE string,
910
value TYPE string,
1011
descr TYPE string,
@@ -57,7 +58,7 @@ CLASS z2ui5_cl_demo_app_097 IMPLEMENTATION.
5758
filterproperty = `INFO` )->text( `INFO` )->ui_template( )->text( `{INFO}` ).
5859
lo_columns->get_parent( )->ui_row_action_template( )->ui_row_action(
5960
)->ui_row_action_item( icon = `sap-icon://delete`
60-
press = client->_event( val = `ROW_DELETE` t_arg = VALUE #( ( `${TITLE}` ) ) ) ).
61+
press = client->_event( val = `ROW_DELETE` t_arg = VALUE #( ( `${UUID}` ) ) ) ).
6162

6263
client->nest_view_display(
6364
val = lo_view_nested->stringify( )
@@ -123,19 +124,17 @@ CLASS z2ui5_cl_demo_app_097 IMPLEMENTATION.
123124
CASE client->get( )-event.
124125

125126
WHEN `ROW_DELETE`.
126-
DATA(ls_arg) = client->get_event_arg( ).
127-
IF ls_arg IS NOT INITIAL.
128-
DELETE t_tab2 WHERE title = ls_arg.
129-
ENDIF.
130127

128+
DELETE t_tab2 WHERE uuid = client->get_event_arg( ).
131129
client->nest_view_model_update( ).
132130

133131
WHEN `SELCHANGE`.
134132
DATA(lt_sel) = t_tab.
135133
DELETE lt_sel WHERE selected = abap_false.
136134

137135
READ TABLE lt_sel INTO DATA(ls_sel) INDEX 1.
138-
APPEND ls_sel TO t_tab2.
136+
ls_sel-uuid = z2ui5_cl_sample_context=>uuid_get_c32( ).
137+
INSERT ls_sel INTO TABLE t_tab2.
139138

140139
mv_layout = `TwoColumnsMidExpanded`.
141140

src/01/01/z2ui5_cl_demo_app_098.clas.abap

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ CLASS z2ui5_cl_demo_app_098 IMPLEMENTATION.
8383
page = page->text( client->_bind( mv_title )
8484
)->button(
8585
text = `frontend event`
86-
press = client->_event_client( val = client->cs_event-open_new_tab t_arg = VALUE #( ( `https://github.com/abap2UI5/abap2UI5/` ) ) ) ).
86+
press = client->_event( `NN_VIEW` ) ).
8787

8888
client->nest2_view_display(
8989
val = lo_view_nested->stringify( )
@@ -149,6 +149,9 @@ CLASS z2ui5_cl_demo_app_098 IMPLEMENTATION.
149149

150150
CASE client->get( )-event.
151151

152+
WHEN 'NN_VIEW'.
153+
client->message_box_display( `Event in nested nested view raised` ).
154+
152155
WHEN `ROW_NAVIGATE`.
153156

154157
IF client->get_event_arg( ) IS NOT INITIAL.
@@ -165,7 +168,9 @@ CLASS z2ui5_cl_demo_app_098 IMPLEMENTATION.
165168
DELETE lt_sel WHERE selected = abap_false.
166169

167170
READ TABLE lt_sel INTO DATA(ls_sel) INDEX 1.
168-
APPEND ls_sel TO t_tab2.
171+
IF NOT line_exists( t_tab2[ title = ls_sel-title ] ).
172+
INSERT ls_sel INTO TABLE t_tab2.
173+
ENDIF.
169174

170175
mv_layout = `TwoColumnsMidExpanded`.
171176

src/01/01/z2ui5_cl_demo_app_163.clas.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<VSEOCLASS>
66
<CLSNAME>Z2UI5_CL_DEMO_APP_163</CLSNAME>
77
<LANGU>E</LANGU>
8-
<DESCRIPT>More - require sap.m.MessageToast in XML View</DESCRIPT>
8+
<DESCRIPT>More - Require Object in XML View</DESCRIPT>
99
<STATE>1</STATE>
1010
<CLSCCINCL>X</CLSCCINCL>
1111
<FIXPT>X</FIXPT>

src/01/01/z2ui5_cl_demo_app_173.clas.abap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@ CLASS z2ui5_cl_demo_app_173 IMPLEMENTATION.
4444
navbuttonpress = client->_event_nav_app_leave( )
4545
shownavbutton = client->check_app_prev_stack( ) ).
4646

47-
view->table( client->_bind( mt_data )
47+
view->table( client->_bind_edit( mt_data )
4848
)->columns(
49-
)->template_repeat( list = `{template>/MT_LAYOUT}`
49+
)->template_repeat( list = `{template>/XX/MT_LAYOUT}`
5050
var = `L0`
5151
)->column( mergeduplicates = `{L0>MERGE}`
5252
visible = `{L0>VISIBLE}` )->text( `{L0>FNAME}` )->get_parent(
5353
)->get_parent( )->get_parent(
5454
)->items(
5555
)->column_list_item(
5656
)->cells(
57-
)->template_repeat( list = `{template>/MT_LAYOUT}`
57+
)->template_repeat( list = `{template>/XX/MT_LAYOUT}`
5858
var = `L1`
5959
)->object_identifier( text = `{= '{' + ${L1>FNAME} + '}' }` ).
6060

0 commit comments

Comments
 (0)