forked from LongDirtyAnimAlf/OpenUI5_RestModel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComponent.js
64 lines (52 loc) · 1.59 KB
/
Component.js
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
sap.ui.define([
'sap/ui/core/UIComponent',
'sap/ui/Device',
'sap/m/routing/Router',
'sap/ui/model/resource/ResourceModel',
'sap/ui/model/json/JSONModel',
'sap/ui/demo/SapRestDemo/model/Config',
'sap/ui/demo/SapRestDemo/localService/RestModel/RestModel'
], function (UIComponent,
Device,
Router,
ResourceModel,
JSONModel,
mORMotModel) {
return UIComponent.extend("sap.ui.demo.SapRestDemo.Component", {
metadata: {
manifest: "json"
},
init: function () {
// call overwritten init (calls createContent)
UIComponent.prototype.init.apply(this, arguments);
var oModel = new sap.ui.model.rest.RestModel("https://api.github.com");
oModel.setKey("login");
this.setModel(oModel);
// set device model
var oDeviceModel = new JSONModel({
isTouch: sap.ui.Device.support.touch,
isNoTouch: !sap.ui.Device.support.touch,
isPhone: sap.ui.Device.system.phone,
isNoPhone: !sap.ui.Device.system.phone,
listMode: (sap.ui.Device.system.phone) ? "None" : "SingleSelectMaster",
listItemType: (sap.ui.Device.system.phone) ? "Active" : "Inactive"
});
oDeviceModel.setDefaultBindingMode("OneWay");
this.setModel(oDeviceModel, "device");
this._router = this.getRouter();
//navigate to initial page for !phone
if (!sap.ui.Device.system.phone) {
this._router.getTargets().display("welcome");
}
// initialize the router
this._router.initialize();
},
createContent: function () {
// create root view
return sap.ui.view({
viewName: "sap.ui.demo.SapRestDemo.view.App",
type: "XML"
});
}
});
});