forked from 6of5/UI5-Boilerplate-Fiori
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Component.js
executable file
·121 lines (109 loc) · 4.04 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
jQuery.sap.declare("ui5bp.Component");
jQuery.sap.require("ui5bp.app.config");
jQuery.sap.require("sap.m.routing.RouteMatchedHandler");
sap.ui.core.UIComponent.extend("ui5bp.Component", {
metadata: {
"name": "UI5 Boilerplate Fiori",
"version": ui5bp.app.config.APP_VERSION,
"includes": ["css/style.css"],
"dependencies": {
"libs": ["sap.m"],
"components": []
},
"config": {
"resourceBundle": "i18n/i18n.properties",
"titleResource": "xtit.shellTitle",
"favIcon": "img/favicon.ico",
"phone": "img/57_iPhone_Desktop_Launch.png",
"phone@2": "img/114_iPhone-Retina_Web_Clip.png",
"tablet": "img/72_iPad_Desktop_Launch.png",
"tablet@2": "img/144_iPad_Retina_Web_Clip.png",
"serviceConfig": {}
},
rootView: {
viewName: "ui5bp.view.App",
type: "JS"
},
routing: {
config: {
viewType: "JS",
viewPath: "ui5bp.view", // common prefix
targetAggregation: "detailPages",
targetControl: "idAppControl",
clearTarget: false
},
routes: [{
pattern: "Launchpad",
name: "Launchpad",
view: "Launchpad",
viewLevel: 1,
targetAggregation: "detailPages"
}, {
pattern: "",
name: "Menu",
view: "Menu",
viewLevel: 1,
targetAggregation: "masterPages"
}]
}
},
init: function() {
sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
// always use absolute paths relative to our own component
// (relative paths will fail if running in the Fiori Launchpad)
var rootPath = jQuery.sap.getModulePath("ui5bp");
// set i18n model
var i18nModel = new sap.ui.model.resource.ResourceModel({
bundleUrl: rootPath + "/i18n/i18n.properties"
});
this.setModel(i18nModel, "i18n");
this._oRouteMatchedHandler = new sap.m.routing.RouteMatchedHandler(this.getRouter());
var router = this.getRouter();
//load routes from menu.json
var model = new sap.ui.model.json.JSONModel(rootPath + "/model/menu.json");
model.attachRequestCompleted(null, function() {
var data = null,
m = 0,
menu = null,
routeConfig = null;
data = model.getData();
if (data && data.Menu) {
for (m = 0; m < data.Menu.length; m++) {
menu = data.Menu[m];
routeConfig = {
name: menu.targetPage,
pattern: menu.targetPage,
view: menu.targetPage,
viewLevel: 2
};
if (menu.viewType) {
routeConfig.viewType = menu.viewType;
}
if (menu.pattern) {
routeConfig.pattern = menu.pattern;
}
if (menu.targetAggregation) {
routeConfig.targetAggregation = menu.targetAggregation;
}
if (menu.viewLevel) {
routeConfig.viewLevel = menu.viewLevel;
}
if (menu.subroutes) {
routeConfig.subroutes = menu.subroutes;
}
router.addRoute(routeConfig);
} //for
} //if
router.initialize();
if (ui5bp.app.config.LaunchpadMode) {
router.navTo("Launchpad");
} else {
router.navTo("Menu");
}
});
},
destroy: function() {
this._oRouteMatchedHandler.destroy();
sap.ui.core.UIComponent.prototype.destroy.apply(this, arguments);
}
});