new-multiinput-with-backend-token-handling (#733)

This commit is contained in:
oblomov 2023-12-18 15:13:37 +01:00 committed by GitHub
parent 8536b2f4ef
commit 264ff24038
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 138 additions and 2 deletions

View File

@ -26,7 +26,8 @@ CLASS Z2UI5_CL_FW_CC_FACTORY IMPLEMENTATION.
z2ui5_cl_fw_cc_info_frontend=>get_js( ) &&
z2ui5_cl_fw_cc_geolocation=>get_js( ) &&
Z2UI5_CL_FW_CC_DEV_TOOLS=>get_js( ) &&
z2ui5_cl_fw_cc_file_uploader=>get_js( ).
z2ui5_cl_fw_cc_file_uploader=>get_js( ) &&
z2ui5_cl_fw_cc_multiinput=>get_js( ).
ENDMETHOD.
ENDCLASS.

View File

@ -0,0 +1,74 @@
CLASS z2ui5_cl_fw_cc_multiinput DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .
PUBLIC SECTION.
class-methods get_js
RETURNING
value(result) type string.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS z2ui5_cl_fw_cc_multiinput IMPLEMENTATION.
METHOD get_js.
result = `jQuery.sap.declare("z2ui5.MultiInput"); sap.ui.define([` && |\n| &&
` "sap/m/MultiInput"` && |\n| &&
`], (MultiInput) => {` && |\n| &&
` "use strict";` && |\n| &&
|\n| &&
` return MultiInput.extend("z2ui5.MultiInput", {` && |\n| &&
` metadata: {` && |\n| &&
` properties: {` && |\n| &&
` addedTokens: { type: "Array" },` && |\n| &&
` removedTokens: { type: "Array" }` && |\n| &&
` }` && |\n| &&
` },` && |\n| &&
|\n| &&
` init() {` && |\n| &&
` MultiInput.prototype.init.call(this);` && |\n| &&
` this.attachTokenUpdate(this.onTokenUpdate);` && |\n| &&
|\n| &&
` var fnValidator = function (args) {` && |\n| &&
` var text = args.text;` && |\n| &&
` return new sap.m.Token({ key: text, text: text });` && |\n| &&
` };` && |\n| &&
|\n| &&
` this.addValidator(fnValidator);` && |\n| &&
` },` && |\n| &&
|\n| &&
` onTokenUpdate(oEvent) {` && |\n| &&
` this.setProperty("addedTokens", []);` && |\n| &&
` this.setProperty("removedTokens", []);` && |\n| &&
|\n| &&
` if (oEvent.mParameters.type == "removed") {` && |\n| &&
` let removedTokens = [];` && |\n| &&
` oEvent.mParameters.removedTokens.forEach((item) => {` && |\n| &&
` removedTokens.push({ KEY: item.getKey(), TEXT: item.getText() });` && |\n| &&
` });` && |\n| &&
` this.setProperty("removedTokens", removedTokens);` && |\n| &&
` } else {` && |\n| &&
` let addedTokens = [];` && |\n| &&
` oEvent.mParameters.addedTokens.forEach((item) => {` && |\n| &&
` addedTokens.push({ KEY: item.getKey(), TEXT: item.getText() });` && |\n| &&
` });` && |\n| &&
` this.setProperty("addedTokens", addedTokens);` && |\n| &&
` }` && |\n| &&
` },` && |\n| &&
|\n| &&
` renderer(oRM, oControl) {` && |\n| &&
` sap.m.MultiInputRenderer.render(oRM, oControl);` && |\n| &&
|\n| &&
` }` && |\n| &&
` });` && |\n| &&
`});`.
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_FW_CC_MULTIINPUT</CLSNAME>
<LANGU>E</LANGU>
<DESCRIPT>cc MultiInput</DESCRIPT>
<STATE>1</STATE>
<CLSCCINCL>X</CLSCCINCL>
<FIXPT>X</FIXPT>
<UNICODE>X</UNICODE>
</VSEOCLASS>
</asx:values>
</asx:abap>
</abapGit>

View File

@ -424,6 +424,8 @@ public section.
returning
value(RESULT) type ref to Z2UI5_CL_XML_VIEW .
methods TOKENS
importing
ns type clike optional
returning
value(RESULT) type ref to Z2UI5_CL_XML_VIEW .
methods TOKEN
@ -6877,7 +6879,7 @@ CLASS Z2UI5_CL_XML_VIEW IMPLEMENTATION.
METHOD tokens.
result = _generic( `tokens` ).
result = _generic( name = `tokens` ns = ns ).
ENDMETHOD.

View File

@ -5,6 +5,27 @@ CLASS z2ui5_cl_xml_view_cc DEFINITION
PUBLIC SECTION.
METHODS multiinput
IMPORTING
!showclearicon TYPE clike OPTIONAL
!showvaluehelp TYPE clike OPTIONAL
!suggestionitems TYPE clike OPTIONAL
!tokenupdate TYPE clike OPTIONAL
!width TYPE clike OPTIONAL
!id TYPE clike OPTIONAL
!value TYPE clike OPTIONAL
!tokens TYPE clike OPTIONAL
!submit TYPE clike OPTIONAL
!valuehelprequest TYPE clike OPTIONAL
!enabled TYPE clike OPTIONAL
!class TYPE clike OPTIONAL
!change TYPE clike OPTIONAL
!addedTokens TYPE clike OPTIONAL
!removedTokens TYPE clike OPTIONAL
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_xml_view .
METHODS camera_picture
IMPORTING
!id TYPE clike OPTIONAL
@ -22,11 +43,13 @@ CLASS z2ui5_cl_xml_view_cc DEFINITION
!height TYPE clike OPTIONAL
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_xml_view .
METHODS demo_output
IMPORTING
!val TYPE clike OPTIONAL
RETURNING
VALUE(result) TYPE REF TO z2ui5_cl_xml_view .
METHODS focus
IMPORTING
!focusid TYPE clike OPTIONAL
@ -318,4 +341,24 @@ CLASS z2ui5_cl_xml_view_cc IMPLEMENTATION.
t_prop = VALUE #( ( n = `title` v = title ) ) ).
ENDMETHOD.
METHOD multiinput.
result = mo_view->_generic( name = `MultiInput` ns = `z2ui5`
t_prop = VALUE #( ( n = `tokens` v = tokens )
( n = `showClearIcon` v = z2ui5_cl_util_func=>boolean_abap_2_json( showclearicon ) )
( n = `showValueHelp` v = z2ui5_cl_util_func=>boolean_abap_2_json( showvaluehelp ) )
( n = `enabled` v = z2ui5_cl_util_func=>boolean_abap_2_json( enabled ) )
( n = `suggestionItems` v = suggestionitems )
( n = `tokenUpdate` v = tokenupdate )
( n = `submit` v = submit )
( n = `width` v = width )
( n = `value` v = value )
( n = `id` v = id )
( n = `change` v = change )
( n = `valueHelpRequest` v = valuehelprequest )
( n = `addedTokens` v = addedTokens )
( n = `removedTokens` v = removedTokens )
( n = `class` v = class ) ) ).
ENDMETHOD.
ENDCLASS.