diff --git a/README.md b/README.md index 57990e8..dc8a7eb 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ Clone the Git [repository](https://github.com/SAP/cloud-espm-v2.git) or download 5. [Setup the Runtime Environment](https://help.hana.ondemand.com/help/frameset.htm?7613f000711e1014839a8273b0e91070.html). please use the Java EE 6 Web Profile section in the above document 6. Signup for [HCP Trial account](https://hcp.sap.com/developers.html#section_4) - ### Build the application and deploy 1. Git configuration in Eclipse - From the Eclipse IDE main menu, choose Window > Preferences @@ -82,6 +81,8 @@ Clone the Git [repository](https://github.com/SAP/cloud-espm-v2.git) or download - On this wizard page check that the master branch is selected and click again on Next > - On the last wizard page you can adjust the location of the local Git Repository, but for the scope of this tutorial we'll just leave the default as-is - Click on Finish so that the remote cloud-basecamp Git repository (source code) is cloned to the local location specified on the last wizard page. + - In Eclipse, open File->Import->Existing Maven projects. + 4. Update dependencies and build Maven project - Instruction to run update dependencies for the Maven project @@ -214,33 +215,6 @@ The ESPM Sample Application is a Maven based project which has a parent pom.xml After deploying the application in HCP, assign the Retailer role to the user who will act as the retailer of the eCommerce site. Please refer to documentation of SAP HANA Cloud Platform on how to assign roles to users. See [Details](https://help.hana.ondemand.com/help/frameset.htm?db8175b9d976101484e6fa303b108acd.html) -### Protecting from Cross-Site Request Forgery - -In ESPM, we use **Custom header approach** for CSRF protection. For details on the same, please refer [SAP HANA Cloud Platform documentation](https://help.hana.ondemand.com/help/frameset.htm?1f5f34e31ec64af8b5fef1796ea07c0a.html) - -In Web.xml file in ESPM espm-cloud-web project(path src/main/webapp/WEB-INF/web.xml), we have added the below tags to enable CSRF protection for the secure odata service (http://.hana.ondemand.com/espm-cloud-web/espm.svc/secure) -```sh - - - RestCSRF - org.apache.catalina.filters.RestCsrfPreventionFilter - - - RestCSRF - - /espm.svc/secure/* - -``` - -Note that the CSRF protection is performed only for modifying HTTP requests (different from GET|HEAD or OPTIONS). -All CSRF protected resources should be protected with an authentication mechanism. - -In ESPM, the Retailer scenario (https://localhost:\/espm-cloud-web/retailer) is protected with authentication. The Sales Order Approval and Stock Update scenario is protected with CSRF protection. - -The modifing HTTP requests to the secure service will be sent with header **X-CSRF-Token: ** - -Prior to sending a modifing HTTTP request, an HTTP GET request should be sent to a non-modifing HTTP request with the header **X-CSRF-Token: Fetch**. This will fetch the **** required for the modifing request. - # Important Disclaimers on Security and Legal Aspects This document is for informational purposes only. Its content is subject to change without notice, and SAP does not warrant that it is error-free. SAP MAKES NO WARRANTIES, EXPRESS OR IMPLIED, OR OF MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. diff --git a/docs/documentation/SAPJAMIntegrationREADME.md b/docs/documentation/SAPJAMIntegrationREADME.md index 39e3c6a..349fab1 100644 --- a/docs/documentation/SAPJAMIntegrationREADME.md +++ b/docs/documentation/SAPJAMIntegrationREADME.md @@ -41,124 +41,132 @@ The product reviews information from within SAP HANA Cloud Platform can be fetch # Implementation The business data that is exposed in this scenario is the product reviews written by customers for products in ESPM application. The data is exposed as OData. + https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web/espm.svc/Products https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web/espm.svc/CustomerReviews -The “annotations.xml” file used by SAP Jam to render the data is created for you and available within the ESPM application. https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web/webshop/reviews_annotations.xml +The “annotations.xml” file used by SAP Jam to render the data is created for you and available within the ESPM application. + +https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web/webshop/reviews_annotations.xml For understanding the annotations.xml file tags, please refer the [documentation](http://help.sap.com/download/documentation/sapjam/developer/index.html#intguide/concepts/DevelopAnODataAnnotationsFileToDisplayBusinessRecords.html) With the “annotations.xml” file and the data exposed via OData available, we can create an external application in SAP Jam that brings in products and product reviews data from the ESPM application into SAP Jam. Then create SAP Jam group for each product and its associated product reviews and collaborate within SAP Jam on the business data. -Setting up ESPM application integration with SAP Jam -Setting up the integration of ESPM application with SAP Jam has the below steps -1. Create an External Application in SAP Jam -2. Import the ESPM Web Shop Records into SAP Jam -3. Import the ESPM Reviews Group Template into SAP Jam -4. Create a new ESPM Reviews group in SAP Jam from an ESPM Web Shop Record -5. Reconfigure the ESPM Reviews Group Widgets + +#####Setting up ESPM application integration with SAP Jam + +Setting up the integration of ESPM application with SAP Jam has the below steps
+1. Create an External Application in SAP Jam
+2. Import the ESPM Web Shop Records into SAP Jam
+3. Import the ESPM Reviews Group Template into SAP Jam
+4. Create a new ESPM Reviews group in SAP Jam from an ESPM Web Shop Record
+5. Reconfigure the ESPM Reviews Group Widgets
### Create an External Application in SAP Jam An External Application in SAP Jam defines the connection between SAP Jam and an external application to access the data in that application exposed via its API. Use the following steps to create an External Application in SAP Jam: - - Launch SAP Jam service from the HCP cockpit -> Services -> SAP Jam -> Go to Service - - In SAP Jam, click on the "cog" settings icon and select Admin. The SAP Jam Admin page will appear. - - Select Integrations > External Applications from the sidebar menu. The External Applications page will appear. - - Click Add Application and select SAP HANA Cloud Platform from the dropdown menu. - - In the Name text box, enter ESPM - - Click on the Select Authentication Type drop-down menu, and select Common User. - - Leave the User Name and Password fields blank. - - Click Save to create the External Application. - - You will see the ESPM External Application you created in the External Applications list. + a. Launch SAP Jam service from the HCP cockpit -> Services -> SAP Jam -> Go to Service
+ b In SAP Jam, click on the "cog" settings icon and select Admin. The SAP Jam Admin page will appear.
+ c. Select Integrations > External Applications from the sidebar menu. The External Applications page will appear.
+ d. Click Add Application and select SAP HANA Cloud Platform from the dropdown menu.
+ e. In the Name text box, enter ESPM
+ f. Click on the Select Authentication Type drop-down menu, and select Common User.
+ g. Leave the User Name and Password fields blank.
+ h. Click Save to create the External Application.
+ i. You will see the ESPM External Application you created in the External Applications list.
### Import the ESPM Web Shop Records into SAP Jam Record types in SAP Jam define how the data from the external application will be displayed within SAP Jam. Use the following steps to import the ESPM Web Shop records into SAP Jam - - In the external applications page, for the ESPM application select Action -> Manage Record types - - Click on Add Record Type button - - In the Name text box, enter Products - - In the External Type text box, enterhttps://espm.hanatrial.ondemand.com/espm-cloud-web /espm.svc/$metadata#Products - - In the Annotations URL text field, enter https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web /webshop/reviews_annotations.xml - - Click on Import External resources button. You will be display with a success page. Click on Done button - - Click on the Create button - - Products has been created as an entry in Manage ESPM Record Types page. - - repeat step no b to g again, but changing the value in step c. to CustomerReviews and the value for External Type text box in step d. to https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web /espm.svc/$metadata#CustomerReviews - - CustomerReviews has been created as an entry in Manage ESPM Record Types page + a. In the external applications page, for the ESPM application select Action -> Manage Record types
+ b. Click on Add Record Type button
+ c. In the Name text box, enter Products
+ d. In the External Type text box, enter
+ https://espm.hanatrial.ondemand.com/espm-cloud-web/espm.svc/$metadata#Products
+ e. In the Annotations URL text field, enter
+ https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web/webshop/reviews_annotations.xml
+ f. Click on Import External resources button. You will be display with a success page. Click on Done button.
+ g. Click on the Create button.
+ h. Products has been created as an entry in Manage ESPM Record Types page.
+ i. repeat step no b to g again, but changing the value in step c. to CustomerReviews and the value for External Type text box in step d. to
+ https://espmxxxxxxxtrial.hanatrial.ondemand.com/espm-cloud-web/espm.svc/$metadata#CustomerReviews
+ j. CustomerReviews has been created as an entry in Manage ESPM Record Types page ### Create Filters for Products and CustomerReviews Record Types We need to create the filters for the CustomerReviews Record Types so that we are able to analyze the top and bottom rated products based on the customer reviews and ratings - - In the Manage ESPM Record Types, Against the CustomerReviews record,Click on the Filters link - - Click on the New Filter button - - In the Name text field, enter Top rated customer reviews - - In the Filter text area, enter Rating gt 3 - - Select the Checkbox “enabled” - - Click on the Submit button - - Repeat steps b to f again with Name text field as bottom rated customer reviews and Filter text area as Rating le 2 + a. In the Manage ESPM Record Types, Against the CustomerReviews record,Click on the Filters link
+ b. Click on the New Filter button
+ c. In the Name text field, enter Top rated customer reviews
+ d. In the Filter text area, enter Rating gt 3
+ e. Select the Checkbox “enabled”
+ f. Click on the Submit button
+ g. Repeat steps b to f again with Name text field as bottom rated customer reviews and Filter text area as Rating le 2
### Import the ESPM Reviews Group Template into SAP Jam SAP Jam groups act as the collaborative workspaces for work patterns. Group templates organize the content in a way that provides guidance to users on the best way to approach the work required to support a particular repeatable business process. Use the following steps to import the ESPM Reviews group template into SAP Jam: - - On the Admin page select Product Setup > Group Templates from the sidebar menu. The Group Templates screen will appear. - - Download the group template zip file from the following URL https://sapjamsamplecode.github.io/GroupTemplates/ESPM_Reviews-Products.zip - - Click the Import a template button. - - Navigate to the group template zip file. - - Click the Open button. - - Click the Import button. - - Once the template has been imported an Import a template dialog will be displayed. Click the OK button. - - Refresh the web page and you will see a new group template titled ESPM Reviews - Products. If you do not see the new group template, wait 30 seconds and try again. - - Click the Slider button next to this group template and set it to Enabled (shown as a blue checkmark). This group template is now active. + a. On the Admin page select Product Setup > Group Templates from the sidebar menu. The Group Templates screen will appear.
+ b. Download the group template zip file from the following URL
https://sapjamsamplecode.github.io/GroupTemplates/ESPM_Reviews-Products.zip
+ c. Click the Import a template button.
+ d. Navigate to the group template zip file.
+ e. Click the Open button.
+ f. Click the Import button.
+ g. Once the template has been imported an Import a template dialog will be displayed. Click the OK button.
+ h. Refresh the web page and you will see a new group template titled ESPM Reviews - Products. If you do not see the new group template, wait 30 seconds and try again.
+ i. Click the Slider button next to this group template and set it to Enabled (shown as a blue checkmark). This group template is now active.
### Create a new ESPM Reviews group in SAP Jam from an ESPM Web Shop Record -Groups are a membership of users who can upload, create, or reference material specific to a department, project, or team. Group members can participate in discussions, forums and much more. Use the following steps to create a new ESPM Reviews Group in SAP Jam for an ESPM Web Shop Record: - - - Select Business Records from the top menu-bar. The Business Records screen will appear. - - Select ESPM in the Name column. - - Select Products in the Type column. A list of IDs from ESPM will be displayed. - - Copy the ID value next to "Notebook Basic 15" in the ID column. - - Hover over "Notebook Basic 15" in the Product Name column and a quick view panel of the product will appear. - - Click the Create Group button in the quick view panel. The Create a Group dialog appears - - Click the No Template drop-down list and select the group template ESPM Reviews - Products. - - In the Type a Group Name text box, enter “ESPM Product Reviews - ” and paste the ID value. - - Set the Group Permissions by selecting Public. - - Select the Activate this group now checkbox. - - Click the "Create" button. The new group has now been created +Groups are a membership of users who can upload, create, or reference material specific to a department, project, or team. Group members can participate in discussions, forums and much more. Use the following steps to create a new ESPM Reviews Group in SAP Jam for an ESPM Web Shop Record:
+ + a. Select Business Records from the top menu-bar. The Business Records screen will appear.
+ b. Select ESPM in the Name column.
+ c. Select Products in the Type column. A list of IDs from ESPM will be displayed.
+ d. Copy the ID value next to "Notebook Basic 15" in the ID column.
+ e. Hover over "Notebook Basic 15" in the Product Name column and a quick view panel of the product will appear.
+ f. Click the Create Group button in the quick view panel. The Create a Group dialog appears.
+ g. Click the No Template drop-down list and select the group template ESPM Reviews - Products.
+ h. In the Type a Group Name text box, enter “ESPM Product Reviews - ” and paste the ID value.
+ i. Set the Group Permissions by selecting Public.
+ j. Select the Activate this group now checkbox.
+ k. Click the "Create" button. The new group has now been created
- ### Reconfigure the ESPM Reviews Group Widgets +### Reconfigure the ESPM Reviews Group Widgets 1. Select Overview. The Overview screen appears. 2. Select Edit. -3. Configure the "Customer Reviews" widget: - - Hover the mouse cursor over the top right corner of the "Customer Reviews" widget. The Edit and Remove menu appears. - - Select Edit. - - Select ESPM: Customer Reviews from the "Update Widget" drop-down list. - - Select Related from the "Show" drop-down list. - - Click the OK button. The "Customer Reviews" widget information appears. -4. Configure the "Top Rated Customer Reviews" widget: - - Hover the mouse cursor over the top right corner of the "Top Rated Customer Reviews" widget. The Edit and Remove menu appears. - - Select Edit. - - Select ESPM:Customer Reviews from the "Update Widget" drop-down list. - - Select Related from the "Show" drop-down list. - - Select Top Rated Reviews from the "Filter by" drop-down list. - - Select Rating from the "Sort by" drop-down list. - - Select the Descending radio button. - - Click the OK button. The "Top Rated Customer Reviews" widget information appears. -5. Configure the "Bottom Rated Customer Reviews" widget: - - Hover the mouse cursor over the top right corner of the "Bottom Rated Customer Reviews" widget. The Edit and Remove menu appears. - - Select Edit. - - Select ESPM:Customer Reviews from the "Update Widget" drop-down list. - - Select Related from the "Show" drop-down list. - - Select Bottom Rated Reviews from the "Filter by" drop-down list. - - Select Rating from the "Sort by" drop-down list. - - Select the Ascending radio button. - - Click the OK button. The "Bottom Rated Customer Reviews" widget information appears. +3. Configure the "Customer Reviews" widget:
+ a. Hover the mouse cursor over the top right corner of the "Customer Reviews" widget. The Edit and Remove menu appears.
+ b. Select Edit.
+ c. Select ESPM: Customer Reviews from the "Update Widget" drop-down list.
+ d. Select Related from the "Show" drop-down list.
+ e. Click the OK button. The "Customer Reviews" widget information appears.
+4. Configure the "Top Rated Customer Reviews" widget:
+ a. Hover the mouse cursor over the top right corner of the "Top Rated Customer Reviews" widget. The Edit and Remove menu appears.
+ b. Select Edit.
+ c. Select ESPM:Customer Reviews from the "Update Widget" drop-down list.
+ d. Select Related from the "Show" drop-down list.
+ e. Select Top Rated Reviews from the "Filter by" drop-down list.
+ f. Select Rating from the "Sort by" drop-down list.
+ g. Select the Descending radio button.
+ h. Click the OK button. The "Top Rated Customer Reviews" widget information appears.
+5. Configure the "Bottom Rated Customer Reviews" widget:
+ a. Hover the mouse cursor over the top right corner of the "Bottom Rated Customer Reviews" widget. The Edit and Remove menu appears.
+ b. Select Edit.
+ c. Select ESPM:Customer Reviews from the "Update Widget" drop-down list.
+ d. Select Related from the "Show" drop-down list.
+ e. Select Bottom Rated Reviews from the "Filter by" drop-down list.
+ f. Select Rating from the "Sort by" drop-down list.
+ g. Select the Ascending radio button.
+ h. Click the OK button. The "Bottom Rated Customer Reviews" widget information appears.
6. Click the Publish button. 7. Click the Publish button. 8. The Overview page will now display rich information about the product and its reviews. diff --git a/docs/images/repoclone.png b/docs/images/repoclone.png index 0c33e1a..a75c13f 100644 Binary files a/docs/images/repoclone.png and b/docs/images/repoclone.png differ diff --git a/espm-cloud-web/src/main/webapp/retailer/controller/Home.controller.js b/espm-cloud-web/src/main/webapp/retailer/controller/Home.controller.js index f04ea7d..dcedf9c 100644 --- a/espm-cloud-web/src/main/webapp/retailer/controller/Home.controller.js +++ b/espm-cloud-web/src/main/webapp/retailer/controller/Home.controller.js @@ -1,20 +1,19 @@ sap.ui.define([ - "sap/ui/core/mvc/Controller", - 'sap/ui/model/json/JSONModel' -], function(Controller, JSONModel) { + "sap/ui/core/mvc/Controller" +], function(Controller) { "use strict"; return Controller.extend("com.sap.espm.retailer.controller.Home", { - onInit : function (evt) { + onInit : function () { }, - approveTilePressed: function(event){ + approveTilePressed: function(){ var oRouter = sap.ui.core.UIComponent.getRouterFor(this); oRouter.navTo("SalesOrder"); }, - stockTilePressed: function(event){ + stockTilePressed: function(){ var oRouter = sap.ui.core.UIComponent.getRouterFor(this); oRouter.navTo("StockInformation"); diff --git a/espm-cloud-web/src/main/webapp/retailer/controller/SalesOrder.controller.js b/espm-cloud-web/src/main/webapp/retailer/controller/SalesOrder.controller.js index e19b8be..3316c58 100644 --- a/espm-cloud-web/src/main/webapp/retailer/controller/SalesOrder.controller.js +++ b/espm-cloud-web/src/main/webapp/retailer/controller/SalesOrder.controller.js @@ -1,16 +1,14 @@ jQuery.sap.require("com.sap.espm.retailer.model.format"); sap.ui.define([ "sap/ui/core/mvc/Controller", - "sap/ui/core/routing/History", "com/sap/espm/retailer/model/formatter", "sap/m/MessageBox", "sap/m/MessageToast" -], function(Controller, formatter) { +], function(Controller, formatter, MessageBox, MessageToast) { "use strict"; - var statusId = 0; var responseData; return Controller.extend("com.sap.espm.retailer.controller.SalesOrder", { @@ -80,16 +78,16 @@ sap.ui.define([ title : "{ProductId}" }), new sap.m.Text({ - text : "{path: 'DeliveryDate', formatter: 'com.sap.espm.retailer.model.format.date'}", + text : "{path: 'DeliveryDate', formatter: 'com.sap.espm.retailer.model.format.date'}" }), new sap.m.Text({ - text : "{path: 'Quantity', formatter: 'com.sap.espm.retailer.model.format.quantity'}", + text : "{path: 'Quantity', formatter: 'com.sap.espm.retailer.model.format.quantity'}" }), new sap.m.ObjectNumber({ emphasized : false, number : "{path: 'GrossAmount', formatter:'com.sap.espm.retailer.model.format.formatAmount'}", unit : "{CurrencyCode}" - }), + }) ] }); @@ -112,14 +110,14 @@ sap.ui.define([ binding.filter(filters); }, - handleApprove: function(evt){ + handleApprove: function(){ var bundle = this.getView().getModel("i18n").getResourceBundle(); var that = this; - sap.m.MessageBox.confirm( bundle.getText("sales.approveDialogMsg"), + MessageBox.confirm( bundle.getText("sales.approveDialogMsg"), function (oAction) { - if (sap.m.MessageBox.Action.OK === oAction) { + if (MessageBox.Action.OK === oAction) { // notify user var id = that.getView().byId("detailObjectHeader").getTitle(); @@ -142,11 +140,11 @@ sap.ui.define([ model.refresh(); var successMsg = bundle.getText("sales.aproveDialogSuccessMsg"); - sap.m.MessageToast.show(successMsg); + MessageToast.show(successMsg); }, function() { - sap.m.MessageToast.show(bundle.getText("sales.approvalFailed")); + MessageToast.show(bundle.getText("sales.approvalFailed")); }); } }, @@ -155,13 +153,13 @@ sap.ui.define([ }, - handleReject: function(evt){ + handleReject: function(){ var bundle = this.getView().getModel("i18n").getResourceBundle(); var that = this; - sap.m.MessageBox.confirm( bundle.getText("sales.rejectDialogMsg"), + MessageBox.confirm( bundle.getText("sales.rejectDialogMsg"), function (oAction) { - if (sap.m.MessageBox.Action.OK === oAction) { + if (MessageBox.Action.OK === oAction) { // notify user var id = that.getView().byId("detailObjectHeader").getTitle(); @@ -183,9 +181,9 @@ sap.ui.define([ model.refresh(); var successMsg = bundle.getText("sales.rejectDialogSuccessMsg"); - sap.m.MessageToast.show(successMsg); + MessageToast.show(successMsg); },function(){ - sap.m.MessageToast.show(bundle.getText("sales.rejectFailed"));}); + MessageToast.show(bundle.getText("sales.rejectFailed"));}); } }, bundle.getText("sales.rejectDialogTitle") ); diff --git a/espm-cloud-web/src/main/webapp/retailer/controller/StockInformation.controller.js b/espm-cloud-web/src/main/webapp/retailer/controller/StockInformation.controller.js index 5073b74..5544d96 100644 --- a/espm-cloud-web/src/main/webapp/retailer/controller/StockInformation.controller.js +++ b/espm-cloud-web/src/main/webapp/retailer/controller/StockInformation.controller.js @@ -1,15 +1,8 @@ sap.ui.define([ "sap/ui/core/mvc/Controller", - "com/sap/espm/retailer/model/formatter", - "sap/ui/core/routing/History", - 'sap/m/Dialog', - "sap/m/Text", - "sap/m/Button", - 'sap/ui/layout/HorizontalLayout', - 'sap/ui/layout/VerticalLayout', - "sap/m/Input" + "com/sap/espm/retailer/model/formatter" -], function(Controller,formatter, VerticalLayout, HorizontalLayout, Text, Input, Dialog, Button) { +], function(Controller,formatter) { "use strict"; var bindingObject; @@ -107,7 +100,7 @@ sap.ui.define([ } }), new sap.m.Label({text:bundle.getText("stock.itemsInStock")}), - new sap.m.Input({value:stockString[0],editable: false}), + new sap.m.Input({value:stockString[0],editable: false}) ] }) diff --git a/espm-cloud-web/src/main/webapp/webshop/controller/Checkout.controller.js b/espm-cloud-web/src/main/webapp/webshop/controller/Checkout.controller.js index 28664da..8d2a8cd 100644 --- a/espm-cloud-web/src/main/webapp/webshop/controller/Checkout.controller.js +++ b/espm-cloud-web/src/main/webapp/webshop/controller/Checkout.controller.js @@ -3,21 +3,19 @@ sap.ui.define([ "sap/ui/core/mvc/Controller", "com/sap/espm/shop/model/formatter", "sap/ui/core/UIComponent", - "sap/ui/core/mvc/ViewType", "sap/ui/model/odata/ODataModel", "sap/ui/model/json/JSONModel", "sap/ui/core/routing/History", "sap/m/MessageBox" -], function(Controller, formatter, UIComponent, ViewType, ODataModel, JSONModel, History, MessageBox) { +], function(Controller, formatter, UIComponent, ODataModel, JSONModel, History, MessageBox) { "use strict"; var oDataModel; - var isCustomerExist; var customerId = ""; return Controller.extend("com.sap.espm.shop.controller.Checkout", { formatter: formatter, - + cardType: "american", onInit:function() { @@ -84,6 +82,8 @@ sap.ui.define([ ocountryModel.loadData("/espm-cloud-web/webshop/model/countries.json"); this.getView().byId("countryListId").setModel(ocountryModel, "countryModel"); + var today = new Date(); + this.getView().byId("birthId").setMaxDate(today); }, onAfterRendering: function() @@ -211,6 +211,8 @@ sap.ui.define([ sap.ui.getCore().byId("country").setText(this.byId("countryListId").getSelectedKey()); sap.ui.getCore().byId("cardOwner").setText(this.byId("nameId").getValue()); sap.ui.getCore().byId("cardNumber").setText(this.byId("numberId").getValue()); + + sap.ui.getCore().byId("cardImg").setSrc("Images/"+ this.cardType+ ".png"); this._oNavContainer.to(this._oWizardReviewPage); } @@ -219,7 +221,7 @@ sap.ui.define([ handleWizardCancel: function(){ this._oNavContainer.backToPage(this._oWizardContentPage.getId()); - var oRouter = sap.ui.core.UIComponent.getRouterFor(this); + var oRouter = UIComponent.getRouterFor(this); oRouter.navTo("Home", true); }, handleWizardSubmit : function () { @@ -270,7 +272,7 @@ sap.ui.define([ customerId = responsedata.d.CustomerId; that.createSalesOrder(); }, - error: function(err) { + error: function() { sap.m.MessageToast.show(oBundle.getText("check.customerCreateFailed")); } }); @@ -310,7 +312,7 @@ sap.ui.define([ dataType: "json", url: "/espm-cloud-web/espm.svc/SalesOrderHeaders", data : JSON.stringify(SalesOrderHeader), - success: function(oData, responsedata) { + success: function(oData) { var dataJson = { @@ -322,7 +324,7 @@ sap.ui.define([ contentType:"application/json; charset=utf-8", url: oData.d.__metadata.id + "/$links/Customer", data :JSON.stringify(dataJson), - success: function(data, response) { + success: function() { $.ajax({ type: "GET", @@ -330,31 +332,31 @@ sap.ui.define([ contentType:"application/json; charset=utf-8", dataType: "json", url: "/espm-cloud-web/espm.svc/GetSalesOrderItemsById?SalesOrderId='"+ oData.d.SalesOrderId +"'", - success: function(data, response) { + success: function(data) { var length = data.d.results.length; - for(var i=0;i 0 && sReviewComment) { sap.ui.getCore().byId("btnOK", "reviewDialog").setEnabled(true); } - } - + }, + + validateReviewForm: function(){ + var iRatingCount = sap.ui.getCore().byId("ratingIndicator", "reviewDialog").getValue(); + var sReviewComment = sap.ui.getCore().byId("textArea", "reviewDialog").getValue(); + var firstName = sap.ui.getCore().byId("firstNameId", "reviewDialog").getValue(); + var lastName = sap.ui.getCore().byId("lastNameId", "reviewDialog").getValue(); + + if(iRatingCount > 0 && sReviewComment !== "" && firstName !== "" && lastName !== ""){ + sap.ui.getCore().byId("btnOK", "reviewDialog").setEnabled(true); + } + else{ + sap.ui.getCore().byId("btnOK", "reviewDialog").setEnabled(false); + } + }, + onTableSettingsPressed: function(){ + var oBinding = this.byId("reviewTable").getBinding("items"); + var aSorters = []; + var aDescending = this.sortReviewDesc; + this.sortReviewDesc = !this.sortReviewDesc; + aSorters.push(new sap.ui.model.Sorter('Rating', aDescending)); + oBinding.sort(aSorters); + + } }); diff --git a/espm-cloud-web/src/main/webapp/webshop/controller/SalesOrder.controller.js b/espm-cloud-web/src/main/webapp/webshop/controller/SalesOrder.controller.js index 5b7cf32..634fad6 100644 --- a/espm-cloud-web/src/main/webapp/webshop/controller/SalesOrder.controller.js +++ b/espm-cloud-web/src/main/webapp/webshop/controller/SalesOrder.controller.js @@ -1,17 +1,14 @@ jQuery.sap.require("com.sap.espm.shop.model.format"); sap.ui.define([ "sap/ui/core/mvc/Controller", - "sap/ui/core/routing/History", "com/sap/espm/shop/model/formatter", - "sap/m/MessageBox", "sap/m/MessageToast" -], function(Controller, formatter) { +], function(Controller, formatter, MessageToast) { "use strict"; - var statusId = 0; - var responseData, pdfURL; + var pdfURL; return Controller.extend("com.sap.espm.shop.controller.SalesOrder", { @@ -33,6 +30,10 @@ sap.ui.define([ }}); this.getView().byId("detailPageId").setVisible(false); + var deviceModel = new sap.ui.model.json.JSONModel({ + isPhone: sap.ui.Device.system.phone + }); + this.getView().setModel(deviceModel, "device"); }, @@ -65,15 +66,15 @@ sap.ui.define([ var that = this; var emailId; - var oBundle = this.getView().getModel('i18n').getResourceBundle(); + var oBundle = this.getView().getModel("i18n").getResourceBundle(); var dialog = new sap.m.Dialog({ - title: oBundle.getText('soPopup.pageTitle'), - type: 'Message', + title: oBundle.getText("soPopup.pageTitle"), + type: "Message", content: [ new sap.ui.layout.form.SimpleForm({ content:[ - new sap.m.Label({text:oBundle.getText('soPopup.emailAddress')}), + new sap.m.Label({text:oBundle.getText("soPopup.emailAddress")}), new sap.m.Input({ liveChange:function(oEvent){ emailId = oEvent.getSource().getValue(); @@ -84,7 +85,7 @@ sap.ui.define([ }) ], beginButton: new sap.m.Button({ - text: oBundle.getText('soPopup.salesOrderList'), + text: oBundle.getText("soPopup.salesOrderList"), press: function () { if(emailId){ @@ -94,24 +95,24 @@ sap.ui.define([ contentType:"application/json; charset=utf-8", dataType: "json", url: "/espm-cloud-web/espm.svc/GetSalesOrderInvoiceByEmail?EmailAddress='"+ emailId +"'&$expand=SalesOrderItems,Customer&$format=json", - success: function(data, response) { + success: function(data) { that.bindMasterPage(data); }, - error: function(err) { - sap.m.MessageToast.show(oBundle.getText('soPopup.errorMessage')); + error: function() { + MessageToast.show(oBundle.getText("soPopup.errorMessage")); } }); dialog.close(); } else{ - sap.m.MessageToast.show(oBundle.getText('soPopup.fieldEmpty')); + MessageToast.show(oBundle.getText("soPopup.fieldEmpty")); } } }), endButton: new sap.m.Button({ - text: oBundle.getText('soPopup.cancel'), + text: oBundle.getText("soPopup.cancel"), press: function () { dialog.close(); } @@ -184,22 +185,26 @@ sap.ui.define([ title : "{ProductId}" }), new sap.m.Text({ - text : "{path: 'DeliveryDate', formatter: 'com.sap.espm.shop.model.format.date'}", + text : "{path: 'DeliveryDate', formatter: 'com.sap.espm.shop.model.format.date'}" }), new sap.m.Text({ - text : "{path: 'Quantity', formatter: 'com.sap.espm.shop.model.format.quantity'}", + text : "{path: 'Quantity', formatter: 'com.sap.espm.shop.model.format.quantity'}" }), new sap.m.ObjectNumber({ emphasized : false, number : "{path: 'GrossAmount', formatter:'com.sap.espm.shop.model.format.formatAmount'}", unit : "{CurrencyCode}" - }), + }) ] }); var oTable = this.getView().byId("lineItemsId"); var bindString = context + "/SalesOrderItems/results"; oTable.bindItems(bindString, oTemplate); + + if(this.getView().getModel("device").oData.isPhone){ + this.byId("splitContId").to(this.byId("detailPageId")); + } }, @@ -217,13 +222,15 @@ sap.ui.define([ }, handleDownload: function(){ - - this.pdfHTML.setVisible(true); - this.pdfHTML.setContent(""); - + window.open(pdfURL); }, onNavBack: function(){ window.history.go(-1); + }, + handleNavButtonPress: function(){ + var oSplitCont = this.byId("splitContId"); + var oMaster = oSplitCont.getMasterPages()[0]; + oSplitCont.toMaster(oMaster); } }); diff --git a/espm-cloud-web/src/main/webapp/webshop/controller/Shoppingcart.controller.js b/espm-cloud-web/src/main/webapp/webshop/controller/Shoppingcart.controller.js index 7acbb13..f85f916 100644 --- a/espm-cloud-web/src/main/webapp/webshop/controller/Shoppingcart.controller.js +++ b/espm-cloud-web/src/main/webapp/webshop/controller/Shoppingcart.controller.js @@ -1,10 +1,7 @@ jQuery.sap.require("com.sap.espm.shop.model.format"); sap.ui.define([ "sap/ui/core/mvc/Controller", - "com/sap/espm/shop/model/formatter", - "sap/ui/core/mvc/ViewType", - "sap/ui/core/routing/History", - "sap/ui/model/json/JSONModel" + "com/sap/espm/shop/model/formatter" ], function(Controller, formatter) { "use strict"; @@ -76,7 +73,7 @@ sap.ui.define([ onBeforeRendering: function() { }, - onLineItemPressed: function(oEvent) + onLineItemPressed: function() { }, @@ -100,7 +97,7 @@ sap.ui.define([ var subTotal = 0; var currency; var oModel = this.getView().getModel("Cart"); - var data = oModel.getProperty('/ShoppingCart'); + var data = oModel.getProperty("/ShoppingCart"); if(data){ for(var i=0; i + xmlns:mvc="sap.ui.core.mvc" xmlns:shop="com.sap.espm.shop.control" xmlns:l="sap.ui.layout" xmlns:form="sap.ui.layout.form" xmlns:u="sap.ui.unified" xmlns="sap.m" xmlns:app="http://schemas.sap.com/sapui5/extension/sap.ui.core.CustomData/1"> @@ -81,7 +81,7 @@