|
1 | | -class Z2UI5_CL_DEMO_APP_038 definition |
2 | | - public |
3 | | - create private . |
| 1 | +"! Rebuild of the UI5 demo kit sample: https://sapui5.hana.ondemand.com/sdk/#/entity/sap.m.MessageView/sample/sap.m.sample.MessageViewWithGrouping |
| 2 | +"! A sample with Message View and inside a Dialog and grouping of items |
| 3 | +CLASS z2ui5_cl_demo_app_038 DEFINITION PUBLIC. |
4 | 4 |
|
5 | | -public section. |
6 | | -protected section. |
7 | | -private section. |
| 5 | + PUBLIC SECTION. |
| 6 | + INTERFACES z2ui5_if_app. |
| 7 | + |
| 8 | + TYPES: |
| 9 | + BEGIN OF ty_s_msg, |
| 10 | + type TYPE string, |
| 11 | + title TYPE string, |
| 12 | + subtitle TYPE string, |
| 13 | + description TYPE string, |
| 14 | + group TYPE string, |
| 15 | + END OF ty_s_msg. |
| 16 | + DATA t_msg TYPE STANDARD TABLE OF ty_s_msg WITH EMPTY KEY. |
| 17 | + |
| 18 | + PROTECTED SECTION. |
| 19 | + DATA client TYPE REF TO z2ui5_if_client. |
| 20 | + |
| 21 | + METHODS on_init. |
| 22 | + METHODS on_event. |
| 23 | + METHODS view_display. |
| 24 | + METHODS popup_display. |
| 25 | + METHODS popover_display |
| 26 | + IMPORTING |
| 27 | + id TYPE string. |
| 28 | + |
| 29 | + PRIVATE SECTION. |
8 | 30 | ENDCLASS. |
9 | 31 |
|
10 | 32 |
|
| 33 | +CLASS z2ui5_cl_demo_app_038 IMPLEMENTATION. |
| 34 | + |
| 35 | + METHOD z2ui5_if_app~main. |
| 36 | + |
| 37 | + me->client = client. |
| 38 | + IF client->check_on_init( ). |
| 39 | + on_init( ). |
| 40 | + ELSEIF client->check_on_event( ). |
| 41 | + on_event( ). |
| 42 | + ENDIF. |
| 43 | + |
| 44 | + ENDMETHOD. |
| 45 | + |
| 46 | + |
| 47 | + METHOD on_init. |
| 48 | + |
| 49 | + " the original controller reuses the same long description text for every message |
| 50 | + DATA(description) = `First Error message description. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ` && |
| 51 | + `Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. ` && |
| 52 | + `Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ` && |
| 53 | + `Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`. |
| 54 | + |
| 55 | + t_msg = VALUE #( |
| 56 | + ( type = `Error` |
| 57 | + title = `Account 801 requires an assignment` |
| 58 | + subtitle = `Role is invalid` |
| 59 | + description = description |
| 60 | + group = `Purchase Order 450001` ) |
| 61 | + ( type = `Warning` |
| 62 | + title = `Account 821 requires a check` |
| 63 | + subtitle = `Undefined task` |
| 64 | + description = description |
| 65 | + group = `Purchase Order 450001` ) |
| 66 | + ( type = `Warning` |
| 67 | + title = `Enter a text with maximum 6 characters length` |
| 68 | + description = description |
| 69 | + group = `Purchase Order 450002` ) |
| 70 | + ( type = `Warning` |
| 71 | + title = `Enter a text with maximum 8 characters length` |
| 72 | + description = description |
| 73 | + group = `Purchase Order 450002` ) |
| 74 | + ( type = `Error` |
| 75 | + title = `Account 802 requires an assignment` |
| 76 | + subtitle = `Role is invalid` |
| 77 | + description = description |
| 78 | + group = `Purchase Order 450002` ) |
| 79 | + ( type = `Information` |
| 80 | + title = `Account 804 requires an assignment` |
| 81 | + subtitle = `Information type subtitle` |
| 82 | + description = description |
| 83 | + group = `Purchase Order 450002` ) |
| 84 | + ( type = `Error` |
| 85 | + title = `Technical message without object relation` |
| 86 | + description = description |
| 87 | + group = `General` ) |
| 88 | + ( type = `Warning` |
| 89 | + title = `Global System will be down on Sunday` |
| 90 | + description = description |
| 91 | + group = `General` ) |
| 92 | + ( type = `Error` |
| 93 | + title = `Global System will be down on Sunday` |
| 94 | + description = description |
| 95 | + group = `General` ) |
| 96 | + ( type = `Error` |
| 97 | + title = `An Error` |
| 98 | + subtitle = `Ungrouped message` |
| 99 | + description = description ) |
| 100 | + ( type = `Warning` |
| 101 | + title = `A Warning` |
| 102 | + subtitle = `Ungrouped message` |
| 103 | + description = description ) ). |
| 104 | + |
| 105 | + view_display( ). |
| 106 | + |
| 107 | + ENDMETHOD. |
| 108 | + |
| 109 | + |
| 110 | + METHOD on_event. |
| 111 | + |
| 112 | + CASE client->get( )-event. |
| 113 | + WHEN `POPUP`. |
| 114 | + popup_display( ). |
| 115 | + WHEN `POPOVER`. |
| 116 | + popover_display( `messagePopoverBtn` ). |
| 117 | + WHEN `POPOVER_CLOSE`. |
| 118 | + client->popover_destroy( ). |
| 119 | + ENDCASE. |
| 120 | + |
| 121 | + ENDMETHOD. |
| 122 | + |
| 123 | + |
| 124 | + METHOD view_display. |
| 125 | + |
| 126 | + " the original derives the footer button icon and text from the highest message severity via formatters - here Error |
| 127 | + DATA(error_count) = 0. |
| 128 | + LOOP AT t_msg TRANSPORTING NO FIELDS WHERE type = `Error`. |
| 129 | + error_count = error_count + 1. |
| 130 | + ENDLOOP. |
| 131 | + |
| 132 | + DATA(view) = z2ui5_cl_xml_view=>factory( ). |
| 133 | + DATA(page) = view->shell( |
| 134 | + )->page( |
| 135 | + title = `abap2UI5 - Sample: Message View with Grouping` |
| 136 | + navbuttonpress = client->_event_nav_app_leave( ) |
| 137 | + shownavbutton = client->check_app_prev_stack( ) ). |
| 138 | + |
| 139 | + page->header_content( |
| 140 | + )->link( |
| 141 | + text = `UI5 Demo Kit` |
| 142 | + target = `_blank` |
| 143 | + href = `https://sapui5.hana.ondemand.com/sdk/#/entity/sap.m.MessageView/sample/sap.m.sample.MessageViewWithGrouping` ). |
| 144 | + |
| 145 | + page->message_view( |
| 146 | + items = client->_bind( t_msg ) |
| 147 | + groupitems = abap_true |
| 148 | + )->message_item( |
| 149 | + type = `{TYPE}` |
| 150 | + title = `{TITLE}` |
| 151 | + subtitle = `{SUBTITLE}` |
| 152 | + description = `{DESCRIPTION}` |
| 153 | + groupname = `{GROUP}` |
| 154 | + )->link( |
| 155 | + text = `Show more information` |
| 156 | + href = `http://sap.com` |
| 157 | + target = `_blank` ). |
| 158 | + |
| 159 | + " the original renders the footer button with type 'Negative' - the type is only available since UI5 1.73, therefore omitted |
| 160 | + page->footer( )->overflow_toolbar( |
| 161 | + )->button( |
| 162 | + icon = `sap-icon://message-error` |
| 163 | + text = |{ error_count }| |
| 164 | + press = client->_event( `POPUP` ) |
| 165 | + )->toolbar_spacer( |
| 166 | + )->button( |
| 167 | + id = `messagePopoverBtn` |
| 168 | + text = `Message Popover` |
| 169 | + press = client->_event( `POPOVER` ) ). |
| 170 | + |
| 171 | + client->view_display( view->stringify( ) ). |
| 172 | + |
| 173 | + ENDMETHOD. |
| 174 | + |
| 175 | + |
| 176 | + METHOD popup_display. |
| 177 | + |
| 178 | + DATA(popup) = z2ui5_cl_xml_view=>factory_popup( ). |
| 179 | + |
| 180 | + " the original hosts a back button for the message details in a custom header - here the dialog keeps the plain title |
| 181 | + DATA(dialog) = popup->dialog( |
| 182 | + title = `Publish order` |
| 183 | + contentheight = `50%` |
| 184 | + contentwidth = `50%` |
| 185 | + verticalscrolling = abap_false |
| 186 | + afterclose = client->_event_client( client->cs_event-popup_close ) ). |
| 187 | + |
| 188 | + dialog->message_view( |
| 189 | + items = client->_bind( t_msg ) |
| 190 | + groupitems = abap_true |
| 191 | + )->message_item( |
| 192 | + type = `{TYPE}` |
| 193 | + title = `{TITLE}` |
| 194 | + subtitle = `{SUBTITLE}` |
| 195 | + description = `{DESCRIPTION}` |
| 196 | + groupname = `{GROUP}` |
| 197 | + )->link( |
| 198 | + text = `Show more information` |
| 199 | + href = `http://sap.com` |
| 200 | + target = `_blank` ). |
| 201 | + |
| 202 | + dialog->end_button( )->button( |
| 203 | + text = `Close` |
| 204 | + press = client->_event_client( client->cs_event-popup_close ) ). |
| 205 | + |
| 206 | + client->popup_display( popup->stringify( ) ). |
| 207 | + |
| 208 | + ENDMETHOD. |
| 209 | + |
| 210 | + |
| 211 | + METHOD popover_display. |
| 212 | + |
| 213 | + DATA(popup) = z2ui5_cl_xml_view=>factory_popup( ). |
| 214 | + |
| 215 | + popup->message_popover( |
| 216 | + items = client->_bind( t_msg ) |
| 217 | + groupitems = abap_true |
| 218 | + placement = `Top` |
| 219 | + beforeclose = client->_event( `POPOVER_CLOSE` ) |
| 220 | + )->message_item( |
| 221 | + type = `{TYPE}` |
| 222 | + title = `{TITLE}` |
| 223 | + subtitle = `{SUBTITLE}` |
| 224 | + description = `{DESCRIPTION}` |
| 225 | + groupname = `{GROUP}` |
| 226 | + )->link( |
| 227 | + text = `Show more information` |
| 228 | + href = `http://sap.com` |
| 229 | + target = `_blank` ). |
| 230 | + |
| 231 | + client->popover_display( xml = popup->stringify( ) |
| 232 | + by_id = id ). |
| 233 | + |
| 234 | + ENDMETHOD. |
11 | 235 |
|
12 | | -CLASS Z2UI5_CL_DEMO_APP_038 IMPLEMENTATION. |
13 | 236 | ENDCLASS. |
0 commit comments