Message manager (#666)

* added message manager to cc

* abaplint fix
This commit is contained in:
oblomov 2023-11-22 15:08:28 +01:00 committed by GitHub
parent 9d075fc490
commit 774bcde019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 325 additions and 3 deletions

View File

@ -137,7 +137,8 @@ CLASS Z2UI5_CL_FW_APP IMPLEMENTATION.
content->input( placeholder = `fill in the class name and press 'check'`
editable = z2ui5_cl_fw_utility=>boolean_abap_2_json( ms_home-class_editable )
value = client->_bind_edit( ms_home-classname ) ).
value = client->_bind_edit( ms_home-classname )
submit = client->_event( ms_home-btn_event_id ) ).
ELSE.
content->text( ms_home-classname ).

View File

@ -37,6 +37,10 @@ CLASS z2ui5_cl_cc_factory DEFINITION
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_cc_timer.
METHODS messaging
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_cc_messaging.
METHODS title
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_cc_title.
@ -45,6 +49,10 @@ CLASS z2ui5_cl_cc_factory DEFINITION
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_cc_focus.
METHODS scroll
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_cc_scroll.
METHODS info
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_cc_info.
@ -63,6 +71,18 @@ ENDCLASS.
CLASS z2ui5_cl_cc_factory IMPLEMENTATION.
METHOD scroll.
result = NEW #( mo_view ).
ENDMETHOD.
METHOD messaging.
result = NEW #( mo_view ).
ENDMETHOD.
METHOD focus.
result = NEW #( mo_view ).

View File

