|
| 1 | +CLASS z2ui5_cl_demo_app_307 DEFINITION |
| 2 | + PUBLIC FINAL |
| 3 | + CREATE PUBLIC. |
| 4 | + |
| 5 | + PUBLIC SECTION. |
| 6 | + INTERFACES z2ui5_if_app. |
| 7 | + |
| 8 | + TYPES: BEGIN OF ty_item, |
| 9 | + busy TYPE abap_bool, |
| 10 | + busyindicatordelay TYPE i, |
| 11 | + busyindicatorsize TYPE string, |
| 12 | + counter TYPE i, |
| 13 | + fieldgroupids TYPE string, |
| 14 | + highlight TYPE string, |
| 15 | + highlighttext TYPE string, |
| 16 | + navigated TYPE abap_bool, |
| 17 | + selected TYPE abap_bool, |
| 18 | + type TYPE string, |
| 19 | + unread TYPE abap_bool, |
| 20 | + visiple TYPE abap_bool, |
| 21 | + title TYPE string, |
| 22 | + subtitle TYPE string, |
| 23 | + END OF ty_item. |
| 24 | + TYPES ty_items TYPE STANDARD TABLE OF ty_item WITH DEFAULT KEY. |
| 25 | + |
| 26 | + DATA client TYPE REF TO z2ui5_if_client. |
| 27 | + DATA check_initialized TYPE abap_bool. |
| 28 | + DATA items TYPE ty_items. |
| 29 | + |
| 30 | + METHODS initialization. |
| 31 | + |
| 32 | + METHODS display_view |
| 33 | + IMPORTING !client TYPE REF TO z2ui5_if_client. |
| 34 | + |
| 35 | + METHODS on_event |
| 36 | + IMPORTING !client TYPE REF TO z2ui5_if_client. |
| 37 | + |
| 38 | +ENDCLASS. |
| 39 | + |
| 40 | + |
| 41 | +CLASS z2ui5_cl_demo_app_307 IMPLEMENTATION. |
| 42 | + METHOD z2ui5_if_app~main. |
| 43 | + me->client = client. |
| 44 | + |
| 45 | + IF check_initialized = abap_false. |
| 46 | + check_initialized = abap_true. |
| 47 | + initialization( ). |
| 48 | + display_view( client ). |
| 49 | + ENDIF. |
| 50 | + |
| 51 | + on_event( client ). |
| 52 | + ENDMETHOD. |
| 53 | + |
| 54 | + METHOD initialization. |
| 55 | + items = VALUE #( |
| 56 | + ( title = `Box title 1` |
| 57 | + subtitle = `Subtitle 1` |
| 58 | + counter = 5 |
| 59 | + highlight = `Error` |
| 60 | + unread = abap_true |
| 61 | + type = `Active` ) |
| 62 | + ( title = `Box title 2` |
| 63 | + subtitle = `Subtitle 2` |
| 64 | + counter = 15 |
| 65 | + highlight = `Warning` |
| 66 | + type = `Active` ) |
| 67 | + ( title = `Box title 3` |
| 68 | + subtitle = `Subtitle 3` |
| 69 | + counter = 15734 |
| 70 | + highlight = `None` |
| 71 | + type = `Inactive` |
| 72 | + busy = abap_true ) |
| 73 | + ( title = `Box title 4` |
| 74 | + subtitle = `Subtitle 4` |
| 75 | + counter = 2 |
| 76 | + highlight = `None` |
| 77 | + type = `Inactive` ) |
| 78 | + ( title = `Box title 5` |
| 79 | + subtitle = `Subtitle 5` |
| 80 | + counter = 1 |
| 81 | + highlight = `Warning` |
| 82 | + type = `Inactive` ) |
| 83 | + ( title = `Box title 6 Box title Box title Box title Box title Box title` |
| 84 | + subtitle = `Subtitle 6` |
| 85 | + counter = 5 |
| 86 | + highlight = `None` |
| 87 | + type = `Active` ) |
| 88 | + ( title = `Very long Box title that should wrap 7` |
| 89 | + subtitle = `This is a long subtitle 7` |
| 90 | + counter = 5 |
| 91 | + highlight = `Error` |
| 92 | + type = `DetailAndActive` ) |
| 93 | + ( title = `Box title B 8` |
| 94 | + subtitle = `Subtitle 8` |
| 95 | + counter = 0 |
| 96 | + highlight = `None` |
| 97 | + type = `Navigation` ) |
| 98 | + ( title = `Box title B 9 Box title B Box title B 9 Box title B 9Box title B 9title B 9 Box title B 9Box title B` |
| 99 | + subtitle = `Subtitle 9` |
| 100 | + highlight = `Success` |
| 101 | + type = `Inactive` ) |
| 102 | + ( title = `Box title B 10` |
| 103 | + subtitle = `Subtitle 10` |
| 104 | + highlight = `None` |
| 105 | + type = `Active` ) |
| 106 | + ( title = `Box title B 11` |
| 107 | + subtitle = `Subtitle 11` |
| 108 | + highlight = `None` |
| 109 | + type = `Active` ) |
| 110 | + ( title = `Box title B 12` |
| 111 | + subtitle = `Subtitle 12` |
| 112 | + highlight = `Information` |
| 113 | + type = `Inactive` ) |
| 114 | + ( title = `Box title 13` |
| 115 | + subtitle = `Subtitle 13` |
| 116 | + counter = 5 |
| 117 | + highlight = `None` |
| 118 | + type = `Navigation` ) |
| 119 | + ( title = `Box title 14` |
| 120 | + subtitle = `Subtitle 14` |
| 121 | + highlight = `Success` |
| 122 | + type = `DetailAndActive` ) |
| 123 | + ( title = `Box title 15` |
| 124 | + subtitle = `Subtitle 15` |
| 125 | + highlight = `None` |
| 126 | + type = `Inactive` ) |
| 127 | + ( title = `Box title 16` |
| 128 | + subtitle = `Subtitle 16` |
| 129 | + counter = 37412578 |
| 130 | + highlight = `None` |
| 131 | + type = `Navigation` ) |
| 132 | + ( title = `Box title 17` |
| 133 | + subtitle = `Subtitle 17` |
| 134 | + highlight = `Information` |
| 135 | + type = `Inactive` ) |
| 136 | + ( title = `Box title 18` |
| 137 | + subtitle = `Subtitle 18` |
| 138 | + highlight = `None` |
| 139 | + type = `Inactive` ) |
| 140 | + ( title = `Very long Box title that should wrap 19` |
| 141 | + subtitle = `This is a long subtitle 19` |
| 142 | + highlight = `None` |
| 143 | + type = `Inactive` ) |
| 144 | + ( title = `Box title B 20` |
| 145 | + subtitle = `Subtitle 20` |
| 146 | + counter = 1 |
| 147 | + busy = abap_true |
| 148 | + highlight = `Success` |
| 149 | + type = `Inactive` ) |
| 150 | + ( title = `Box title B 21` |
| 151 | + subtitle = `Subtitle 21` |
| 152 | + highlight = `None` |
| 153 | + type = `Navigation` ) |
| 154 | + ( title = `Box title B 22` |
| 155 | + subtitle = `Subtitle 22` |
| 156 | + counter = 5 |
| 157 | + highlight = `None` |
| 158 | + unread = abap_true |
| 159 | + type = `Inactive` ) |
| 160 | + ( title = `Box title B 23` |
| 161 | + subtitle = `Subtitle 23` |
| 162 | + counter = 3 |
| 163 | + highlight = `None` |
| 164 | + unread = abap_true |
| 165 | + type = `Inactive` ) |
| 166 | + ( title = `Box title B 24` |
| 167 | + subtitle = `Subtitle 24` |
| 168 | + counter = 5 |
| 169 | + highlight = `Error` |
| 170 | + type = `Inactive` ) |
| 171 | + ( title = `Box title B 21` |
| 172 | + subtitle = `Subtitle 21` |
| 173 | + highlight = `None` |
| 174 | + type = `Inactive` ) |
| 175 | + ( title = `Box title B 22` |
| 176 | + subtitle = `Subtitle 22` |
| 177 | + highlight = `None` |
| 178 | + unread = abap_true |
| 179 | + type = `Navigation` ) |
| 180 | + ( title = `Box title B 23` |
| 181 | + subtitle = `Subtitle 23` |
| 182 | + highlight = `None` |
| 183 | + type = `Navigation` ) ). |
| 184 | + ENDMETHOD. |
| 185 | + |
| 186 | + METHOD display_view. |
| 187 | + data(view) = z2ui5_cl_xml_view=>factory( ). |
| 188 | + |
| 189 | + view->_z2ui5( )->title( `Grid List with Drag and Drop` ). |
| 190 | + |
| 191 | + view->panel( id = `panelForGridList` |
| 192 | + backgroundDesign = `Transparent` |
| 193 | + )->header_toolbar( |
| 194 | + )->toolbar( height = `3rem` |
| 195 | + )->title( text = `Grid List with Drag and Drop` |
| 196 | + )->get_parent( |
| 197 | + )->get_parent( |
| 198 | + )->grid_list( id = `gridList` |
| 199 | + headerText = `GridList header` |
| 200 | + items = client->_bind_edit( items ) |
| 201 | + )->drag_drop_config( |
| 202 | + )->drag_info( sourceAggregation = `items` |
| 203 | + )->grid_drop_info( |
| 204 | + targetAggregation = `items` |
| 205 | + dropPosition = `Between` |
| 206 | + dropLayout = `Horizontal` |
| 207 | + drop = client->_event( |
| 208 | + val = 'onDrop' |
| 209 | + t_arg = VALUE #( |
| 210 | + ( `${$parameters>/draggedControl/oParent}.indexOfItem(${$parameters>/draggedControl})` ) |
| 211 | + ( `${$parameters>/droppedControl/oParent}.indexOfItem(${$parameters>/droppedControl})` ) |
| 212 | + ( `${$parameters>/dropPosition}` ) ) ) |
| 213 | + )->get_parent( |
| 214 | + )->custom_layout( ns = 'f' |
| 215 | + )->grid_box_layout( boxMinWidth = `17rem` |
| 216 | + )->get_parent( |
| 217 | + )->grid_list_item( counter = '{COUNTER}' |
| 218 | + highlight = '{HIGHLIGHT}' |
| 219 | + type = '{TYPE}' |
| 220 | + unread = '{UNREAD}' |
| 221 | + )->vbox( height = `100%` |
| 222 | + )->VBox( class = `sapUiSmallMargin` |
| 223 | + )->layout_Data( |
| 224 | + )->Flex_Item_Data( growFactor = `1` |
| 225 | + shrinkFactor = `0` |
| 226 | + )->get_parent( |
| 227 | + )->title( text = '{TITLE}' |
| 228 | + wrapping = abap_true |
| 229 | + )->Label( text = '{SUBTITLE}' |
| 230 | + wrapping = abap_true ). |
| 231 | + |
| 232 | + client->view_display( view->stringify( ) ). |
| 233 | + ENDMETHOD. |
| 234 | + |
| 235 | + METHOD on_event. |
| 236 | + CASE client->get( )-event. |
| 237 | + WHEN 'onDrop'. |
| 238 | + DATA(onDropParameters) = client->get( )-t_event_arg. |
| 239 | + TRY. |
| 240 | + DATA(drag_position) = CONV i( onDropParameters[ 1 ] ) + 1. |
| 241 | + DATA(drop_position) = CONV i( onDropParameters[ 2 ] ) + 1. |
| 242 | + DATA(insert_position) = onDropParameters[ 3 ]. |
| 243 | + DATA(item) = items[ drag_position ]. |
| 244 | + CATCH cx_root. |
| 245 | + RETURN. |
| 246 | + ENDTRY. |
| 247 | + |
| 248 | + DELETE items INDEX drag_position. |
| 249 | + |
| 250 | + IF drag_position < drop_position. |
| 251 | + drop_position = drop_position - 1. |
| 252 | + ENDIF. |
| 253 | + |
| 254 | + IF insert_position = `Before`. |
| 255 | + INSERT item INTO items INDEX drop_position. |
| 256 | + ELSE. |
| 257 | + INSERT item INTO items INDEX drop_position + 1. |
| 258 | + ENDIF. |
| 259 | + |
| 260 | + ENDCASE. |
| 261 | + client->view_model_update( ). |
| 262 | + ENDMETHOD. |
| 263 | +ENDCLASS. |
0 commit comments