sap.ui.define(
[
'sap/fe/core/PageController'
],
function(PageController) {
'use strict';
return PageController.extend('flex.customformentry.ext.main.Main', {
onInit: function() {
PageController.prototype.onInit.apply(this);
const router = this.getAppComponent().getRouter();
router.getRoute("OrdersMain").attachPatternMatched(this._onObjectMatched, this);
},
_onObjectMatched: function() {
if(this._createDone) {
if (sap.ushell && sap.ushell.Container && sap.ushell.Container.getService) {
var oCrossAppNav = sap.ushell.Container.getService("CrossApplicationNavigation");
oCrossAppNav.toExternal({
target: {
shellHash: "#"
}
});
}
} else {
this._createDone = true;
const listBinding = this.getAppComponent().getModel().bindList("/Orders");
this.editFlow.createDocument(listBinding, {
creationMode: "NewPage"
});
}
}
});
}
);
this.editflow.<functionName>
./<EntityName>(<key>)
so a route matching this pattern has to exist (we will be creating this route in the next step).PageController.prototype.onInit.apply(this)
. Omitting this line will cause issues in Flexible Programming Model.#<SemanticObject>-<Action>&/<Entity>(<key>)
to #<SemanticObject>-<Action>
, triggering navigation back to the main page. As I did not want to repeat creating new documents, I decided to navigate back to the launchpad if the same route is accessed a second time. "routing": {
"config": {},
"routes": [
{
"name": "OrdersMain",
"pattern": ":?query:",
"target": "OrdersMain"
},
{
"name": "OrdersForm",
"pattern": "Orders({OrdersKey}):?query:",
"target": "OrdersForm"
}
],
"targets": {
"OrdersMain": {
"type": "Component",
"id": "OrdersMain",
"name": "sap.fe.core.fpm",
"options": {
"settings": {
"viewName": "flex.customformentry.ext.main.Main",
"entitySet": "Orders",
"navigation": {
"Orders": {
"detail": {
"route": "OrdersForm"
}
}
}
}
}
},
"OrdersForm": {
"type": "Component",
"id": "OrdersForm",
"name": "sap.fe.core.fpm",
"options": {
"settings": {
"viewName": "flex.customformentry.ext.view.Form",
"entitySet": "Orders",
"navigation": {}
}
}
}
}
}
}
<mvc:View xmlns:core="sap.ui.core"
xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:macros="sap.fe.macros"
xmlns:html="http://www.w3.org/1999/xhtml" controllerName="flex.customformentry.ext.view.Form">
<Page id="Form" title="Form">
<content>
<Panel headerText="Order information" >
<macros:Form metaPath="@com.sap.vocabularies.UI.v1.FieldGroup#main" id="main"/>
</Panel>
<Panel headerText="Order items" >
<macros:Table metaPath="to_Items/@com.sap.vocabularies.UI.v1.LineItem" id="items"
/>
</Panel>
</content>
<footer>
<OverflowToolbar>
<ToolbarSpacer />
<Button text="Create" press="saveDocument" type="Emphasized"
visible="{viewModel>/editable}" />
<Button id="cancelButton" text="Cancel" press="cancelDocument"
visible="{viewModel>/editable}"/>
</OverflowToolbar>
</footer>
</Page>
</mvc:View>
sap.ui.define(
[
'sap/fe/core/PageController',
'sap/ui/model/json/JSONModel',
],
function(PageController, JSONModel,) {
'use strict';
return PageController.extend('flex.customformentry.ext.view.Form', {
onInit: function() {
PageController.prototype.onInit.apply(this);
let model = {
editable : true
};
this.getView().setModel(new JSONModel(model), "viewModel");
},
saveDocument: function () {
var that = this;
this.editFlow.saveDocument(this.getView().getBindingContext()).then(function(){
that.getView().getModel("viewModel").setProperty("/editable", false);
})
},
cancelDocument: function () {
var that = this;
this.editFlow.cancelDocument(this.getView().getBindingContext(), {
control: this.byId("cancelButton")
}).then(function(){
that.getView().getModel("viewModel").setProperty("/editable", false);
})
}
});
}
);
&/<EntityName>(<key>)
, and if you discard the document, this part will be removed from the pattern.You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
14 | |
11 | |
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
3 |