@ -0,0 +1,160 @@
CLASS z2ui5_cl_cc_messaging DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
TYPES:
BEGIN OF ty_s_item,
message TYPE string,
description TYPE string,
type TYPE string,
target TYPE string,
additionaltext TYPE string,
date TYPE string,
descriptionurl TYPE string,
persistent TYPE string,
END OF ty_s_item.
TYPES ty_t_items TYPE STANDARD TABLE OF ty_s_item WITH DEFAULT KEY ##NEEDED.
METHODS constructor
IMPORTING
view TYPE REF TO z2ui5_cl_xml_view.
METHODS control
IMPORTING
items TYPE clike OPTIONAL
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_xml_view.
METHODS load_cc
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_xml_view.
CLASS-METHODS get_js
RETURNING
VALUE(result) TYPE string.
PROTECTED SECTION.
DATA mo_view TYPE REF TO z2ui5_cl_xml_view.
PRIVATE SECTION.
ENDCLASS.
CLASS Z2UI5_CL_CC_MESSAGING IMPLEMENTATION.
METHOD constructor.
me->mo_view = view.
ENDMETHOD.
METHOD control.
result = mo_view.
mo_view->_generic( name = `Messaging`
ns = `z2ui5`
t_prop = VALUE #( ( n = `items` v = items )
) ).
ENDMETHOD.
METHOD get_js.
result = `debugger; jQuery.sap.declare("z2ui5.Messaging");` && |\n| &&
`sap.ui.require([` && |\n| &&
` "sap/ui/core/Control",` && |\n| &&
` "sap/ui/core/Messaging",` && |\n| &&
`], (Control, Messaging) => {` && |\n| &&
` "use strict";` && |\n| &&
|\n| &&
` return Control.extend("z2ui5.Messaging", {` && |\n| &&
` metadata: {` && |\n| &&
` properties: {` && |\n| &&
` items: { type: "Array" }` && |\n| &&
` }` && |\n| &&
` },` && |\n| &&
` init() {` && |\n| &&
` if (!sap.z2ui5.oMessaging){` && |\n| &&
` sap.z2ui5.oMessaging = {};` && |\n| &&
` sap.z2ui5.oMessaging.oMessageProcessor = new sap.ui.core.message.ControlMessageProcessor();` && |\n| &&
` sap.z2ui5.oMessaging.oMessageManager = sap.ui.getCore().getMessageManager();` && |\n| &&
` sap.z2ui5.oMessaging.oMessageManager.registerMessageProcessor(sap.z2ui5.oMessaging.oMessageProcessor);` && |\n| &&
` }` && |\n| &&
` },` && |\n| &&
|\n| &&
` onModelChange(oEvent) {` && |\n| &&
` this.Messaging2Model();` && |\n| &&
` },` && |\n| &&
|\n| &&
` Messaging2Model( ){` && |\n| &&
` debugger;` && |\n| &&
` var oData = Messaging.getMessageModel().getData();` && |\n| &&
` var Model = [];` && |\n| &&
` oData.forEach(element => {` && |\n| &&
` Model.push( { ` && |\n| &&
` MESSAGE : element.message , ` && |\n| &&
` DESCRIPTION : element.description , ` && |\n| &&
` TYPE : element.type, ` && |\n| &&
` TARGET : element.aTargets[0] , ` && |\n| &&
` ADDITIONALTEXT : element.additionalText , ` && |\n| &&
` DATE : element.date , ` && |\n| &&
` DESCRIPTIONURL : element.descriptionUrl, ` && |\n| &&
` PERSISTENT : element.persistent } );` && |\n| &&
` });` && |\n| &&
` this.setProperty("items", Model );` && |\n| &&
` },` && |\n| &&
|\n| &&
` Model2Messaging( ){` && |\n| &&
` var Model = this.getProperty("items");` && |\n| &&
` if(!Model) { return; }` && |\n| &&
|\n| &&
` Model.forEach(element => {` && |\n| &&
` var target = element.TARGET.split("--")[1];` && |\n| &&
` if ( target == undefined ) { target = element.TARGET }` && |\n| &&
` var oMessage = new sap.ui.core.message.Message({` && |\n| &&
` message: element.MESSAGE,` && |\n| &&
` description: element.DESCRIPTION,` && |\n| &&
` type: element.TYPE,` && |\n| &&
` target : sap.z2ui5.oView.getId( 'testINPUT' ) + '--' + target,` && |\n| &&
` additionalText : element.ADDITIONALTEXT , ` && |\n| &&
` date : element.DATE , ` && |\n| &&
` descriptionUrl : element.DESCRIPTIONURL, ` && |\n| &&
` persistent : element.PERSISTENT,` && |\n| &&
` processor : this.oMessageProcessor` && |\n| &&
` });` && |\n| &&
` Messaging.addMessages(oMessage) ;` && |\n| &&
` });` && |\n| &&
` var resBinding = new sap.ui.model.ListBinding(Messaging.getMessageModel(), "/" );` && |\n| &&
` resBinding.attachChange(this.onModelChange.bind(this));` && |\n| &&
` },` && |\n| &&
|\n| &&
` renderer(oRm, oControl) {` && |\n| &&
` if(oControl.isInitialized) { return; }` && |\n| &&
` oControl.Model2Messaging();` && |\n| &&
` Messaging.registerObject(sap.z2ui5.oView, true);` && |\n| &&
` oControl.isInitialized = true;` && |\n| &&
` setTimeout( (oControl) => { ` && |\n| &&
* ` Messaging.registerObject(sap.z2ui5.oView, true);` && |\n| &&
` ` && |\n| &&
` ` && |\n| &&
` }, 50 , oControl );` && |\n| &&
` }` && |\n| &&
` });` && |\n| &&
`});`.
ENDMETHOD.
METHOD load_cc.
result = mo_view->_generic( ns = `html` name = `script` )->_cc_plain_xml( get_js( ) )->get_parent( ).
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_CC_MESSAGING</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>cc - Messaging</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

View File

