Skip to content

Commit

Permalink
UI5 Week 2 Challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
HexClan-dev committed Jun 17, 2022
1 parent a885dd9 commit f257ff3
Show file tree
Hide file tree
Showing 14 changed files with 10,750 additions and 499 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"SAP HANA Database Explorer.displaySapWebAnalyticsStartupNotification": false
}
1 change: 0 additions & 1 deletion CODEOWNERS

This file was deleted.

11,079 changes: 10,627 additions & 452 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"wdio-chromedriver-service": "^7.3.2",
"wdio-ui5-service": "^0.9.0"
}
}
}
22 changes: 16 additions & 6 deletions webapp/controller/BaseController.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"sap/ui/core/mvc/Controller",
"sap/ui/core/UIComponent",
"sap/ui/core/routing/History"
], function (Controller, UIComponent, History) {
"use strict";

return Controller.extend("ui5.challenge.controller.BaseController", {
navTo: function (psTarget, pmParameters, pbReplace) {
this.getRouter().navTo(psTarget, pmParameters, pbReplace);
},
getRouter: function () {
return UIComponent.getRouterFor(this);

onNavBack: function () {
const sPreviousHash = History.getInstance().getPreviousHash();

if (sPreviousHash !== undefined) {
window.history.back();
} else {
this.getRouter().navTo("RouteMainView", {}, true /* no history*/ );
}
},
onPress: function () {

getRouter: function () {
return UIComponent.getRouterFor(this);
}
});
});
});
15 changes: 15 additions & 0 deletions webapp/controller/DetailController.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
sap.ui.define([
"./BaseController",
"sap/ui/model/json/JSONModel",
"sap/m/MessageToast",
], function (Controller, JSONModel, MessageToast) {
"use strict";

return Controller.extend("ui5.challenge.controller.DetailController", {

goBack: function () {
this.onNavBack();
}

});
});
28 changes: 20 additions & 8 deletions webapp/controller/MainController.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,23 @@ sap.ui.define([
// This is used for Dynamically change title
// document.title = 'ui5-challenge';

console.log(this.getView().byId('titleId'));

var oDummyData = {
Employees: [{
Name: "Name1",
Surname: "Surname1",
Id: 1,
Name: "Betty",
Surname: "Buzzell",
Age: 26
}, {
Name: "Name2",
Surname: "Surname2",
Id: 2,
Name: "Donna",
Surname: "Rosen",
Age: 23
}, {
Name: "Name3",
Surname: "Surname3",
Id: 3,
Name: "Craig",
Surname: "Reid",
Age: 32
}]
};
Expand All @@ -31,8 +36,15 @@ sap.ui.define([

},

onPress: function () {
MessageToast.show("You pressed the Button!");
onTestBtnPress: function (oEvent) {
console.log(oEvent);
MessageToast.show("You pressed the Test Button!");
},


onNextPagePress: function () {
this.navTo("RouteDetailView");
}

});
});
5 changes: 3 additions & 2 deletions webapp/i18n/i18n.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@

browserTitle=ui5-challenge


# Main Page
mainPageTitle=ui5-challenge
mainTitleText=wdi5 rocks
appTitle=ui5-challenge
appDescription=App test Desciption

mainButtonText=Test Button
nextNacButton=Go to Detail Page

listEmployees=Employees


2 changes: 1 addition & 1 deletion webapp/index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>ui5-challenge</title>
<title id="titleId">ui5-challenge</title>

<script
id="sap-ui-bootstrap"
Expand Down
29 changes: 25 additions & 4 deletions webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,35 @@
"controlId": "app",
"clearControlAggregation": false
},
"routes": [],
"targets": {}
"routes": [{
"pattern": "",
"name": "RouteMainView",
"target": ["MainView"]
},
{
"pattern": "RouteDetail",
"name": "RouteDetailView",
"target": ["DetailView"]
}
],
"targets": {
"MainView": {
"viewId": "Main",
"viewName": "Main",
"viewLevel": 1
},
"DetailView": {
"viewId": "Detail",
"viewName": "Detail",
"viewLevel": 2
}
}
},
"rootView": {
"viewName": "ui5.challenge.view.Main",
"viewName": "ui5.challenge.view.App",
"type": "XML",
"async": true,
"id": "shell"
"id": "app"
},
"models": {
"i18n": {
Expand Down
6 changes: 4 additions & 2 deletions webapp/test/e2e/week2.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { wdi5 } = require("wdio-ui5-service")
const {
wdi5
} = require("wdio-ui5-service")
const Main = require("./pageObjects/Main")

describe("week2: main page", () => {
Expand Down Expand Up @@ -27,7 +29,7 @@ describe("week2: main page", () => {
selector: {
id: "myControl",
viewName: Main._viewName
}
}
})
await control.firePress()
const url = await browser.getUrl()
Expand Down
6 changes: 6 additions & 0 deletions webapp/view/App.view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<mvc:View xmlns:mvc="sap.ui.core.mvc" displayBlock="true"
xmlns="sap.m">
<Shell id="shell">
<App id="app" />
</Shell>
</mvc:View>
11 changes: 11 additions & 0 deletions webapp/view/Detail.view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<mvc:View controllerName="ui5.challenge.controller.DetailController" displayBlock="true"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">

<Page title="{i18n>mainTitleText}" showNavButton="true" navButtonPress=".goBack">
<content>
<Label text="Welcome to details Page" />

</content>
</Page>
</mvc:View>
40 changes: 18 additions & 22 deletions webapp/view/Main.view.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
<mvc:View controllerName="ui5.challenge.controller.MainController" displayBlock="true"
xmlns:mvc="sap.ui.core.mvc"
xmlns="sap.m">
<Shell id="shell">
<App id="app">
<pages>
<Page title="{i18n>mainPageTitle}">
<content>

<Panel width="auto" title="Button Controller" class="sapUiSmallMargin">
<content>
<Button id="mainButton" text="{i18n>mainButtonText}" press=".onPress" />
</content>
</Panel>
<Page title="{i18n>mainTitleText}">
<content>

<Panel width="auto" title="List Information" class="sapUiSmallMargin">
<content>
<List headerText="{i18n>listEmployees}" items="{
<Panel width="auto" title="Button Controller" class="sapUiSmallMargin">
<content>
<Button id="mainButton" text="{i18n>mainButtonText}" press=".onTestBtnPress" />
<Button id="myControl" text="{i18n>nextNacButton}" press=".onNextPagePress" />
</content>
</Panel>

<Panel width="auto" title="List Information" class="sapUiSmallMargin">
<content>
<List id="employeeList" mode="SingleSelect" headerText="{i18n>listEmployees}" items="{
path: '/Employees'
}">
<StandardListItem title="{Name}" description="{Surname}" counter="{Age}"/>
</List>
</content>
</Panel>
<StandardListItem type="Active" title="{Name}" press=".onLinePress" description="{Surname}" counter="{Age}"/>
</List>
</content>
</Panel>

</content>
</Page>
</pages>
</App>
</Shell>
</content>
</Page>
</mvc:View>

0 comments on commit f257ff3

Please sign in to comment.