<core:View controllerName="app.pdf.view.Page"
xmlns:mvc="sap.ui.core.mvc"
xmlns:f="sap.ui.layout.form"
xmlns:core="sap.ui.core"
xmlns:pdf="ui5lab.wl.pdf"
xmlns="sap.m" height="100%">
<Page showHeader="false">
<content>
<f:SimpleForm id="AttachmentForm" minWidth="1024" editable="true" layout="ResponsiveGridLayout" title="LR_ATTACHMENTS_FORM" class="editableForm">
</f:SimpleForm>
<pdf:PdfViewer pdfSource="{/pdfsource}" />
</content>
<footer>
<OverflowToolbar>
<ToolbarSpacer />
<ToolbarSpacer />
<ToolbarSpacer />
<Button icon="sap-icon://paper-plane" iconFirst="true" iconDensityAware="true" type="Accept" text="Submit" press="onSubmit" />
</OverflowToolbar>
</footer>
</Page>
</core:View>
sap.ui.define([
"jquery.sap.global",
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
'sap/m/MessageToast',
"sap/ui/unified/FileUploader",
], function (jQuery, Controller, JSONModel, MessageToast, FileUploader) {
"use strict";
var PageController = Controller.extend("app.pdf.view.Page", {
reader: {},
onInit: function () {
var that = this;
this._oModel = new JSONModel({
pdfsource: ""
});
this.reader = new FileReader();
this.reader.onload = function(oEvent){
that._oModel.setProperty("/pdfsource", oEvent.target.result);
};
this.getView().setModel(this._oModel);
},
onBeforeRendering: function () {
var that = this;
var oAttachmentForm = this.getView().byId("AttachmentForm");
oAttachmentForm.addContent(new sap.m.Label("AttachmentFile_Label", { text: "LR_SEL_ATTACH" }));
oAttachmentForm.addContent(new FileUploader("fileUploader", {
style: "Emphasized",
fileType: "pdf,jpeg,jpg,png",
width: "100%",
change: function (oEvent) {
var file = oEvent.getParameter("files")[0];
that.reader.readAsDataURL(file);
},
typeMissmatch: function (oEvent) {
var aFileTypes = oEvent.getSource().getFileType();
jQuery.each(aFileTypes, function (key, value) { aFileTypes[key] = "*." + value });
var sSupportedFileTypes = aFileTypes.join(", ");
MessageToast.show(that.oBundle.getText("LR_ATTACHMENT_TYPECHECK", [oEvent.getParameter("fileType"), sSupportedFileTypes]));
}
}));
}
});
return PageController;
});
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
5 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 | |
3 | |
3 |