@ -0,0 +1,108 @@
CLASS z2ui5_cl_cc_scroll DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
METHODS constructor
IMPORTING
view TYPE REF TO z2ui5_cl_xml_view.
METHODS control
IMPORTING
setUpdate TYPE clike OPTIONAL
items TYPE clike OPTIONAL
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_xml_view.
METHODS load_cc
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_xml_view.
CLASS-METHODS get_js
RETURNING
VALUE(result) TYPE string.
PROTECTED SECTION.
DATA mo_view TYPE REF TO z2ui5_cl_xml_view.
PRIVATE SECTION.
ENDCLASS.
CLASS Z2UI5_CL_CC_SCROLL IMPLEMENTATION.
METHOD constructor.
me->mo_view = view.
ENDMETHOD.
METHOD control.
result = mo_view.
mo_view->_generic( name = `Scroll`
ns = `z2ui5`
t_prop = VALUE #(
( n = `setUpdate` v = setUpdate )
( n = `items` v = items )
) ).
ENDMETHOD.
METHOD get_js.
result = `debugger; jQuery.sap.declare("z2ui5.Scroll");` && |\n| &&
`sap.ui.define([` && |\n| &&
` "sap/ui/core/Control",` && |\n| &&
`], (Control) => {` && |\n| &&
` "use strict";` && |\n| &&
|\n| &&
` return Control.extend("z2u5.Scroll", {` && |\n| &&
` metadata: {` && |\n| &&
` properties: {` && |\n| &&
` setUpdate: { type: "boolean" , defaultValue: true},` && |\n| &&
` items: { type: "Array" },` && |\n| &&
` }` && |\n| &&
` },` && |\n| &&
|\n| &&
` renderer(oRm, oControl) {` && |\n| &&
|\n| &&
` if (!oControl.getProperty("setUpdate")){ return; }` && |\n| &&
|\n| &&
` oControl.setProperty("setUpdate", false);` && |\n| &&
` var items = oControl.getProperty("items");` && |\n| &&
` if(!items){return;};` && |\n| &&
|\n| &&
` setTimeout( (oControl) => { ` && |\n| &&
` var items = oControl.getProperty("items"); ` && |\n| &&
` items.forEach(item => {` && |\n| &&
` try {` && |\n| &&
` sap.z2ui5.oView.byId(item.ID).scrollTo(item.SCROLLTO);` && |\n| &&
` } catch {` && |\n| &&
` try {` && |\n| &&
` var ele = '#' + sap.z2ui5.oView.byId(item.ID).getId() + '-inner';` && |\n| &&
` $(ele).scrollTop(item.SCROLLTO);` && |\n| &&
` } catch { setTimeout( function( item ) { sap.z2ui5.oView.byId(item.ID).scrollTo(item.SCROLLTO); } , 1 , item);}` && |\n| &&
` }` && |\n| &&
` } ` && |\n| &&
` );` && |\n| &&
|\n| &&
` } , 50 , oControl );` && |\n| &&
` }` && |\n| &&
` });` && |\n| &&
`});`.
ENDMETHOD.
METHOD load_cc.
result = mo_view->_generic( ns = `html` name = `script` )->_cc_plain_xml( get_js( ) )->get_parent( ).
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_CC_SCROLL</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>cc - Scrolling</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

View File

@ -443,7 +443,7 @@ CLASS Z2UI5_CL_FW_HTTP_HANDLER IMPLEMENTATION.
` } else {` && |\n| &&
` oView.placeAt("content")` && |\n| &&
` };` && |\n| &&
` sap.ui.getCore().getMessageManager().registerObject(oView, true);` && |\n| &&
` sap.ui.getCore().getMessageManager().registerObject(oView, true);` && |\n| &&
` sap.z2ui5.oView = oView;` && |\n| &&
` },` && |\n| &&
` );` && |\n| &&
@ -469,7 +469,8 @@ CLASS Z2UI5_CL_FW_HTTP_HANDLER IMPLEMENTATION.
` }` && |\n| &&
` if (sap.z2ui5.oResponse.PARAMS.S_MESSAGE_MANAGER.CHECK_CLEAR == true) {` && |\n| &&
` sap.ui.getCore().getMessageManager().removeAllMessages(); ` && |\n| &&
` sap.ui.getCore().getMessageManager().registerObject(oView, true); } ` && |\n| &&
` sap.ui.getCore().getMessageManager().registerObject(oView, true); ` && |\n| &&
` } ` && |\n| &&
` if (sap.z2ui5.oResponse.PARAMS.S_MESSAGE_MANAGER.T_MESSAGE != "") {` && |\n| &&
` sap.z2ui5.oResponse.PARAMS.S_MESSAGE_MANAGER.T_MESSAGE.forEach( item => { ` && |\n| &&
` sap.ui.getCore().getMessageManager().addMessages( new sap.ui.core.message.Message({` && |\n| &&