mirror of
https://github.com/abap2UI5/abap2UI5.git
synced 2025-04-29 23:06:30 +08:00
new view parser (#679)
This commit is contained in:
parent
1a2b0c8e18
commit
d2ca457372
|
@ -46,8 +46,8 @@ CLASS z2ui5_cl_ui5 DEFINITION
|
|||
METHODS _ns_suite
|
||||
RETURNING VALUE(result) TYPE REF TO z2ui5_cl_ui5_suite.
|
||||
|
||||
METHODS _ns_zcc
|
||||
RETURNING VALUE(result) TYPE REF TO z2ui5_cl_ui5_ui.
|
||||
METHODS _ns_z2ui5
|
||||
RETURNING VALUE(result) TYPE REF TO z2ui5_cl_ui5_z2ui5.
|
||||
|
||||
METHODS _ns_html
|
||||
RETURNING VALUE(result) TYPE REF TO z2ui5_cl_ui5_html.
|
||||
|
@ -272,7 +272,7 @@ CLASS z2ui5_cl_ui5 IMPLEMENTATION.
|
|||
result = NEW #( _node ).
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD _ns_zcc.
|
||||
METHOD _ns_z2ui5.
|
||||
result = NEW #( _node ).
|
||||
ENDMETHOD.
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ CLASS ltcl_unit_test IMPLEMENTATION.
|
|||
DATA(lo_m) = NEW z2ui5_cl_ui5( )->_ns_m( ) ##NEEDED.
|
||||
DATA(lo_ndc) = NEW z2ui5_cl_ui5( )->_ns_ndc( ) ##NEEDED.
|
||||
DATA(lo_suite) = NEW z2ui5_cl_ui5( )->_ns_suite( ) ##NEEDED.
|
||||
DATA(lo_zcc) = NEW z2ui5_cl_ui5( )->_ns_zcc( ) ##NEEDED.
|
||||
DATA(lo_zcc) = NEW z2ui5_cl_ui5( )->_ns_z2ui5( ) ##NEEDED.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ CLASS z2ui5_cl_ui5_ui IMPLEMENTATION.
|
|||
( n = `icon` v = icon )
|
||||
( n = `key` v = key )
|
||||
( n = `textDirection` v = textdirection )
|
||||
( n = `enabled` v = z2ui5_cl_fw_utility=>boolean_abap_2_json( enabled ) )
|
||||
( n = `enabled` v = _2bool( enabled ) )
|
||||
( n = `additionalText` v = additionaltext ) ) ).
|
||||
ENDMETHOD.
|
||||
|
||||
|
@ -85,7 +85,7 @@ CLASS z2ui5_cl_ui5_ui IMPLEMENTATION.
|
|||
ns = `sap.ui.codeeditor`
|
||||
t_p = VALUE #( ( n = `value` v = value )
|
||||
( n = `type` v = type )
|
||||
( n = `editable` v = z2ui5_cl_fw_utility=>boolean_abap_2_json( editable ) )
|
||||
( n = `editable` v = _2bool( editable ) )
|
||||
( n = `height` v = height )
|
||||
( n = `width` v = width ) ) )->_ns_ui( ).
|
||||
ENDMETHOD.
|
||||
|
|
70
src/02/z2ui5_cl_ui5_z2ui5.clas.abap
Normal file
70
src/02/z2ui5_cl_ui5_z2ui5.clas.abap
Normal file
|
@ -0,0 +1,70 @@
|
|||
CLASS z2ui5_cl_ui5_z2ui5 DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC INHERITING FROM z2ui5_cl_ui5.
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
||||
METHODS file_uploader
|
||||
IMPORTING
|
||||
!value TYPE clike OPTIONAL
|
||||
!path TYPE clike OPTIONAL
|
||||
!placeholder TYPE clike OPTIONAL
|
||||
!upload TYPE clike OPTIONAL
|
||||
!icononly TYPE clike OPTIONAL
|
||||
!buttononly TYPE clike OPTIONAL
|
||||
!buttontext TYPE clike OPTIONAL
|
||||
!uploadbuttontext TYPE clike OPTIONAL
|
||||
!checkdirectupload TYPE clike OPTIONAL
|
||||
!filetype TYPE clike OPTIONAL
|
||||
RETURNING
|
||||
VALUE(result) TYPE REF TO z2ui5_cl_ui5_z2ui5.
|
||||
|
||||
METHODS timer
|
||||
IMPORTING
|
||||
finished TYPE clike OPTIONAL
|
||||
delayms TYPE clike OPTIONAL
|
||||
checkrepeat TYPE clike OPTIONAL
|
||||
PREFERRED PARAMETER finished
|
||||
RETURNING
|
||||
VALUE(result) TYPE REF TO z2ui5_cl_ui5_z2ui5.
|
||||
|
||||
PROTECTED SECTION.
|
||||
PRIVATE SECTION.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS z2ui5_cl_ui5_z2ui5 IMPLEMENTATION.
|
||||
|
||||
METHOD timer.
|
||||
|
||||
result = me.
|
||||
_add( n = `Timer`
|
||||
ns = `z2ui5`
|
||||
t_p = VALUE #( ( n = `delayMS` v = delayms )
|
||||
( n = `finished` v = finished )
|
||||
( n = `checkRepeat` v = _2bool( checkrepeat ) )
|
||||
) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD file_uploader.
|
||||
|
||||
result = me.
|
||||
_add( n = `FileUploader`
|
||||
ns = `z2ui5`
|
||||
t_p = VALUE #( ( n = `placeholder` v = placeholder )
|
||||
( n = `upload` v = upload )
|
||||
( n = `path` v = path )
|
||||
( n = `value` v = value )
|
||||
( n = `iconOnly` v = _2bool( icononly ) )
|
||||
( n = `buttonOnly` v = _2bool( buttononly ) )
|
||||
( n = `buttonText` v = buttontext )
|
||||
( n = `uploadButtonText` v = uploadbuttontext )
|
||||
( n = `fileType` v = filetype )
|
||||
( n = `checkDirectUpload` v = _2bool( checkdirectupload ) ) ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
|
@ -3,7 +3,7 @@
|
|||
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
|
||||
<asx:values>
|
||||
<VSEOCLASS>
|
||||
<CLSNAME>Z2UI5_CL_UI5_ZCC</CLSNAME>
|
||||
<CLSNAME>Z2UI5_CL_UI5_Z2UI5</CLSNAME>
|
||||
<LANGU>E</LANGU>
|
||||
<DESCRIPT>ns - z2ui5 (custom)</DESCRIPT>
|
||||
<STATE>1</STATE>
|
|
@ -1,16 +0,0 @@
|
|||
CLASS z2ui5_cl_ui5_zcc DEFINITION
|
||||
PUBLIC
|
||||
FINAL
|
||||
CREATE PUBLIC INHERITING FROM z2ui5_cl_ui5.
|
||||
|
||||
PUBLIC SECTION.
|
||||
|
||||
|
||||
PROTECTED SECTION.
|
||||
PRIVATE SECTION.
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS Z2UI5_CL_UI5_ZCC IMPLEMENTATION.
|
||||
ENDCLASS.
|
|
@ -16,31 +16,36 @@ CLASS z2ui5_cl_cc_file_uploader DEFINITION
|
|||
!buttontext TYPE clike OPTIONAL
|
||||
!uploadbuttontext TYPE clike OPTIONAL
|
||||
!checkdirectupload TYPE clike OPTIONAL
|
||||
!filetype TYPE clike OPTIONAL
|
||||
!filetype TYPE clike OPTIONAL
|
||||
RETURNING
|
||||
VALUE(result) TYPE REF TO z2ui5_cl_xml_view .
|
||||
VALUE(result) TYPE REF TO z2ui5_cl_xml_view.
|
||||
|
||||
METHODS constructor
|
||||
IMPORTING
|
||||
view TYPE REF TO z2ui5_cl_xml_view.
|
||||
|
||||
METHODS load_cc
|
||||
RETURNING
|
||||
VALUE(result) TYPE REF TO z2ui5_cl_xml_view .
|
||||
VALUE(result) TYPE REF TO z2ui5_cl_xml_view.
|
||||
|
||||
CLASS-METHODS get_js
|
||||
RETURNING
|
||||
VALUE(r_js) TYPE string.
|
||||
|
||||
PROTECTED SECTION.
|
||||
DATA mo_view TYPE REF TO z2ui5_cl_xml_view.
|
||||
DATA mo_view TYPE REF TO z2ui5_cl_xml_view.
|
||||
PRIVATE SECTION.
|
||||
|
||||
ENDCLASS.
|
||||
|
||||
|
||||
|
||||
CLASS Z2UI5_CL_CC_FILE_UPLOADER IMPLEMENTATION.
|
||||
CLASS z2ui5_cl_cc_file_uploader IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD CONSTRUCTOR.
|
||||
METHOD constructor.
|
||||
|
||||
ME->MO_VIEW = VIEW.
|
||||
me->mo_view = view.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
@ -66,160 +71,166 @@ CLASS Z2UI5_CL_CC_FILE_UPLOADER IMPLEMENTATION.
|
|||
|
||||
METHOD load_cc.
|
||||
|
||||
DATA(js) = `jQuery.sap.declare("z2ui5.FileUploader");` && |\n| &&
|
||||
|\n| &&
|
||||
` sap.ui.require([` && |\n| &&
|
||||
` "sap/ui/core/Control",` && |\n| &&
|
||||
` "sap/m/Button",` && |\n| &&
|
||||
` "sap/ui/unified/FileUploader"` && |\n| &&
|
||||
` ], function (Control, Button, FileUploader) {` && |\n| &&
|
||||
` "use strict";` && |\n| &&
|
||||
|\n| &&
|
||||
` return Control.extend("z2ui5.FileUploader", {` && |\n| &&
|
||||
|\n| &&
|
||||
` metadata: {` && |\n| &&
|
||||
` properties: {` && |\n| &&
|
||||
` value: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` path: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` tooltip: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` fileType: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` placeholder: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` buttonText: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` uploadButtonText: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: "Upload"` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` enabled: {` && |\n| &&
|
||||
` type: "boolean",` && |\n| &&
|
||||
` defaultValue: true` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` iconOnly: {` && |\n| &&
|
||||
` type: "boolean",` && |\n| &&
|
||||
` defaultValue: false` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` buttonOnly: {` && |\n| &&
|
||||
` type: "boolean",` && |\n| &&
|
||||
` defaultValue: false` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` multiple: {` && |\n| &&
|
||||
` type: "boolean",` && |\n| &&
|
||||
` defaultValue: false` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` checkDirectUpload: {` && |\n| &&
|
||||
` type: "boolean",` && |\n| &&
|
||||
` defaultValue: false` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
|\n| &&
|
||||
|\n| &&
|
||||
` aggregations: {` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` events: {` && |\n| &&
|
||||
` "upload": {` && |\n| &&
|
||||
` allowPreventDefault: true,` && |\n| &&
|
||||
` parameters: {}` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` renderer: null` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
|\n| &&
|
||||
` renderer: function (oRm, oControl) {` && |\n| &&
|
||||
|\n| &&
|
||||
` if (!oControl.getProperty("checkDirectUpload")) {` && |\n| &&
|
||||
` oControl.oUploadButton = new Button({` && |\n| &&
|
||||
` text: oControl.getProperty("uploadButtonText"),` && |\n| &&
|
||||
` enabled: oControl.getProperty("path") !== "",` && |\n| &&
|
||||
` press: function (oEvent) { ` && |\n| &&
|
||||
|\n| &&
|
||||
` this.setProperty("path", this.oFileUploader.getProperty("value"));` && |\n| &&
|
||||
|\n| &&
|
||||
` var file = sap.z2ui5.oUpload.oFileUpload.files[0];` && |\n| &&
|
||||
` var reader = new FileReader();` && |\n| &&
|
||||
|\n| &&
|
||||
` reader.onload = function (evt) {` && |\n| &&
|
||||
` var vContent = evt.currentTarget.result;` && |\n| &&
|
||||
` this.setProperty("value", vContent);` && |\n| &&
|
||||
` this.fireUpload();` && |\n| &&
|
||||
` //this.getView().byId('picture' ).getDomRef().src = vContent;` && |\n| &&
|
||||
` }.bind(this)` && |\n| &&
|
||||
|\n| &&
|
||||
` reader.readAsDataURL(file);` && |\n| &&
|
||||
` }.bind(oControl)` && |\n| &&
|
||||
` });` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
|\n| &&
|
||||
` oControl.oFileUploader = new FileUploader({` && |\n| &&
|
||||
` icon: "sap-icon://browse-folder",` && |\n| &&
|
||||
` iconOnly: oControl.getProperty("iconOnly"),` && |\n| &&
|
||||
` buttonOnly: oControl.getProperty("buttonOnly"),` && |\n| &&
|
||||
` buttonText: oControl.getProperty("buttonText"),` && |\n| &&
|
||||
` fileType: oControl.getProperty("fileType"),` && |\n| &&
|
||||
` uploadOnChange: true,` && |\n| &&
|
||||
` value: oControl.getProperty("path"),` && |\n| &&
|
||||
` placeholder: oControl.getProperty("placeholder"),` && |\n| &&
|
||||
` change: function (oEvent) {` && |\n| &&
|
||||
` if (oControl.getProperty("checkDirectUpload")) {` && |\n| &&
|
||||
` return; ` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
|\n| &&
|
||||
` var value = oEvent.getSource().getProperty("value");` && |\n| &&
|
||||
` this.setProperty("path", value);` && |\n| &&
|
||||
` if (value) {` && |\n| &&
|
||||
` this.oUploadButton.setEnabled();` && |\n| &&
|
||||
` } else {` && |\n| &&
|
||||
` this.oUploadButton.setEnabled(false);` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
` this.oUploadButton.rerender();` && |\n| &&
|
||||
` sap.z2ui5.oUpload = oEvent.oSource;` && |\n| &&
|
||||
` }.bind(oControl),` && |\n| &&
|
||||
` uploadComplete: function (oEvent) {` && |\n| &&
|
||||
` if (!oControl.getProperty("checkDirectUpload")) {` && |\n| &&
|
||||
` return; ` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
|\n| &&
|
||||
` var value = oEvent.getSource().getProperty("value");` && |\n| &&
|
||||
` this.setProperty("path", value);` && |\n| &&
|
||||
|\n| &&
|
||||
` var file = oEvent.oSource.oFileUpload.files[0];` && |\n| &&
|
||||
` var reader = new FileReader();` && |\n| &&
|
||||
|\n| &&
|
||||
` reader.onload = function (evt) {` && |\n| &&
|
||||
` var vContent = evt.currentTarget.result;` && |\n| &&
|
||||
` this.setProperty("value", vContent);` && |\n| &&
|
||||
` this.fireUpload();` && |\n| &&
|
||||
` }.bind(this)` && |\n| &&
|
||||
|\n| &&
|
||||
` reader.readAsDataURL(file);` && |\n| &&
|
||||
` }.bind(oControl)` && |\n| &&
|
||||
` });` && |\n| &&
|
||||
|\n| &&
|
||||
` var hbox = new sap.m.HBox();` && |\n| &&
|
||||
` hbox.addItem(oControl.oFileUploader);` && |\n| &&
|
||||
` hbox.addItem(oControl.oUploadButton);` && |\n| &&
|
||||
` oRm.renderControl(hbox);` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
` });` && |\n| &&
|
||||
` });`.
|
||||
|
||||
DATA(js) = get_js( ).
|
||||
result = mo_view->_generic( ns = `html` name = `script` )->_cc_plain_xml( js )->get_parent( ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD get_js.
|
||||
|
||||
r_js = `jQuery.sap.declare("z2ui5.FileUploader");` && |\n| &&
|
||||
|\n| &&
|
||||
` sap.ui.require([` && |\n| &&
|
||||
` "sap/ui/core/Control",` && |\n| &&
|
||||
` "sap/m/Button",` && |\n| &&
|
||||
` "sap/ui/unified/FileUploader"` && |\n| &&
|
||||
` ], function (Control, Button, FileUploader) {` && |\n| &&
|
||||
` "use strict";` && |\n| &&
|
||||
|\n| &&
|
||||
` return Control.extend("z2ui5.FileUploader", {` && |\n| &&
|
||||
|\n| &&
|
||||
` metadata: {` && |\n| &&
|
||||
` properties: {` && |\n| &&
|
||||
` value: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` path: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` tooltip: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` fileType: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` placeholder: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` buttonText: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: ""` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` uploadButtonText: {` && |\n| &&
|
||||
` type: "string",` && |\n| &&
|
||||
` defaultValue: "Upload"` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` enabled: {` && |\n| &&
|
||||
` type: "boolean",` && |\n| &&
|
||||
` defaultValue: true` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` iconOnly: {` && |\n| &&
|
||||
` type: "boolean",` && |\n| &&
|
||||
` defaultValue: false` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` buttonOnly: {` && |\n| &&
|
||||
` type: "boolean",` && |\n| &&
|
||||
` defaultValue: false` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` multiple: {` && |\n| &&
|
||||
` type: "boolean",` && |\n| &&
|
||||
` defaultValue: false` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` checkDirectUpload: {` && |\n| &&
|
||||
` type: "boolean",` && |\n| &&
|
||||
` defaultValue: false` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
|\n| &&
|
||||
|\n| &&
|
||||
` aggregations: {` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` events: {` && |\n| &&
|
||||
` "upload": {` && |\n| &&
|
||||
` allowPreventDefault: true,` && |\n| &&
|
||||
` parameters: {}` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
` renderer: null` && |\n| &&
|
||||
` },` && |\n| &&
|
||||
|\n| &&
|
||||
` renderer: function (oRm, oControl) {` && |\n| &&
|
||||
|\n| &&
|
||||
` if (!oControl.getProperty("checkDirectUpload")) {` && |\n| &&
|
||||
` oControl.oUploadButton = new Button({` && |\n| &&
|
||||
` text: oControl.getProperty("uploadButtonText"),` && |\n| &&
|
||||
` enabled: oControl.getProperty("path") !== "",` && |\n| &&
|
||||
` press: function (oEvent) { ` && |\n| &&
|
||||
|\n| &&
|
||||
` this.setProperty("path", this.oFileUploader.getProperty("value"));` && |\n| &&
|
||||
|\n| &&
|
||||
` var file = sap.z2ui5.oUpload.oFileUpload.files[0];` && |\n| &&
|
||||
` var reader = new FileReader();` && |\n| &&
|
||||
|\n| &&
|
||||
` reader.onload = function (evt) {` && |\n| &&
|
||||
` var vContent = evt.currentTarget.result;` && |\n| &&
|
||||
` this.setProperty("value", vContent);` && |\n| &&
|
||||
` this.fireUpload();` && |\n| &&
|
||||
` //this.getView().byId('picture' ).getDomRef().src = vContent;` && |\n| &&
|
||||
` }.bind(this)` && |\n| &&
|
||||
|\n| &&
|
||||
` reader.readAsDataURL(file);` && |\n| &&
|
||||
` }.bind(oControl)` && |\n| &&
|
||||
` });` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
|\n| &&
|
||||
` oControl.oFileUploader = new FileUploader({` && |\n| &&
|
||||
` icon: "sap-icon://browse-folder",` && |\n| &&
|
||||
` iconOnly: oControl.getProperty("iconOnly"),` && |\n| &&
|
||||
` buttonOnly: oControl.getProperty("buttonOnly"),` && |\n| &&
|
||||
` buttonText: oControl.getProperty("buttonText"),` && |\n| &&
|
||||
` fileType: oControl.getProperty("fileType"),` && |\n| &&
|
||||
` uploadOnChange: true,` && |\n| &&
|
||||
` value: oControl.getProperty("path"),` && |\n| &&
|
||||
` placeholder: oControl.getProperty("placeholder"),` && |\n| &&
|
||||
` change: function (oEvent) {` && |\n| &&
|
||||
` if (oControl.getProperty("checkDirectUpload")) {` && |\n| &&
|
||||
` return; ` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
|\n| &&
|
||||
` var value = oEvent.getSource().getProperty("value");` && |\n| &&
|
||||
` this.setProperty("path", value);` && |\n| &&
|
||||
` if (value) {` && |\n| &&
|
||||
` this.oUploadButton.setEnabled();` && |\n| &&
|
||||
` } else {` && |\n| &&
|
||||
` this.oUploadButton.setEnabled(false);` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
` this.oUploadButton.rerender();` && |\n| &&
|
||||
` sap.z2ui5.oUpload = oEvent.oSource;` && |\n| &&
|
||||
` }.bind(oControl),` && |\n| &&
|
||||
` uploadComplete: function (oEvent) {` && |\n| &&
|
||||
` if (!oControl.getProperty("checkDirectUpload")) {` && |\n| &&
|
||||
` return; ` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
|\n| &&
|
||||
` var value = oEvent.getSource().getProperty("value");` && |\n| &&
|
||||
` this.setProperty("path", value);` && |\n| &&
|
||||
|\n| &&
|
||||
` var file = oEvent.oSource.oFileUpload.files[0];` && |\n| &&
|
||||
` var reader = new FileReader();` && |\n| &&
|
||||
|\n| &&
|
||||
` reader.onload = function (evt) {` && |\n| &&
|
||||
` var vContent = evt.currentTarget.result;` && |\n| &&
|
||||
` this.setProperty("value", vContent);` && |\n| &&
|
||||
` this.fireUpload();` && |\n| &&
|
||||
` }.bind(this)` && |\n| &&
|
||||
|\n| &&
|
||||
` reader.readAsDataURL(file);` && |\n| &&
|
||||
` }.bind(oControl)` && |\n| &&
|
||||
` });` && |\n| &&
|
||||
|\n| &&
|
||||
` var hbox = new sap.m.HBox();` && |\n| &&
|
||||
` hbox.addItem(oControl.oFileUploader);` && |\n| &&
|
||||
` hbox.addItem(oControl.oUploadButton);` && |\n| &&
|
||||
` oRm.renderControl(hbox);` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
` });` && |\n| &&
|
||||
` });`.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
|
|
@ -5,6 +5,21 @@ CLASS z2ui5_cl_xml_view_cc DEFINITION
|
|||
|
||||
PUBLIC SECTION.
|
||||
|
||||
METHODS file_uploader
|
||||
IMPORTING
|
||||
!value TYPE clike OPTIONAL
|
||||
!path TYPE clike OPTIONAL
|
||||
!placeholder TYPE clike OPTIONAL
|
||||
!upload TYPE clike OPTIONAL
|
||||
!icononly TYPE clike OPTIONAL
|
||||
!buttononly TYPE clike OPTIONAL
|
||||
!buttontext TYPE clike OPTIONAL
|
||||
!uploadbuttontext TYPE clike OPTIONAL
|
||||
!checkdirectupload TYPE clike OPTIONAL
|
||||
!filetype TYPE clike OPTIONAL
|
||||
RETURNING
|
||||
VALUE(result) TYPE REF TO z2ui5_cl_xml_view.
|
||||
|
||||
METHODS title
|
||||
IMPORTING
|
||||
title TYPE clike OPTIONAL
|
||||
|
@ -31,9 +46,8 @@ CLASS z2ui5_cl_xml_view_cc DEFINITION
|
|||
IMPORTING
|
||||
view TYPE REF TO z2ui5_cl_xml_view.
|
||||
|
||||
DATA mo_view TYPE REF TO z2ui5_cl_xml_view.
|
||||
|
||||
PROTECTED SECTION.
|
||||
DATA mo_view TYPE REF TO z2ui5_cl_xml_view.
|
||||
PRIVATE SECTION.
|
||||
ENDCLASS.
|
||||
|
||||
|
@ -41,6 +55,14 @@ ENDCLASS.
|
|||
|
||||
CLASS z2ui5_cl_xml_view_cc IMPLEMENTATION.
|
||||
|
||||
|
||||
METHOD constructor.
|
||||
|
||||
me->mo_view = view.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD scroll.
|
||||
|
||||
result = mo_view.
|
||||
|
@ -53,20 +75,6 @@ CLASS z2ui5_cl_xml_view_cc IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD constructor.
|
||||
|
||||
me->mo_view = view.
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD title.
|
||||
|
||||
result = mo_view.
|
||||
mo_view->_generic( name = `Title`
|
||||
ns = `z2ui5`
|
||||
t_prop = VALUE #( ( n = `title` v = title ) ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD timer.
|
||||
|
||||
|
@ -80,4 +88,33 @@ CLASS z2ui5_cl_xml_view_cc IMPLEMENTATION.
|
|||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD title.
|
||||
|
||||
result = mo_view.
|
||||
mo_view->_generic( name = `Title`
|
||||
ns = `z2ui5`
|
||||
t_prop = VALUE #( ( n = `title` v = title ) ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
METHOD file_uploader.
|
||||
|
||||
result = mo_view.
|
||||
mo_view->_generic( name = `FileUploader`
|
||||
ns = `z2ui5`
|
||||
t_prop = VALUE #( ( n = `placeholder` v = placeholder )
|
||||
( n = `upload` v = upload )
|
||||
( n = `path` v = path )
|
||||
( n = `value` v = value )
|
||||
( n = `iconOnly` v = z2ui5_cl_fw_utility=>boolean_abap_2_json( icononly ) )
|
||||
( n = `buttonOnly` v = z2ui5_cl_fw_utility=>boolean_abap_2_json( buttononly ) )
|
||||
( n = `buttonText` v = buttontext )
|
||||
( n = `uploadButtonText` v = uploadbuttontext )
|
||||
( n = `fileType` v = filetype )
|
||||
( n = `checkDirectUpload` v = z2ui5_cl_fw_utility=>boolean_abap_2_json( checkdirectupload ) ) ) ).
|
||||
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
ENDCLASS.
|
||||
|
|
Loading…
Reference in New Issue
Block a user