|
| 1 | +CLASS z2ui5_cl_demo_app_084 DEFINITION PUBLIC. |
| 2 | + |
| 3 | + PUBLIC SECTION. |
| 4 | + |
| 5 | + INTERFACES z2ui5_if_app. |
| 6 | + |
| 7 | + DATA: |
| 8 | + BEGIN OF screen, |
| 9 | + check_is_active TYPE abap_bool, |
| 10 | + colour TYPE string, |
| 11 | + combo_key TYPE string, |
| 12 | + combo_key2 TYPE string, |
| 13 | + segment_key TYPE string, |
| 14 | + date TYPE string, |
| 15 | + date_time TYPE string, |
| 16 | + time_start TYPE string, |
| 17 | + time_end TYPE string, |
| 18 | + check_switch_01 TYPE abap_bool VALUE abap_false, |
| 19 | + check_switch_02 TYPE abap_bool VALUE abap_false, |
| 20 | + END OF screen. |
| 21 | + |
| 22 | + TYPES: |
| 23 | + BEGIN OF s_suggestion_items, |
| 24 | + value TYPE string, |
| 25 | + descr TYPE string, |
| 26 | + END OF s_suggestion_items. |
| 27 | + DATA mt_suggestion TYPE STANDARD TABLE OF s_suggestion_items WITH EMPTY KEY. |
| 28 | + |
| 29 | + TYPES: |
| 30 | + BEGIN OF s_combobox, |
| 31 | + key TYPE string, |
| 32 | + text TYPE string, |
| 33 | + END OF s_combobox. |
| 34 | + |
| 35 | + TYPES ty_t_combo TYPE STANDARD TABLE OF s_combobox WITH EMPTY KEY. |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + DATA check_initialized TYPE abap_bool. |
| 40 | + |
| 41 | + DATA client TYPE REF TO z2ui5_if_client. |
| 42 | + |
| 43 | + PROTECTED SECTION. |
| 44 | + |
| 45 | + METHODS z2ui5_on_rendering. |
| 46 | + METHODS z2ui5_on_event. |
| 47 | + METHODS z2ui5_on_init. |
| 48 | + |
| 49 | + PRIVATE SECTION. |
| 50 | +ENDCLASS. |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | +CLASS z2ui5_cl_demo_app_084 IMPLEMENTATION. |
| 55 | + |
| 56 | + |
| 57 | + METHOD z2ui5_if_app~main. |
| 58 | + |
| 59 | + me->client = client. |
| 60 | + |
| 61 | + IF check_initialized = abap_false. |
| 62 | + check_initialized = abap_true. |
| 63 | + |
| 64 | + DATA(lv_script) = `` && |\n| && |
| 65 | + `function setInputFIlter(){` && |\n| && |
| 66 | + ` var inp = sap.z2ui5.oView.byId('suggInput');` && |\n| && |
| 67 | + ` inp.setFilterFunction(function(sValue, oItem){` && |\n| && |
| 68 | + ` var aSplit = sValue.split(" ");` && |\n| && |
| 69 | + ` if (aSplit.length > 0) {` && |\n| && |
| 70 | + ` var sTermNew = aSplit.slice(-1)[0];` && |\n| && |
| 71 | + ` sTermNew.trim();` && |\n| && |
| 72 | + ` if (sTermNew) {` && |\n| && |
| 73 | + ` return oItem.getText().match(new RegExp(sTermNew, "i"));` && |\n| && |
| 74 | + ` }` && |\n| && |
| 75 | + ` }` && |\n| && |
| 76 | + ` });` && |\n| && |
| 77 | + `}`. |
| 78 | + |
| 79 | + |
| 80 | + client->view_display( z2ui5_cl_xml_view=>factory( |
| 81 | + )->_z2ui5( )->timer( client->_event( `START` ) |
| 82 | + )->_generic( ns = `html` name = `script` )->_cc_plain_xml( lv_script |
| 83 | + )->stringify( ) ). |
| 84 | + |
| 85 | + |
| 86 | + z2ui5_on_init( ). |
| 87 | + RETURN. |
| 88 | + ENDIF. |
| 89 | + |
| 90 | + z2ui5_on_event( ). |
| 91 | + |
| 92 | + ENDMETHOD. |
| 93 | + |
| 94 | + |
| 95 | + METHOD z2ui5_on_event. |
| 96 | + |
| 97 | + CASE client->get( )-event. |
| 98 | + WHEN 'START'. |
| 99 | + z2ui5_on_rendering( ). |
| 100 | + WHEN 'BUTTON_MCUSTOM'. |
| 101 | +* send type = '' is mandatory in order to not break current implementation |
| 102 | + client->message_box_display( type = '' text = 'Custom MessageBox' icon = `SUCCESS` |
| 103 | + title = 'Custom MessageBox' actions = VALUE #( ( `First Button` ) ( `Second Button` ) ) emphasizedaction = `First Button` |
| 104 | + onclose = `callMessageToast()` details = `<h3>these are details</h3>`). |
| 105 | + WHEN 'BUTTON_MCONFIRM'. |
| 106 | + client->message_box_display( type = 'confirm' text = 'Confirm MessageBox' ). |
| 107 | + WHEN 'BUTTON_MALERT'. |
| 108 | + client->message_box_display( type = 'alert' text = 'Alert MessageBox' ). |
| 109 | + WHEN 'BUTTON_MERROR'. |
| 110 | + client->message_box_display( type = 'error' text = 'Error MessageBox' ). |
| 111 | + WHEN 'BUTTON_MINFO'. |
| 112 | + client->message_box_display( type = 'information' text = 'Information MessageBox' ). |
| 113 | + WHEN 'BUTTON_MWARNING'. |
| 114 | + client->message_box_display( type = 'warning' text = 'Warning MessageBox' ). |
| 115 | + WHEN 'BUTTON_MSUCCESS'. |
| 116 | + client->message_box_display( type = 'success' text = 'Success MessageBox' icon = `sap-icon://accept` ). |
| 117 | + WHEN 'BUTTON_SEND'. |
| 118 | + client->message_box_display( 'success - values send to the server' ). |
| 119 | + WHEN 'BUTTON_CLEAR'. |
| 120 | + CLEAR screen. |
| 121 | + client->message_toast_display( 'View initialized' ). |
| 122 | + WHEN 'BACK'. |
| 123 | + client->nav_app_leave( ). |
| 124 | + |
| 125 | + ENDCASE. |
| 126 | + |
| 127 | + ENDMETHOD. |
| 128 | + |
| 129 | + |
| 130 | + METHOD z2ui5_on_init. |
| 131 | + |
| 132 | + screen = VALUE #( |
| 133 | + check_is_active = abap_true |
| 134 | + colour = 'BLUE' |
| 135 | + combo_key = 'GRAY' |
| 136 | + segment_key = 'GREEN' |
| 137 | + date = '07.12.22' |
| 138 | + date_time = '23.12.2022, 19:27:20' |
| 139 | + time_start = '05:24:00' |
| 140 | + time_end = '17:23:57'). |
| 141 | + |
| 142 | + mt_suggestion = VALUE #( |
| 143 | + ( descr = 'Green' value = 'GREEN' ) |
| 144 | + ( descr = 'Blue' value = 'BLUE' ) |
| 145 | + ( descr = 'Black' value = 'BLACK' ) |
| 146 | + ( descr = 'Gray' value = 'GRAY' ) |
| 147 | + ( descr = 'Blue2' value = 'BLUE2' ) |
| 148 | + ( descr = 'Blue3' value = 'BLUE3' ) ). |
| 149 | + |
| 150 | + ENDMETHOD. |
| 151 | + |
| 152 | + |
| 153 | + METHOD z2ui5_on_rendering. |
| 154 | + |
| 155 | + DATA(view) = z2ui5_cl_xml_view=>factory( ). |
| 156 | + view->_generic( name = `script` ns = `html` )->_cc_plain_xml( `function callMessageToast(sAction) { sap.m.MessageToast.show('Hello there !!'); }` ). |
| 157 | + DATA(page) = view->shell( |
| 158 | + )->page( |
| 159 | + showheader = xsdbool( abap_false = client->get( )-check_launchpad_active ) |
| 160 | + title = 'abap2UI5 - Selection-Screen Example' |
| 161 | + navbuttonpress = client->_event( 'BACK' ) |
| 162 | + shownavbutton = xsdbool( client->get( )-s_draft-id_prev_app_stack IS NOT INITIAL ) |
| 163 | + ). |
| 164 | + |
| 165 | + DATA(grid) = page->grid( 'L6 M12 S12' |
| 166 | + )->content( 'layout' ). |
| 167 | + |
| 168 | + grid->simple_form( title = 'Input' editable = abap_true |
| 169 | + )->content( 'form' |
| 170 | + )->label( 'Input with suggestion items' |
| 171 | + )->input( |
| 172 | + id = `suggInput` |
| 173 | + value = client->_bind_edit( screen-colour ) |
| 174 | + placeholder = 'Fill in your favorite color' |
| 175 | + suggestionitems = client->_bind( mt_suggestion ) |
| 176 | + showsuggestion = abap_true )->get( |
| 177 | + )->suggestion_items( )->get( |
| 178 | + )->list_item( |
| 179 | + text = '{VALUE}' |
| 180 | + additionaltext = '{DESCR}' ). |
| 181 | + |
| 182 | + page->footer( )->overflow_toolbar( |
| 183 | + )->text( text = `MessageBox Types` |
| 184 | + )->button( |
| 185 | + text = 'Confirm' |
| 186 | + press = client->_event( 'BUTTON_MCONFIRM' ) |
| 187 | + )->button( |
| 188 | + text = 'Alert' |
| 189 | + press = client->_event( 'BUTTON_MALERT' ) |
| 190 | + )->button( |
| 191 | + text = 'Error' |
| 192 | + press = client->_event( 'BUTTON_MERROR' ) |
| 193 | + )->button( |
| 194 | + text = 'Information' |
| 195 | + press = client->_event( 'BUTTON_MINFO' ) |
| 196 | + )->button( |
| 197 | + text = 'Warning' |
| 198 | + press = client->_event( 'BUTTON_MWARNING' ) |
| 199 | + )->button( |
| 200 | + text = 'Success' |
| 201 | + press = client->_event( 'BUTTON_MSUCCESS' ) |
| 202 | + )->button( |
| 203 | + text = 'Custom' |
| 204 | + press = client->_event( 'BUTTON_MCUSTOM' ) |
| 205 | + )->toolbar_spacer( |
| 206 | + )->button( |
| 207 | + text = 'Clear' |
| 208 | + press = client->_event( 'BUTTON_CLEAR' ) |
| 209 | + type = 'Reject' |
| 210 | + icon = 'sap-icon://delete' |
| 211 | + )->button( |
| 212 | + text = 'Send to Server' |
| 213 | + press = client->_event( 'BUTTON_SEND' ) |
| 214 | + type = 'Success' ). |
| 215 | + |
| 216 | + |
| 217 | + view->_generic( name = `script` ns = `html` )->_cc_plain_xml( `setInputFIlter()` ). |
| 218 | + |
| 219 | + client->view_display( page->stringify( ) ). |
| 220 | + |
| 221 | + ENDMETHOD. |
| 222 | +ENDCLASS. |
0 commit comments