Skip to content

Commit

Permalink
[FEATURE] Migrate to ECMAScript 2022 syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
flovogt committed Aug 6, 2023
1 parent 0021bb8 commit b2f0fd6
Show file tree
Hide file tree
Showing 18 changed files with 254 additions and 253 deletions.
11 changes: 7 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"env": {
"browser": true
"browser": true,
"es2022": "true"
},
"extends": "eslint:recommended",
"globals": {
"sap": true,
"jQuery": true
},
"rules": {
"block-scoped-var": 1,
"brace-style": [2, "1tbs", { "allowSingleLine": true }],
"consistent-this": 2,
"no-div-regex": 2,
"no-floating-decimal": 2,
"no-self-compare": 2,
"no-mixed-spaces-and-tabs": [2, true],
"no-nested-ternary": 2,
"no-unused-vars": [2, {"vars":"all", "args":"none"}],
"radix": 2,
"keyword-spacing": 2,
"space-unary-ops": 2,
Expand Down Expand Up @@ -49,6 +49,9 @@
"comma-spacing": 0,
"no-multi-spaces": 0,
"no-shadow": 0,
"no-irregular-whitespace": 0
"no-irregular-whitespace": 0,
"no-var": 2,
"no-const-assign": 2,
"prefer-const": 2
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ typings/
# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
# dotenv environment constiables file
.env

# Misc
Expand Down
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function(config) {
"use strict";

var chromeFlags = [
const chromeFlags = [
"--window-size=1280,1024"
];

Expand Down
46 changes: 23 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ui5.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
specVersion: '2.0'
specVersion: '3.0'
metadata:
name: openui5-sample-app
type: application
Expand Down
2 changes: 1 addition & 1 deletion webapp/Component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sap.ui.define(["sap/ui/core/UIComponent", "sap/ui/core/ComponentSupport"], function(UIComponent) {
sap.ui.define(["sap/ui/core/UIComponent", "sap/ui/core/ComponentSupport"], (UIComponent) => {
"use strict";
return UIComponent.extend("sap.ui.demo.todo.Component", {
metadata: {
Expand Down
50 changes: 24 additions & 26 deletions webapp/controller/App.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ sap.ui.define([
"sap/ui/model/Filter",
"sap/ui/model/FilterOperator",
"sap/ui/model/json/JSONModel"
], function(Device, Controller, Filter, FilterOperator, JSONModel) {
], (Device, Controller, Filter, FilterOperator, JSONModel) => {
"use strict";

return Controller.extend("sap.ui.demo.todo.controller.App", {

onInit: function() {
onInit() {
this.aSearchFilters = [];
this.aTabFilters = [];

Expand All @@ -22,9 +22,9 @@ sap.ui.define([
/**
* Adds a new todo item to the bottom of the list.
*/
addTodo: function() {
var oModel = this.getView().getModel();
var aTodos = oModel.getProperty("/todos").map(function (oTodo) { return Object.assign({}, oTodo); });
addTodo() {
const oModel = this.getView().getModel();
const aTodos = oModel.getProperty("/todos").map((oTodo) => Object.assign({}, oTodo));

aTodos.push({
title: oModel.getProperty("/newTodo"),
Expand All @@ -38,13 +38,13 @@ sap.ui.define([
/**
* Removes all completed items from the todo list.
*/
clearCompleted: function() {
var oModel = this.getView().getModel();
var aTodos = oModel.getProperty("/todos").map(function (oTodo) { return Object.assign({}, oTodo); });
clearCompleted() {
const oModel = this.getView().getModel();
const aTodos = oModel.getProperty("/todos").map((oTodo) => Object.assign({}, oTodo));

var i = aTodos.length;
let i = aTodos.length;
while (i--) {
var oTodo = aTodos[i];
const oTodo = aTodos[i];
if (oTodo.completed) {
aTodos.splice(i, 1);
}
Expand All @@ -56,13 +56,11 @@ sap.ui.define([
/**
* Updates the number of items not yet completed
*/
updateItemsLeftCount: function() {
var oModel = this.getView().getModel();
var aTodos = oModel.getProperty("/todos") || [];
updateItemsLeftCount() {
const oModel = this.getView().getModel();
const aTodos = oModel.getProperty("/todos") || [];

var iItemsLeft = aTodos.filter(function(oTodo) {
return oTodo.completed !== true;
}).length;
const iItemsLeft = aTodos.filter((oTodo) => oTodo.completed !== true).length;

oModel.setProperty("/itemsLeftCount", iItemsLeft);
},
Expand All @@ -71,8 +69,8 @@ sap.ui.define([
* Trigger search for specific items. The removal of items is disable as long as the search is used.
* @param {sap.ui.base.Event} oEvent Input changed event
*/
onSearch: function(oEvent) {
var oModel = this.getView().getModel();
onSearch(oEvent) {
const oModel = this.getView().getModel();

// First reset current filters
this.aSearchFilters = [];
Expand All @@ -81,7 +79,7 @@ sap.ui.define([
this.sSearchQuery = oEvent.getSource().getValue();
if (this.sSearchQuery && this.sSearchQuery.length > 0) {
oModel.setProperty("/itemsRemovable", false);
var filter = new Filter("title", FilterOperator.Contains, this.sSearchQuery);
const filter = new Filter("title", FilterOperator.Contains, this.sSearchQuery);
this.aSearchFilters.push(filter);
} else {
oModel.setProperty("/itemsRemovable", true);
Expand All @@ -90,7 +88,7 @@ sap.ui.define([
this._applyListFilters();
},

onFilter: function(oEvent) {
onFilter(oEvent) {
// First reset current filters
this.aTabFilters = [];

Expand All @@ -113,13 +111,13 @@ sap.ui.define([
this._applyListFilters();
},

_applyListFilters: function() {
var oList = this.byId("todoList");
var oBinding = oList.getBinding("items");
_applyListFilters() {
const oList = this.byId("todoList");
const oBinding = oList.getBinding("items");

oBinding.filter(this.aSearchFilters.concat(this.aTabFilters), "todos");

var sI18nKey;
let sI18nKey;
if (this.sFilterKey && this.sFilterKey !== "all") {
if (this.sFilterKey === "active") {
sI18nKey = "ACTIVE_ITEMS";
Expand All @@ -134,9 +132,9 @@ sap.ui.define([
sI18nKey = "ITEMS_CONTAINING";
}

var sFilterText;
let sFilterText;
if (sI18nKey) {
var oResourceBundle = this.getView().getModel("i18n").getResourceBundle();
const oResourceBundle = this.getView().getModel("i18n").getResourceBundle();
sFilterText = oResourceBundle.getText(sI18nKey, [this.sSearchQuery]);
}

Expand Down
2 changes: 1 addition & 1 deletion webapp/test/integration/AllJourneys.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ sap.ui.define([
"sap/ui/demo/todo/test/integration/TodoListJourney",
"sap/ui/demo/todo/test/integration/SearchJourney",
"sap/ui/demo/todo/test/integration/FilterJourney"
], function(Opa5, Startup) {
], (Opa5, Startup) => {
"use strict";

Opa5.extendConfig({
Expand Down
Loading

0 comments on commit b2f0fd6

Please sign in to comment.