Permalink
Browse files

replaced northwind crap with local json

  • Loading branch information...
1 parent 5fd302a commit ff456c24b1901e6b21c39e9555445479a73290ec @js1972 committed Feb 25, 2014
Showing with 310 additions and 3 deletions.
  1. +3 −0 Component.js
  2. +2 −0 Gruntfile.js
  3. +1 −0 index.html
  4. +286 −0 model/mock.json
  5. +15 −2 view/Detail.controller.js
  6. +3 −1 view/Home.controller.js
View
@@ -65,12 +65,15 @@ Component details:
}
});
+ /*
// set data model on root view
var sURI = "http://localhost:8080/Northwind/Northwind.svc/";
if (typeof baseURL === "string") {
sURI = baseURL; //if mock service use the baseURL
}
oView.setModel(new sap.ui.model.odata.ODataModel(sURI, false)); // use XML for the fake request
+ */
+ oView.setModel(new sap.ui.model.json.JSONModel("model/mock.json"));
// set device model
var deviceModel = new sap.ui.model.json.JSONModel({
View
@@ -93,6 +93,7 @@ module.exports = function(grunt) {
//When not using grunt-connect-proxy you still must have the
//livereload target for connect.
//
+ /*
proxies: {
context: "/Northwind", // When the url contains this...
host: "services.odata.org", // Proxy to this host
@@ -103,6 +104,7 @@ module.exports = function(grunt) {
//"^/changingcontext": "/anothercontext"
//}
},
+ */
//=====================================================================
// Requires the Livereload browser extension or a middleware to inject the livereload script
View
@@ -23,6 +23,7 @@
<script type="text/javascript" src="https://openui5.netweaver.ondemand.com/resources/sap/ui/thirdparty/sinon.js"></script>
<script type="text/javascript" src="model/ODataModelFakeService.js"></script>
-->
+
<script>
new sap.ui.core.ComponentContainer({
name: "sap.ui.demo"
View
@@ -0,0 +1,286 @@
+{
+ "Categories": [
+ {
+ "CategoryID": "1",
+ "CategoryName": "Beverages",
+ "isActive": true,
+ "Description": "Soft drinks, coffees, teas, beers, and ales",
+ "Products": [
+ {
+ "ProductName": "Chai",
+ "QuantityPerUnit": "10 boxes x 20 bags",
+ "UnitsInStock": "39",
+ "UnitPrice": "18.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Chang",
+ "QuantityPerUnit": "24 - 12 oz bottles",
+ "UnitsInStock": "17",
+ "UnitPrice": "19.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Chartreuse verte",
+ "QuantityPerUnit": "750 cc per bottle",
+ "UnitsInStock": "69",
+ "UnitPrice": "10.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Côte de Blaye",
+ "QuantityPerUnit": "12 - 75 cl bottles",
+ "UnitsInStock": "17",
+ "UnitPrice": "18.0000",
+ "Discontinued": "false"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "CategoryID": "2",
+ "CategoryName": "Condiments",
+ "isActive": true,
+ "Description": "Sweet and savory sauces, relishes, spreads, and seasonings",
+ "Products": [
+ {
+ "ProductName": "Aniseed Syrup",
+ "QuantityPerUnit": "12 - 550 ml bottles",
+ "UnitsInStock": "13",
+ "UnitPrice": "17.5000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Chef Anton's Cajun Seasoning",
+ "QuantityPerUnit": "48 - 6 oz jars",
+ "UnitsInStock": "53",
+ "UnitPrice": "8.7500",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Genen Shouyu",
+ "QuantityPerUnit": "24 - 250 ml bottles",
+ "UnitsInStock": "39",
+ "UnitPrice": "18.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Grandma's Boysenberry Spread",
+ "QuantityPerUnit": "12 - 8 oz jars",
+ "UnitsInStock": "120",
+ "UnitPrice": "10.0000",
+ "Discontinued": "false"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "CategoryID": "3",
+ "CategoryName": "Confections",
+ "isActive": true,
+ "Description": "Desserts, candies, and sweet breads",
+ "Products": [
+ {
+ "ProductName": "Chocolade",
+ "QuantityPerUnit": "10 pkgs.",
+ "UnitsInStock": "15",
+ "UnitPrice": "120.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Gumbär Gummibärchen",
+ "QuantityPerUnit": "100 - 250 g bags",
+ "UnitsInStock": "15",
+ "UnitPrice": "1.1000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Maxilaku",
+ "QuantityPerUnit": "24 - 50 g pkgs.",
+ "UnitsInStock": "10",
+ "UnitPrice": "19.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "NuNuCa Nuß-Nougat-Creme",
+ "QuantityPerUnit": "20 - 450 g glasses",
+ "UnitsInStock": "76",
+ "UnitPrice": "27.0000",
+ "Discontinued": "false"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "CategoryID": "4",
+ "CategoryName": "Dairy Products",
+ "isActive": true,
+ "Description": "Cheeses",
+ "Products": [
+ {
+ "ProductName": "Camembert Pierrot",
+ "QuantityPerUnit": "15 - 300 g rounds",
+ "UnitsInStock": "19",
+ "UnitPrice": "8.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Flotemysost",
+ "QuantityPerUnit": "10 - 500 g pkgs.",
+ "UnitsInStock": "26",
+ "UnitPrice": "7.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Geitost",
+ "QuantityPerUnit": "500 g",
+ "UnitsInStock": "112",
+ "UnitPrice": "6.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Gorgonzola Telino",
+ "QuantityPerUnit": "12 - 100 g pkgs",
+ "UnitsInStock": "0",
+ "UnitPrice": "5.0000",
+ "Discontinued": "false"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "CategoryID": "5",
+ "CategoryName": "Grains/Cereals",
+ "isActive": true,
+ "Description": "Breads, crackers, pasta, and cereal",
+ "Products": [
+ {
+ "ProductName": "Filo Mix",
+ "QuantityPerUnit": "16 - 2 kg boxes",
+ "UnitsInStock": "38",
+ "UnitPrice": "4.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Gnocchi di nonna Alice",
+ "QuantityPerUnit": "24 - 250 g pkgs.",
+ "UnitsInStock": "21",
+ "UnitPrice": "3.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Gustaf's Knäckebröd",
+ "QuantityPerUnit": "24 - 500 g pkgs.",
+ "UnitsInStock": "104",
+ "UnitPrice": "2.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Ravioli Angelo",
+ "QuantityPerUnit": "24 - 250 g pkgs.",
+ "UnitsInStock": "36",
+ "UnitPrice": "1.0000",
+ "Discontinued": "false"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "CategoryID": "6",
+ "CategoryName": "Meat/Poultry",
+ "isActive": true,
+ "Description": "Prepared meats",
+ "Products": [
+ {
+ "ProductName": "Pâté chinois",
+ "QuantityPerUnit": "24 boxes x 2 pies",
+ "UnitsInStock": "115",
+ "UnitPrice": "35.7500",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Tourtière",
+ "QuantityPerUnit": "16 pies",
+ "UnitsInStock": "21",
+ "UnitPrice": "19.9900",
+ "Discontinued": "false"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "CategoryID": "7",
+ "CategoryName": "Produce",
+ "isActive": true,
+ "Description": "Dried fruit and bean curd",
+ "Products": [
+ {
+ "ProductName": "Longlife Tofu",
+ "QuantityPerUnit": "5 kg pkg.",
+ "UnitsInStock": "4",
+ "UnitPrice": "5.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Manjimup Dried Apples",
+ "QuantityPerUnit": "50 - 300 g pkgs.",
+ "UnitsInStock": "20",
+ "UnitPrice": "6.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Tofu",
+ "QuantityPerUnit": "40 - 100 g pkgs.",
+ "UnitsInStock": "35",
+ "UnitPrice": "18.8800",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Uncle Bob's Organic Dried Pears",
+ "QuantityPerUnit": "12 - 1 lb pkgs.",
+ "UnitsInStock": "15",
+ "UnitPrice": "7.9900",
+ "Discontinued": "false"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ },
+ {
+ "CategoryID": "8",
+ "CategoryName": "Seafood",
+ "isActive": true,
+ "Description": "Seaweed and fish",
+ "Products": [
+ {
+ "ProductName": "Boston Crab Meat",
+ "QuantityPerUnit": "24 - 4 oz tins",
+ "UnitsInStock": "123",
+ "UnitPrice": "5.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Carnarvon Tigers",
+ "QuantityPerUnit": "16 kg pkg.",
+ "UnitsInStock": "42",
+ "UnitPrice": "6.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Escargots de Bourgogne",
+ "QuantityPerUnit": "24 pieces",
+ "UnitsInStock": "62",
+ "UnitPrice": "7.0000",
+ "Discontinued": "false"
+ },
+ {
+ "ProductName": "Gravad lax",
+ "QuantityPerUnit": "12 - 500 g pkgs.",
+ "UnitsInStock": "11",
+ "UnitPrice": "8.0000",
+ "Discontinued": "false"
+ }
+ ],
+ "randomArrayItem": "lemon"
+ }
+ ]
+}
View
@@ -13,8 +13,21 @@
_handleRouteMatched: function(evt) {
if (evt.getParameter("name") === "detail") {
- var path = "/" + evt.getParameter("arguments").data;
- this.getView().bindObject(path);
+ //var path = "/" + evt.getParameter("arguments").data;
+ var path = evt.getParameter("arguments").data.replace(/!/g, "/");
+
+ //this.getView().bindObject(path);
+ var thisView = this.getView();
+ thisView.getModel().createBindingContext(path, function(bindingCtx) {
+ thisView.setBindingContext(bindingCtx);
+ });
+
+
+ /*
+ sap.ui.getCore().getModel().createBindingContext("/" + oArguments.selectedIndex + "/details", function(oBindingContext) {
+ that.getView().setBindingContext(oBindingContext);
+ });
+ */
}
},
View
@@ -9,7 +9,9 @@
handleTileTap: function(evt) {
var bindingPath = evt.getSource().getBindingContext().sPath;
- this.router.navTo("detail", {data: bindingPath.substring(1)});
+ var crap = bindingPath.replace(/\//g, "!");
+ this.router.navTo("detail", {data: crap});
+ //this.router.navTo("detail", {data: bindingPath.substring(1)});
},
productCount: function(oValue) {

0 comments on commit ff456c2

Please sign in to comment.