Skip to content

Commit a1c0a07

Browse files
committed
refactor: eslint error fixes
1 parent 22cc8b9 commit a1c0a07

File tree

38 files changed

+462
-440
lines changed

38 files changed

+462
-440
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
sap.ui.define([
22
"sap/ui/core/mvc/Controller",
33
"sap/base/Log"
4-
], function(Controller, Log) {
4+
], (Controller, Log) => {
55
"use strict";
66

77
return Controller.extend("my.lib.sample.base.BaseController", {
8-
onInit: function() {
9-
Log.info(this.getView().getControllerName(), "onInit");
8+
base64StringToImage(picture) {
9+
return picture ? `data:image/bmp;base64,${ picture}` : null;
1010
},
11-
base64StringToImage: function(picture) {
12-
return picture ? "data:image/bmp;base64," + picture : null;
11+
onInit() {
12+
Log.info(this.getView().getControllerName(), "onInit");
1313
}
1414
});
1515
});

demo/BaseComponent/src/my/lib/sample/base/Component.js

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
sap.ui.define([
22
"sap/ui/core/UIComponent",
33
"sap/base/util/deepClone"
4-
], function(UIComponent, deepClone) {
4+
], (UIComponent, deepClone) => {
55
"use strict";
66

77
return UIComponent.extend("my.lib.sample.base.Component", {
8-
init: function() {
9-
UIComponent.prototype.init.apply(this, arguments);
8+
init(...args) {
9+
UIComponent.prototype.init.apply(this, args);
1010

11-
var oRouter = this.getRouter();
11+
const oRouter = this.getRouter();
1212
oRouter.getViews().attachCreated(this._processEventMappingOnTargetCreated, this);
1313
oRouter.initialize();
1414
},
@@ -32,55 +32,57 @@ sap.ui.define([
3232
* @param {object} oEvent The event object which is provided by the 'created' event from
3333
* router's target cache
3434
*/
35-
_processEventMappingOnTargetCreated: function(oEvent) {
35+
_processEventMappingOnTargetCreated(oEvent) {
3636
if (!this.eventMappings) {
3737
return;
3838
}
3939

40-
var sType = oEvent.getParameter("type");
41-
var oObject = oEvent.getParameter("object");
42-
var oOptions = oEvent.getParameter("options");
43-
var that = this;
44-
var aEvents;
45-
46-
function processComponentTargetInfo(oComponentTargetInfo, oEvent) {
47-
Object.keys(oComponentTargetInfo).forEach(function(sTargetName) {
48-
var oInfo = oComponentTargetInfo[sTargetName];
40+
const sType = oEvent.getParameter("type"),
41+
oObject = oEvent.getParameter("object"),
42+
oOptions = oEvent.getParameter("options"),
43+
that = this,
44+
processComponentTargetInfo = (oComponentTargetInfo, oEv) => {
45+
Object.keys(oComponentTargetInfo).forEach((sTargetName) => {
46+
const oInfo = oComponentTargetInfo[sTargetName];
4947

5048
if (oInfo.parameters) {
51-
Object.keys(oInfo.parameters).forEach(function(sName) {
52-
var sParamName = oInfo.parameters[sName];
53-
var sEventValue = oEvent.getParameter(sParamName);
49+
Object.keys(oInfo.parameters).forEach((sName) => {
50+
const sParamName = oInfo.parameters[sName],
51+
sEventValue = oEv.getParameter(sParamName);
5452

55-
// expand the parameter mapping with the parameter value from
56-
// the event
53+
/*
54+
* Expand the parameter mapping with the parameter value from
55+
* the event
56+
*/
5757
oInfo.parameters[sName] = sEventValue;
5858
});
5959
}
6060

6161
if (oInfo.componentTargetInfo) {
62-
processComponentTargetInfo(oInfo.componentTargetInfo, oEvent);
62+
processComponentTargetInfo(oInfo.componentTargetInfo, oEv);
6363
}
6464
});
65-
}
65+
};
6666

6767
if (sType === "Component") {
68-
aEvents = this.eventMappings[oOptions.usage];
68+
const aEvents = this.eventMappings[oOptions.usage];
6969
if (Array.isArray(aEvents)) {
70-
aEvents.forEach(function(oEventMapping) {
71-
oObject.attachEvent(oEventMapping.name, function(oEvent) {
72-
var oComponentTargetInfo;
73-
if (oEventMapping.route) { // route information defined, call 'navTo'
70+
aEvents.forEach((oEventMapping) => {
71+
oObject.attachEvent(oEventMapping.name, (oEv) => {
72+
let oComponentTargetInfo = {};
73+
if (oEventMapping.route) { // Route information defined, call 'navTo'
7474
if (oEventMapping.componentTargetInfo) {
75-
// if there's information for component target defined, replace the
76-
// event parameter mapping with the value from the event object
75+
/*
76+
* If there's information for component target defined, replace the
77+
* event parameter mapping with the value from the event object
78+
*/
7779
oComponentTargetInfo = deepClone(oEventMapping.componentTargetInfo);
78-
processComponentTargetInfo(oComponentTargetInfo, oEvent);
80+
processComponentTargetInfo(oComponentTargetInfo, oEv);
7981
}
8082

8183
that.getRouter().navTo(oEventMapping.route, {}, oComponentTargetInfo);
82-
} else if (oEventMapping.forward) { // event should be forwarded with the same parameters
83-
that.fireEvent(oEventMapping.forward, oEvent.getParameters());
84+
} else if (oEventMapping.forward) { // Event should be forwarded with the same parameters
85+
that.fireEvent(oEventMapping.forward, oEv.getParameters());
8486
}
8587
});
8688
});
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
sap.ui.define(function() {
1+
sap.ui.define(() => {
22

33
"use strict";
44

55
sap.ui.getCore().initLibrary({
66
name : "my.lib.sample.base",
7+
// eslint-disable-next-line no-template-curly-in-string
78
version : "${version}",
89
noLibraryCSS: true,
910
dependencies : [ "sap.ui.core" ],
1011
controls : [ ],
1112
types : [ ]
1213
});
13-
14+
// eslint-disable-next-line no-undef
1415
return my.lib.sample.base;
1516
});

demo/CategoriesComponent/src/my/lib/sample/categories/Component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sap.ui.define(["my/lib/sample/base/Component"], function(Component) {
1+
sap.ui.define(["my/lib/sample/base/Component"], (Component) => {
22
"use strict";
33

44
return Component.extend("my.lib.sample.categories.Component", {

demo/CategoriesComponent/src/my/lib/sample/categories/controller/App.controller.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sap.ui.define(["my/lib/sample/base/BaseController"], function(BaseController) {
1+
sap.ui.define(["my/lib/sample/base/BaseController"], (BaseController) => {
22
"use strict";
33

44
return BaseController.extend("my.lib.sample.categories.controller.App", {

demo/CategoriesComponent/src/my/lib/sample/categories/controller/Detail.controller.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,43 @@
11
sap.ui.define([
22
"my/lib/sample/base/BaseController",
33
"sap/base/Log"
4-
], function(BaseController, Log) {
4+
], (BaseController, Log) => {
55
"use strict";
66
return BaseController.extend("my.lib.sample.categories.controller.Detail", {
77

8-
onInit: function() {
9-
BaseController.prototype.onInit.apply(this, arguments);
8+
onInit(...args) {
9+
BaseController.prototype.onInit.apply(this, args);
1010
this.getOwnerComponent().getRouter().getRoute("detailRoute").attachMatched(this._onMatched, this);
1111
},
1212

13-
_onMatched: function(oEvent) {
13+
_onMatched(oEvent) {
1414
Log.info(this.getView().getControllerName(), "_onMatched");
15-
var oArgs = oEvent.getParameter("arguments");
15+
const oArgs = oEvent.getParameter("arguments");
1616
this.getOwnerComponent().getModel().metadataLoaded().then(this._bindData.bind(this, oArgs.id));
1717
},
1818

19-
_bindData: function(id) {
19+
_bindData(id) {
2020
Log.info(this.getView().getControllerName(), "_bindData");
21-
var sObjectPath = this.getOwnerComponent().getModel().createKey("Categories", { CategoryID: id });
21+
const sObjectPath = this.getOwnerComponent().getModel().createKey("Categories", { CategoryID: id }),
22+
that = this;
2223
this.getView().bindElement({
23-
path: "/" + sObjectPath,
24+
path: "/"+ sObjectPath,
2425
events: {
25-
change: function() {
26-
Log.info(this.getView().getControllerName(), "_bindData change");
27-
this.getView().setBusy(false);
28-
}.bind(this),
29-
dataRequested: function() {
30-
Log.info(this.getView().getControllerName(), "_bindData dataRequested");
31-
this.getView().setBusy(true);
32-
}.bind(this),
33-
dataReceived: function() {
34-
Log.info(this.getView().getControllerName(), "_bindData dataReceived");
35-
this.getView().setBusy(false);
36-
if (this.getView().getBindingContext() === null) {
37-
this.getOwnerComponent().getRouter().getTargets().display("notFound");
26+
change() {
27+
Log.info(that.getView().getControllerName(), "_bindData change");
28+
that.getView().setBusy(false);
29+
},
30+
dataRequested() {
31+
Log.info(that.getView().getControllerName(), "_bindData dataRequested");
32+
that.getView().setBusy(true);
33+
},
34+
dataReceived() {
35+
Log.info(that.getView().getControllerName(), "_bindData dataReceived");
36+
that.getView().setBusy(false);
37+
if (that.getView().getBindingContext() === null) {
38+
that.getOwnerComponent().getRouter().getTargets().display("notFound");
3839
}
39-
}.bind(this)
40+
}
4041
}
4142
});
4243
}

demo/CategoriesComponent/src/my/lib/sample/categories/controller/List.controller.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
sap.ui.define([
22
"my/lib/sample/base/BaseController",
33
"sap/base/Log"
4-
], function(Controller, Log) {
4+
], (Controller, Log) => {
55
"use strict";
66

77
return Controller.extend("my.lib.sample.categories.controller.List", {
8-
onPressListItem: function(oEvent) {
8+
onPressListItem(oEvent) {
99
Log.info(this.getView().getControllerName(), "onPressListItem");
1010

11-
var oBindingContext = oEvent.getSource().getBindingContext();
11+
const oBindingContext = oEvent.getSource().getBindingContext();
1212

13-
// navigate to the detail page. Because the products component is
14-
// integrated in the detail page, it's also needed to provide route
15-
// information for the deeply nested products component
13+
/*
14+
* Navigate to the detail page. Because the products component is
15+
* integrated in the detail page, it's also needed to provide route
16+
* information for the deeply nested products component
17+
*/
1618
this.getOwnerComponent()
1719
.getRouter()
1820
.navTo("detailRoute", {
@@ -21,8 +23,10 @@ sap.ui.define([
2123
productsTarget: {
2224
route: "listRoute",
2325
parameters: {
24-
// encode the path because it could contain "/" which
25-
// isn't allowed to use as pattern parameter directly
26+
/*
27+
* Encode the path because it could contain "/" which
28+
* isn't allowed to use as pattern parameter directly
29+
*/
2630
basepath: encodeURIComponent(oBindingContext.getPath())
2731
}
2832
}

0 commit comments

Comments
 (0)