-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added everything for Step 9: Adding the Post Page
- Loading branch information
Showing
5 changed files
with
97 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
sap.ui.define( | ||
["./BaseController", "sap/ui/model/json/JSONModel", "../model/formatter"], | ||
function (BaseController, JSONModel, formatter) { | ||
"use strict"; | ||
return BaseController.extend("com.mrb.UI5-Testing.controller.Post", { | ||
formatter: formatter, | ||
/** | ||
* Called when the worklist controller is instantiated. | ||
* @public | ||
*/ | ||
onInit: function () { | ||
// Model used to manipulate control states. The chosen values make sure, | ||
// detail page is busy indication immediately so there is no break in | ||
// between the busy indication for loading the view's meta data | ||
var oViewModel = new JSONModel({ | ||
busy: false, | ||
}); | ||
this.getRouter() | ||
.getRoute("post") | ||
.attachPatternMatched(this._onPostMatched, this); | ||
this.setModel(oViewModel, "postView"); | ||
}, | ||
/** | ||
* Binds the view to the post path. | ||
* | ||
* @function | ||
* @param {sap.ui.base.Event} oEvent pattern match event in route 'object' | ||
* @private | ||
*/ | ||
_onPostMatched: function (oEvent) { | ||
var oViewModel = this.getModel("postView"), | ||
oDataModel = this.getModel(); | ||
this.getView().bindElement({ | ||
path: "/Posts('" + oEvent.getParameter("arguments").postId + "')", | ||
events: { | ||
dataRequested: function () { | ||
oDataModel.metadataLoaded().then(function () { | ||
// Busy indicator on view should only be set if metadata is loaded, | ||
// otherwise there may be two busy indications next to each other on the | ||
// screen. This happens because route matched handler already calls '_bindView' | ||
// while metadata is loaded. | ||
oViewModel.setProperty("/busy", true); | ||
}); | ||
}, | ||
dataReceived: function () { | ||
oViewModel.setProperty("/busy", false); | ||
}, | ||
}, | ||
}); | ||
}, | ||
}); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<mvc:View controllerName="com.mrb.UI5-Testing.controller.Post" | ||
xmlns="sap.m" | ||
xmlns:mvc="sap.ui.core.mvc" | ||
xmlns:semantic="sap.m.semantic"> | ||
<semantic:FullscreenPage id="page" busy="{postView>/busy}" busyIndicatorDelay="0" navButtonPress=".onNavBack" showNavButton="true" title="{i18n>objectTitle}"> | ||
<semantic:content> | ||
<ObjectHeader id="objectHeader" title="{Title}" number="{ | ||
path: 'Price', | ||
formatter: '.formatter.numberUnit' | ||
}" numberUnit="{Currency}" backgroundDesign="Translucent"> | ||
</ObjectHeader> | ||
</semantic:content> | ||
</semantic:FullscreenPage> | ||
</mvc:View> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters