mirror of
https://github.com/abap2UI5/abap2UI5.git
synced 2025-04-29 22:09:24 +08:00
zcc_file_uploader with new optional parameters (#552)
- new property "checkDirectUpload"
This commit is contained in:
parent
e602beaaaa
commit
191a985c52
|
@ -1136,10 +1136,15 @@
|
|||
|
||||
METHODS zcc_file_uploader
|
||||
IMPORTING
|
||||
!value TYPE clike OPTIONAL
|
||||
!path TYPE clike OPTIONAL
|
||||
!placeholder TYPE clike OPTIONAL
|
||||
!upload TYPE clike OPTIONAL
|
||||
!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
|
||||
RETURNING
|
||||
VALUE(result) TYPE REF TO z2ui5_cl_xml_view .
|
||||
|
||||
|
@ -5377,15 +5382,20 @@ CLASS Z2UI5_CL_XML_VIEW IMPLEMENTATION.
|
|||
result = me.
|
||||
_generic( name = `FileUploader`
|
||||
ns = `z2ui5`
|
||||
t_prop = VALUE #( ( n = `placeholder` v = placeholder )
|
||||
( n = `upload` v = upload )
|
||||
( n = `path` v = path )
|
||||
( n = `value` v = value ) ) ).
|
||||
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 = `checkDirectUpload` v = z2ui5_cl_fw_utility=>boolean_abap_2_json( checkdirectupload ) ) ) ).
|
||||
|
||||
ENDMETHOD.
|
||||
|
||||
|
||||
METHOD zcc_file_uploader_js.
|
||||
METHOD zcc_file_uploader_js.
|
||||
|
||||
DATA(js) = ` debugger; jQuery.sap.declare("z2ui5.FileUploader");` && |\n| &&
|
||||
|\n| &&
|
||||
|
@ -5422,15 +5432,31 @@ CLASS Z2UI5_CL_XML_VIEW IMPLEMENTATION.
|
|||
` },` && |\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| &&
|
||||
|
@ -5448,8 +5474,9 @@ CLASS Z2UI5_CL_XML_VIEW IMPLEMENTATION.
|
|||
|\n| &&
|
||||
` renderer: function (oRm, oControl) {` && |\n| &&
|
||||
|\n| &&
|
||||
` oControl.oUploadButton = new Button({` && |\n| &&
|
||||
` text: oControl.getProperty("buttonText"),` && |\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| &&
|
||||
|
@ -5467,14 +5494,22 @@ CLASS Z2UI5_CL_XML_VIEW IMPLEMENTATION.
|
|||
|\n| &&
|
||||
` reader.readAsDataURL(file);` && |\n| &&
|
||||
` }.bind(oControl)` && |\n| &&
|
||||
` });` && |\n| &&
|
||||
` });` && |\n| &&
|
||||
` }` && |\n| &&
|
||||
|\n| &&
|
||||
` oControl.oFileUploader = new FileUploader({` && |\n| &&
|
||||
` icon: "sap-icon://browse-folder",` && |\n| &&
|
||||
` iconOnly: true,` && |\n| &&
|
||||
` iconOnly: oControl.getProperty("iconOnly"),` && |\n| &&
|
||||
` buttonOnly: oControl.getProperty("buttonOnly"),` && |\n| &&
|
||||
` buttonText: oControl.getProperty("buttonText"),` && |\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| &&
|
||||
|
@ -5484,6 +5519,25 @@ CLASS Z2UI5_CL_XML_VIEW IMPLEMENTATION.
|
|||
` }` && |\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| &&
|
||||
|
|
Loading…
Reference in New Issue
Block a user