Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11,105 changes: 10,669 additions & 436 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions webapp/controller/App.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sap.ui.define([
"ui5/challenge/controller/BaseController"
], function (
Controller
) {
"use strict";

return Controller.extend("ui5.challenge.controller.App", {
onInit: function () {
}
});
});
21 changes: 19 additions & 2 deletions webapp/controller/BaseController.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"sap/ui/core/mvc/Controller",
"sap/ui/core/UIComponent"
], function (Controller, UIComponent) {
"use strict";

return Controller.extend("ui5.challenge.controller.BaseController", {
/**
* @override
*/
onInit: function () {
console.log("Base init");
},

/**
* Convenience method for getting the resource bundle.
* @public
* @returns {sap.ui.model.resource.ResourceModel} the resourceModel of the component
*/
getResourceBundle: function () {
return this.getOwnerComponent().getModel("i18n").getResourceBundle();
},

navTo: function (psTarget, pmParameters, pbReplace) {
this.getRouter().navTo(psTarget, pmParameters, pbReplace);
},
Expand Down
54 changes: 54 additions & 0 deletions webapp/controller/Detail.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
sap.ui.define([
"ui5/challenge/controller/BaseController",
"sap/ui/core/routing/History",
"sap/m/MessageBox",
"sap/ui/model/json/JSONModel"
], function (
BaseController,
History,
MessageBox,
JSONModel
) {
"use strict";

return BaseController.extend("ui5.challenge.controller.Detail", {
/**
* @override
*/
onInit: function () {
this.getRouter().getRoute("RouteProductDetail").attachPatternMatched(this._onPatternMatched, this);
},

_onPatternMatched: function (oEvent) {
var sProductId = window.decodeURIComponent(oEvent.getParameter("arguments").ProductID);
var oProductData = this.getOwnerComponent().getModel().getProperty("/ProductCollection").find(function (oProduct) {
return oProduct.ProductId == sProductId;
});
var oDetailModel = new JSONModel(oProductData);
this.getView().setModel(oDetailModel, "detailModel");
},

onNavButtonPress: function (oEvent) {
var oHistory = History.getInstance();
var sPreviousHash = oHistory.getPreviousHash();

if (sPreviousHash !== undefined) {
window.history.go(-1);
} else {
this.getRouter().navTo("RouteMain");
}
},

onDialogButtonPress: function () {
var oModel = this.getView().getModel("detailModel");
var sPrice = "NA";
if (oModel) {
var sPrice = oModel.getProperty("/Price") + " " + oModel.getProperty("/CurrencyCode");
}

MessageBox.information(sPrice, {
id: "myDialog"
});
}
});
});
33 changes: 33 additions & 0 deletions webapp/controller/Main.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
sap.ui.define([
"ui5/challenge/controller/BaseController",
"sap/ui/model/json/JSONModel"
], function (
Controller,
JSONModel
) {
"use strict";

return Controller.extend("ui5.challenge.controller.Main", {
/**
* @override
*/
onInit: function () {
// var oModel = new JSONModel(sap.ui.require.toUrl("ui5/challenge/mockdata/products.json"));
// this.getView().setModel(oModel);
},

onButtonPress: function (oEvent) {
alert("Will be implemented soon ...");
},

onMyControlPress: function (oEvent) {
var oList = this.getView().byId("productsList");
var oSelectedItem = oList.getSelectedItem();
if (!oSelectedItem) {
this.getRouter().navTo("RouteDetail");
} else {
this.getRouter().navTo("RouteProductDetail", { "ProductID": oSelectedItem.getBindingContext().getProperty("ProductId") });
}
}
});
});
8 changes: 8 additions & 0 deletions webapp/i18n/i18n.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
appTitle=ui5-challenge
appDescription=My fulfillment of ui5-challenge tests.

myControl=Show details
mainTitleText=wdi5 rocks

Detail.dialogButton.text=How much?
Detail.messageBox.text=Maybe next week :)
29 changes: 10 additions & 19 deletions webapp/index.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
<!DOCTYPE html>
<html>

<head>
<title>title</title>
<title>ui5-challenge</title>

<script
id="sap-ui-bootstrap"
src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_horizon"
data-sap-ui-resourceroots='{
<script id="sap-ui-bootstrap" src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js"
data-sap-ui-theme="sap_horizon" data-sap-ui-resourceroots='{
"ui5.challenge": "./"
}'
data-sap-ui-oninit="module:sap/ui/core/ComponentSupport"
data-sap-ui-compatVersion="edge"
data-sap-ui-async="true"
data-sap-ui-frameOptions="trusted"
></script>
}' data-sap-ui-oninit="module:sap/ui/core/ComponentSupport" data-sap-ui-compatVersion="edge"
data-sap-ui-async="true" data-sap-ui-frameOptions="trusted"></script>
</head>

<body class="sapUiBody sapUiSizeCompact" id="content">
<div
data-sap-ui-component
data-name="ui5.challenge"
data-id="container"
data-settings='{"id" : "ui5.challenge"}'
data-handle-validation="true"
></div>
<div data-sap-ui-component data-name="ui5.challenge" data-id="container" data-settings='{"id" : "ui5.challenge"}'
data-handle-validation="true"></div>
</body>

</html>
54 changes: 51 additions & 3 deletions webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
"sap.app": {
"id": "ui5.challenge",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "0.0.1"
},
"title": "{{appTitle}}",
"description": "{{appDescription}}"
"description": "{{appDescription}}",
"dataSources": {
"mainDataSource": {
"type": "JSON",
"uri": "mockdata/products.json"
}
}
},
"sap.ui": {
"technology": "UI5",
Expand Down Expand Up @@ -47,8 +54,45 @@
"controlId": "app",
"clearControlAggregation": false
},
"routes": [],
"targets": {}
"routes": [
{
"pattern": "",
"name": "RouteMain",
"target": [
"TargetMain"
]
},
{
"pattern": "RouteDetail",
"name": "RouteDetail",
"target": [
"TargetDetail"
]
},
{
"pattern": "RouteDetail/{ProductID}",
"name": "RouteProductDetail",
"target": [
"TargetDetail"
]
}
],
"targets": {
"TargetMain": {
"viewType": "XML",
"transition": "slide",
"clearControlAggregation": false,
"viewName": "Main",
"viewId": "main"
},
"TargetDetail": {
"viewType": "XML",
"transition": "slide",
"clearControlAggregation": false,
"viewName": "Detail",
"viewId": "Detail"
}
}
},
"rootView": {
"viewName": "ui5.challenge.view.App",
Expand All @@ -62,6 +106,10 @@
"settings": {
"bundleName": "ui5.challenge.i18n.i18n"
}
},
"": {
"dataSource": "mainDataSource",
"type": "sap.ui.model.json.JSONModel"
}
}
}
Expand Down
Loading