forked from qmacro/sapui5bin
-
Notifications
You must be signed in to change notification settings - Fork 8
/
OData_BlueCrystal.html
106 lines (97 loc) · 3.23 KB
/
OData_BlueCrystal.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>OData BlueCrystal Simple Example</title>
<script id="sap-ui-bootstrap" src="../resources/sap-ui-core.js"
type="text/javascript" data-sap-ui-libs="sap.m, sap.me"
data-sap-ui-theme="sap_bluecrystal">
</script>
<!-- The OData Northwind service was down this morning, so i used the fake service based on
Sinon.JS FakeXHR. To run on the real service instead please comment out the following 2 lines. -->
<script type="text/javascript" src="../resources/sap/ui/thirdparty/sinon.js"></script>
<script type="text/javascript" src="../test-resources/sap/ui/core/qunit/ODataModelFakeService.js"></script>
<script type="text/javascript">
var sURI= "http://services.odata.org/Northwind/Northwind.svc/"
if (typeof baseURL === "string") sURI=baseURL; //if mock service use the baseURL
var oModel = new sap.ui.model.odata.ODataModel(sURI, true);
var oTileCont = new sap.m.TileContainer("tileCont", {});
sap.ui.getCore().setModel(oModel);
//Tile Template
var oTileTmp = new sap.m.StandardTile({
number : {
path : "CategoryID",
formatter : productCount
},
numberUnit : "Products",
icon : "sap-icon://action",
title : "{CategoryName}",
info : "{Description}",
press : _handleTileTap
});
//Bind Categories use template to build tiles,
oTileCont.bindAggregation("tiles", {
path : "/Categories",
template : oTileTmp,
parameters : { expand : "Products" }
});
var page1 = new sap.m.Page("home", { title : "Products by Category" });
page1.setEnableScrolling(false).addContent(oTileCont);
// PAGE 2 //
var page2 = new sap.m.Page("page2", {
customHeader : new sap.m.Bar({
contentLeft : [ new sap.m.Button({
icon : "sap-icon://home",
tap : function() { app.back();}
}) ],
contentMiddle : [ new sap.m.Label("title", { text : "{CategoryName}"
}) ]
}),
footer : new sap.m.Bar({
transluscent : "true",
contentLeft : [ new sap.m.Button({ icon : "sap-icon://action-settings"})]
}),
content : [ new sap.m.ObjectHeader({intro : "{Description}" }),
new sap.me.TabContainer("tabContainer", {
badgeInfo : { path : "CategoryID", formatter : productCount },
contentInfo : new sap.m.List("list", {
items : {
path : "Products",
template : new sap.m.ObjectListItem({
type : "Active",
title : "{ProductName}",
numberUnit : "EUR",
attributes : [ new sap.m.ObjectAttribute({
text : "{QuantityPerUnit}"
}) ],
number : {
path : "UnitPrice",
type : new sap.ui.model.type.Float({
maxFractionDigits : 2
})
}
})
}
})
}) ]
});
var app = new sap.m.App("App");
app.addPage(page1).addPage(page2).setInitialPage(page1.getId());
var shell = new sap.m.Shell("Shell",{showLogout : false});
shell.setApp(app).placeAt('body');
function _handleTileTap(oEvent) {
app.to("page2");
page2.setBindingContext(this.getBindingContext());
};
function productCount(oValue) {
//return the number of products linked to Category
if (oValue) {
var sPath = this.getBindingContext().getPath() + '/Products';
return this.getModel().bindList(sPath).getContexts().length;
}
};
</script>
</head>
<body class="sapUiBody" id="body" role="application">
</body>
</html>