-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathComponent.js
130 lines (120 loc) · 2.97 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
122
123
124
125
126
127
128
129
130
jQuery.sap.declare("com.splittemplate.Component");
sap.ui.core.UIComponent.extend("com.splittemplate.Component",{
metadata: {
name: "Splittemplate",
version: "0.1",
includes: [],
dependencies: {
libs: ["sap.m"],
},
config: {
resourceBundle: "i18n/messageBundle.properties"
},
routing: {
config: {
viewType: "JS",
targetControl: "splitApp",
viewPath: "com.splittemplate.view",
clearTarget: false,
transition: "slide"
},
routes: [
{
pattern: "management/{category}",
name: "management",
view: "SidebarManagement",
targetAggregation: "masterPages",
subroutes: [
{
pattern: "management/{category}",
name: "category",
view: "Category",
targetAggregation: "detailPages",
},
{
pattern: "management/category/{category}/subunit/{subunit}",
name: "unit",
view: "Unit",
targetAggregation: "detailPages",
},
]
},
{
pattern: "",
name: "default",
view: "Sidebar",
targetAggregation: "masterPages",
subroutes: [
{
pattern: "",
name: "index",
view: "Index",
targetAggregation: "detailPages",
callback: function () {
/*Routes can have callbacks */
}
},
{
pattern: "settings",
name: "settings",
view: "Settings",
targetAggregation: "detailPages",
},
{
pattern: "about",
name: "about",
view: "About",
targetAggregation: "detailPages",
},
{
pattern: "{all*}",
name: "404",
view: "404",
targetAggregation: "detailPages",
}
]
}
]
}
},
init: function() {
jQuery.sap.require("sap.m.routing.RouteMatchedHandler");
jQuery.sap.require("sap.ui.core.routing.HashChanger");
sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
this._router = this.getRouter();
this._routeHandler = new sap.m.routing.RouteMatchedHandler(this._router);
this._router.initialize();
},
createContent: function() {
var oView = sap.ui.view({
id: "app",
viewName: "com.splittemplate.view.App",
type: "JS",
viewData: { component: this }
});
//Data from "fake back-end"
var jsonModel = new sap.ui.model.json.JSONModel('model/backend.json');
jsonModel.setDefaultBindingMode('OneWay');
oView.setModel(jsonModel, 'management');
//Custom App settings
var settings = {
language: 'de',
languages: [
{key: 'de',},
{key: 'en',},
{key: 'fr',}
]
};
var settingsModel = new sap.ui.model.json.JSONModel(settings);
oView.setModel(settingsModel, 'settings');
//Set i18n model
var i18nModel = new sap.ui.model.resource.ResourceModel({
bundleUrl: "i18n/messageBundle.properties",
bundleLocale: settings.language
});
oView.setModel(i18nModel, "i18n");
//get a specific i18n value
//sap.ui.getCore().byId('app').getModel('i18n').getResourceBundle().getText('language');
return oView;
}
});