Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11,665 changes: 11,628 additions & 37 deletions package-lock.json

Large diffs are not rendered by default.

48 changes: 46 additions & 2 deletions webapp/controller/BaseController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"sap/ui/core/mvc/Controller",
"sap/ui/core/UIComponent",
"sap/ui/core/Fragment",
"sap/ui/core/routing/History"
], function (Controller, UIComponent, Fragment, History) {
"use strict";

return Controller.extend("ui5.challenge.controller.BaseController", {
Expand All @@ -10,8 +13,49 @@ sap.ui.define([
getRouter: function () {
return UIComponent.getRouterFor(this);
},

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

if (sPreviousHash !== undefined) {
window.history.go(-1);
} else {
var oRouter = this.getOwnerComponent().getRouter();
oRouter.navTo("overview", {}, true);
}
},

onPress: function () {

},

loadFragment: function (sFragmentName, oController, sId) {
if (!this._aFragments) {
this._aFragments = {};
}

return new Promise(function(resolve, reject) {
if (!this._aFragments[sFragmentName]) {
var sName = this.getOwnerComponent().getMetadata().getComponentName() + ".fragment." + sFragmentName;
Fragment.load({
id: sId,
name: sName,
controller: oController
}).then(function(oFragment) {
this._aFragments[sFragmentName] = oFragment;
this.getView().addDependent(oFragment);
resolve(this._aFragments[sFragmentName]);
}.bind(this));
}else {
resolve(this._aFragments[sFragmentName]);
}
}.bind(this));
},

getFragment: function (sFragmentName) {
return this._aFragments[sFragmentName];
}

});
});
27 changes: 27 additions & 0 deletions webapp/controller/Detail.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
sap.ui.define([
"./BaseController",
"sap/ui/model/json/JSONModel"
], function (BaseController, JSONModel) {
"use strict";

return BaseController.extend("ui5.challenge.controller.Detail", {
onInit: function () {
},

onOpenDialog: function () {
this.loadFragment("Dialog", this, undefined)
.then(oDialog => {
oDialog.open()
})
},

onCloseDialog: function () {
this.getFragment("Dialog").close()
},

onBack: function () {
this.onNavBack()
}

});
});
29 changes: 29 additions & 0 deletions webapp/controller/Main.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
sap.ui.define([
"./BaseController",
"sap/ui/model/json/JSONModel"
], function (BaseController, JSONModel) {
"use strict";

return BaseController.extend("ui5.challenge.controller.Main", {
onInit: function () {
let model = {
items : [{
title: "First Item",
counter: 1
},{
title: "Secone Item",
counter: 2
},{
title: "Third Item",
counter: 1
}]
}
this.getView().setModel(new JSONModel(model), "viewModel")
},

onGoToDetail: function () {
this.navTo("Detail", undefined, undefined)
}

});
});
12 changes: 12 additions & 0 deletions webapp/fragment/Dialog.fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<c:FragmentDefinition
xmlns="sap.m"
xmlns:c="sap.ui.core"
>
<Dialog id="myDialog" type="Message" title="{i18n>myDialog}">
<content>
</content>
<endButton>
<Button text="{i18n>close}" press="onCloseDialog"/>
</endButton>
</Dialog>
</c:FragmentDefinition>
9 changes: 9 additions & 0 deletions webapp/i18n/i18n.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mainTitleText=wdi5 rocks
detailTitleText=ui5-challenge

mainButton=Main Button
myControl=Go to Detail
navButton=Back to Main
dialogButton=Open Dialog
myDialog=myDialog
close=Close
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>title</title>
<title>ui5-challenge</title>

<script
id="sap-ui-bootstrap"
Expand Down
24 changes: 22 additions & 2 deletions webapp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,28 @@
"controlId": "app",
"clearControlAggregation": false
},
"routes": [],
"targets": {}
"routes": [
{
"pattern": "",
"name": "Main",
"target": "Main"
},
{
"pattern": "RouteDetail",
"name": "Detail",
"target": "Detail"
}
],
"targets": {
"Main": {
"viewId": "Main",
"viewName": "Main"
},
"Detail": {
"viewId": "Detail",
"viewName": "Detail"
}
}
},
"rootView": {
"viewName": "ui5.challenge.view.App",
Expand Down
13 changes: 13 additions & 0 deletions webapp/view/Detail.view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<mvc:View
controllerName="ui5.challenge.controller.Detail"
xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m">
<VBox>
<Title text="{i18n>detailTitleText}"/>
<OverflowToolbar
>
<Button id="navButton" text="{i18n>navBack}" press="onBack"/>
<Button id="dialogButton" text="{i18n>dialogButton}" press="onOpenDialog"/>
</OverflowToolbar>

</VBox>
</mvc:View>
24 changes: 24 additions & 0 deletions webapp/view/Main.view.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<mvc:View
controllerName="ui5.challenge.controller.Main"
xmlns:mvc="sap.ui.core.mvc" displayBlock="true" xmlns="sap.m">
<VBox>
<Title text="{i18n>mainTitleText}"/>
<List
items="{
path: 'viewModel>/items'
}" >
<headerToolbar>
<OverflowToolbar>
<ToolbarSpacer/>
<Button id="mainButton" text="{i18n>mainButton}"/>
<Button id="myControl" text="{i18n>myControl}" press="onGoToDetail"/>
</OverflowToolbar>
</headerToolbar>
<items>
<StandardListItem
title="{viewModel>title}"
counter="{viewModel>counter}"/>
</items>
</List>
</VBox>
</mvc:View>