popup-html (#1003)

This commit is contained in:
oblomov 2024-03-10 17:09:15 -04:00 committed by GitHub
parent 0a6b38e7ee
commit ace5fbfe7e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 130 additions and 7 deletions

View File

@ -98,10 +98,14 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.
mo_action->ms_next-o_app_call = app.
result = COND #( WHEN app->id_draft IS INITIAL
THEN z2ui5_cl_util=>uuid_get_c32( )
ELSE app->id_app ).
* result = COND #( WHEN app->id_draft IS INITIAL
* THEN z2ui5_cl_util=>uuid_get_c32( )
* ELSE app->id_app ).
IF app->id_app IS INITIAL.
app->id_app = z2ui5_cl_util=>uuid_get_c32( ).
ENDIF.
result = app->id_app.
ENDMETHOD.
@ -113,9 +117,14 @@ CLASS z2ui5_cl_core_client IMPLEMENTATION.
mo_action->ms_next-o_app_leave = app.
result = COND #( WHEN app->id_draft IS INITIAL
THEN z2ui5_cl_util=>uuid_get_c32( )
ELSE app->id_app ).
* result = COND #( WHEN app->id_draft IS INITIAL
* THEN z2ui5_cl_util=>uuid_get_c32( )
* ELSE app->id_app ).
IF app->id_app IS INITIAL.
app->id_app = z2ui5_cl_util=>uuid_get_c32( ).
ENDIF.
result = app->id_app.
ENDMETHOD.

View File

@ -407,6 +407,7 @@ CLASS Z2UI5_CL_CORE_HTTP_GET IMPLEMENTATION.
` id: 'mainView',` && |\n| &&
` preprocessors: { xml: { models: { template: oview_model } } }` && |\n| &&
` });` && |\n| &&
` sap.z2ui5.oView.setModel(sap.z2ui5.oDeviceModel, "device");` && |\n| &&
` if (sap.z2ui5.oParent) {` && |\n| &&
` sap.z2ui5.oParent.removeAllPages();` && |\n| &&
` sap.z2ui5.oParent.insertPage(sap.z2ui5.oView);` && |\n| &&
@ -469,7 +470,8 @@ CLASS Z2UI5_CL_CORE_HTTP_GET IMPLEMENTATION.
` },` && |\n| &&
` })` && |\n| &&
`});` && |\n| &&
`sap.ui.require(["z2ui5/Controller", "sap/ui/core/BusyIndicator", "sap/ui/core/mvc/XMLView", "sap/ui/core/Fragment", "sap/m/MessageToast", "sap/m/MessageBox", "sap/ui/model/json/JSONModel"], (Controller,BusyIndicator)=>{` && |\n| &&
`sap.ui.require(["z2ui5/Controller", "sap/ui/core/BusyIndicator", "sap/ui/model/json/JSONModel", "sap/ui/core/mvc/XMLView", "sap/ui/core/Fragment", "sap/m/MessageToast", "sap/m/MessageBox"], (Controller,BusyIndicator, JSONModel)=>{` &&
|\n| &&
` BusyIndicator.show();` && |\n| &&
` sap.z2ui5.oController = new Controller();` && |\n| &&
` sap.z2ui5.oControllerNest = new Controller();` && |\n| &&
@ -486,6 +488,17 @@ CLASS Z2UI5_CL_CORE_HTTP_GET IMPLEMENTATION.
` sap.z2ui5.onAfterRendering = [];` && |\n| &&
` sap.z2ui5.onBeforeEventFrontend = [];` && |\n| &&
` sap.z2ui5.onAfterRoundtrip = []; ` && |\n| &&
* ` // set device model` && |\n| &&
* ` sap.z2ui5.oDeviceModel = new JSONModel({` && |\n| &&
* ` isTouch : sap.ui.Device.support.touch,` && |\n| &&
* ` isNoTouch : !sap.ui.Device.support.touch,` && |\n| &&
* ` isPhone : sap.ui.Device.system.phone,` && |\n| &&
* ` isNoPhone : !sap.ui.Device.system.phone,` && |\n| &&
* ` listMode : sap.ui.Device.system.phone ? "None" : "SingleSelectMaster",` && |\n| &&
* ` listItemType : sap.ui.Device.system.phone ? "Active" : "Inactive"` && |\n| &&
* ` });` && |\n| &&
* ` sap.z2ui5.oDeviceModel.setDefaultBindingMode("OneWay");` && |\n| &&
` ` && |\n| &&
` }` && |\n| &&
`);`.

View File

@ -0,0 +1,85 @@
CLASS z2ui5_cl_popup_html DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
INTERFACES z2ui5_if_app.
CLASS-METHODS factory
IMPORTING
i_html TYPE string
i_title TYPE string DEFAULT `Title`
i_icon TYPE string DEFAULT 'sap-icon://question-mark'
i_button_text TYPE string DEFAULT `OK`
RETURNING
VALUE(r_result) TYPE REF TO z2ui5_cl_popup_html.
PROTECTED SECTION.
DATA client TYPE REF TO z2ui5_if_client.
DATA title TYPE string.
DATA icon TYPE string.
DATA html TYPE string.
DATA button_text_confirm TYPE string.
DATA check_initialized TYPE abap_bool.
METHODS view_display.
PRIVATE SECTION.
ENDCLASS.
CLASS Z2UI5_CL_POPUP_HTML IMPLEMENTATION.
METHOD factory.
r_result = NEW #( ).
r_result->title = i_title.
r_result->icon = i_icon.
r_result->html = i_html.
r_result->button_text_confirm = i_button_text.
ENDMETHOD.
METHOD view_display.
DATA(popup) = z2ui5_cl_xml_view=>factory_popup( )->dialog(
title = title
icon = icon
afterclose = client->_event( 'BUTTON_CONFIRM' )
)->content(
)->vbox( 'sapUiMediumMargin'
)->html( html
)->get_parent( )->get_parent( )->get_parent(
)->buttons(
)->button(
text = button_text_confirm
press = client->_event( 'BUTTON_CONFIRM' )
type = 'Emphasized' ).
client->popup_display( popup->stringify( ) ).
ENDMETHOD.
METHOD z2ui5_if_app~main.
me->client = client.
IF check_initialized = abap_false.
check_initialized = abap_true.
view_display( ).
RETURN.
ENDIF.
CASE client->get( )-event.
WHEN `BUTTON_CONFIRM`.
client->popup_destroy( ).
client->nav_app_leave( client->get_app( client->get( )-s_draft-id_prev_app_stack ) ).
WHEN OTHERS.
ENDCASE.
ENDMETHOD.
ENDCLASS.

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_CLAS" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<VSEOCLASS>
<CLSNAME>Z2UI5_CL_POPUP_HTML</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>ui - popup html</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>