Skip to content

Commit b914157

Browse files
Update 152 - Popup to Select - with mutliselect feature (#362)
* popup to select: add multi select * update example with preselection
1 parent 638cf53 commit b914157

File tree

1 file changed

+58
-13
lines changed

1 file changed

+58
-13
lines changed

src/z2ui5_cl_demo_app_152.clas.abap

Lines changed: 58 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@ CLASS z2ui5_cl_demo_app_152 DEFINITION PUBLIC.
88

99
TYPES:
1010
BEGIN OF ty_row,
11-
title TYPE string,
12-
value TYPE string,
13-
descr TYPE string,
11+
zzselkz TYPE abap_bool,
12+
title TYPE string,
13+
value TYPE string,
14+
descr TYPE string,
1415
END OF ty_row.
1516
DATA mt_tab TYPE STANDARD TABLE OF ty_row WITH EMPTY KEY.
1617

1718
DATA mv_check_initialized TYPE abap_bool.
19+
DATA mv_multiselect TYPE abap_bool.
20+
DATA mv_preselect TYPE abap_bool.
1821
METHODS ui5_display.
1922
METHODS ui5_event.
2023
METHODS ui5_callback.
2124

2225
PROTECTED SECTION.
2326
PRIVATE SECTION.
27+
2428
ENDCLASS.
2529

2630

@@ -35,15 +39,30 @@ CLASS z2ui5_cl_demo_app_152 IMPLEMENTATION.
3539
WHEN 'POPUP'.
3640

3741
mt_tab = VALUE #( descr = 'this is a description'
38-
( title = 'title_01' value = 'value_01' )
39-
( title = 'title_02' value = 'value_02' )
40-
( title = 'title_03' value = 'value_03' )
41-
( title = 'title_04' value = 'value_04' )
42-
( title = 'title_05' value = 'value_05' ) ).
43-
44-
DATA(lo_app) = z2ui5_cl_pop_to_select=>factory( mt_tab ).
42+
( zzselkz = mv_preselect title = 'title_01' value = 'value_01' )
43+
( zzselkz = mv_preselect title = 'title_02' value = 'value_02' )
44+
( zzselkz = mv_preselect title = 'title_03' value = 'value_03' )
45+
( zzselkz = mv_preselect title = 'title_04' value = 'value_04' )
46+
( zzselkz = mv_preselect title = 'title_05' value = 'value_05' ) ).
47+
48+
DATA(lo_app) = z2ui5_cl_pop_to_select=>factory(
49+
i_tab = mt_tab
50+
i_multiselect = mv_multiselect
51+
i_title = COND #(
52+
WHEN mv_multiselect = abap_true
53+
THEN `Multi select`
54+
ELSE `Single select` ) ).
4555
client->nav_app_call( lo_app ).
4656

57+
58+
WHEN 'MULTISELECT_TOGGLE'.
59+
60+
mv_preselect = COND #( WHEN mv_multiselect = abap_false
61+
THEN abap_false
62+
ELSE mv_preselect ).
63+
64+
client->view_model_update( ).
65+
4766
WHEN 'BACK'.
4867
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).
4968

@@ -66,6 +85,14 @@ CLASS z2ui5_cl_demo_app_152 IMPLEMENTATION.
6685
target = '_blank'
6786

6887
)->get_parent(
88+
)->hbox(
89+
)->text( text = 'Multiselect: ' class = 'sapUiTinyMargin'
90+
)->switch( state = client->_bind_edit( mv_multiselect ) change = client->_event( `MULTISELECT_TOGGLE` )
91+
)->get_parent(
92+
)->hbox(
93+
)->text( text = 'Preselect all entries: ' class = 'sapUiTinyMargin'
94+
)->switch( state = client->_bind_edit( mv_preselect ) enabled = client->_bind_edit( mv_multiselect )
95+
)->get_parent(
6996
)->button(
7097
text = 'Open Popup...'
7198
press = client->_event( 'POPUP' ) ).
@@ -98,9 +125,27 @@ CLASS z2ui5_cl_demo_app_152 IMPLEMENTATION.
98125
TRY.
99126
DATA(lo_prev) = client->get_app( client->get( )-s_draft-id_prev_app ).
100127
DATA(ls_result) = CAST z2ui5_cl_pop_to_select( lo_prev )->result( ).
101-
FIELD-SYMBOLS <row> TYPE ty_row.
102-
ASSIGN ls_result-row->* TO <row>.
103-
client->message_box_display( `callback after popup to select: ` && <row>-title ).
128+
129+
IF ls_result-check_confirmed = abap_false.
130+
client->message_box_display( `Popup was cancelled` ).
131+
RETURN.
132+
ENDIF.
133+
134+
IF mv_multiselect = abap_false.
135+
136+
FIELD-SYMBOLS <row> TYPE ty_row.
137+
ASSIGN ls_result-row->* TO <row>.
138+
client->message_box_display( `callback after popup to select: ` && <row>-title ).
139+
140+
ELSE.
141+
142+
ASSIGN ls_result-table->* TO FIELD-SYMBOL(<table>).
143+
client->nav_app_call( z2ui5_cl_pop_table=>factory(
144+
i_tab = <table>
145+
i_title = 'Selected rows' ) ).
146+
147+
ENDIF.
148+
104149
CATCH cx_root.
105150
ENDTRY.
106151

0 commit comments

Comments
 (0)