I am new in KeystoneJS and was trying to add a new navigation tab in the admin panel , so for the same i made changes in the keystone.js file and added the required navigation tab in the code
"keystone.set('nav', {
....
});"
but after making changes in it and then running the code i get an error Unknown keystone list "newTab"
I don't know the name of your model, but the correct syntax is:
keystone.set('nav', {
'<tab-name>': '<modelname>'
});
Where tab name can be anything, and modelname should be either the exact (case sensitive!) same name as your model name or a lower case plural version of it.
For example:
Your model: Artwork.js
var Artwork = new keystone.List('Artwork', { ... });
Your navigation definition:
keystone.set('nav', {
'art': 'Artwork'
});
OR
keystone.set('nav', {
'art': 'artworks'
});
Related
I have used unified Shell control in order to implement the facebook-like swipe menu and I integrated in it a list so that I can enter menu items. The idea is that when a user clicks on a certain list item in the menu he will get redirected to a new view. I tried to implement it by using bus.publish("nav", "to" {id:..}) but it's not working. (I have put the menu in the Curtain Pane of the Unified Shell) Can anybody help me?
You can find below the respective code snippets of the view and controller.
var oListTemplate = new sap.m.StandardListItem({
title: "{title}",
icon: "{icon}",
description: "{description}",
type: sap.m.ListType.Navigation,
customData: new sap.ui.core.CustomData({
key: "targetPage",
value: "{targetPage}"
})
});
var oList = new sap.m.List({
selectionChange: [oController.doNavOnSelect, oController],
mode: sap.m.ListMode.SingleSelectMaster
});
oList.bindAggregation("items", "/Menu", oListTemplate);
The controller:
onInit: function() {
this.getView().setModel(new sap.ui.model.json.JSONModel("model/menu.json"));
this.bus = sap.ui.getCore().getEventBus();
},
doNavOnSelect: function(event){
if (sap.ui.Device.system.phone) {
event.getParameter("listItem").setSelected(false);
}
this.bus.publish("nav", "to", {
id: event.getParameter('listItem').getCustomData()[0].getValue()
});
Navigation via the sap.ui.core.EventBus is obsolete.
Please have a look at "Navigation and Routing" https://help.sap.com/docs/SAP_NETWEAVER_AS_ABAP_FOR_SOH_740/468a97775123488ab3345a0c48cadd8f/688f36bd758e4ce2b4e682eef4dc794e.html?locale=en-US
A new Routing mechanism was introduced to SAPUI5 in release 1.16. For in-app navigation, this supersedes previous techniques such as using the sap.ui.core.EventBus or sharing navigation-container specific controller code amongst aggregated pages.
Solution: Replace bus.publish with app.to
doNavOnSelect: function(event){
if (sap.ui.Device.system.phone) {
event.getParameter("listItem").setSelected(false);
}
app.to(event.getParameter('listItem').getCustomData()[0].getValue());
}
Im fairly new to SAPUI5 and when I click on button I get the error in the title
what I did in Is I used the SAP web IDE to create new MVC project .
in the main view JS I put
createContent : function(oController) {
var btn = new sap.m.Button({
id:"myBtn",
text : "Content Button"
});
return new sap.m.Page({
title: "TitleT",
content: [ btn ]
});
}
in the Main controller JS I put the following code
onInit: function() {
var that = this;
window.setTimeout(function() {
that.byId("myBtn").setVisible(true);
}, Math.random() * 10000);
},
onPress: function() {
this.byId("pressMeButton").setText("I got pressed");
}
When I run it I see the button but when I click on it I get the error in the on Init,
what am I doing wrong here?
The actual problem with your code is that you create a static id in your javascript view, but the controller will search the id with a prefix like "__jsview0--myBtn" if you call that.byId("myBtn").
Therefore you either have to use createId("myBtn") in your javascript view for defining the id or sap.ui.getCore().byId("myBtn") in the controller and it will work fine. The first approach is recommended though to avoid name clashes.
PS:
i did not really get the use case, it seems like you want to display the button only after a certain (random) timeframe. But the visible flag by default is already true, so the button will always be visible.
Use the standard timeout and byId function from SAPUI5 like this:
onInit: function() {
setTimeout(function() {
sap.ui.getCore().byId("myBtn").setVisible(true);
}, Math.random() * 10000);
},
I see this example
https://openui5.hana.ondemand.com/explored.html#/entity/sap.ui.unified.Shell/samples
Now I have a root view (this.app) and all works fine.
return this.app;
Now I want include the root app in a shell container..
I try to do this:
var oShell= new sap.m.Shell("idShell", {
title: "Test App",
logo:"https://dl.dropboxusercontent.com/u/7546923/OpenUI5/SAPUI5.png",
headerRightText: "This is a sap.m.Shell",
logout: function() {alert("Logout button was pressed");}
});
oShell.setApp(this.app);
return oShell;
But in this way I can't see the bar on the top. (I see only the app limited in width and the logo out of the app, on left)
I try to do this:
var oShell= new sap.m.Shell("idShell", {
title: "Test App",
logo:"https://dl.dropboxusercontent.com/u/7546923/OpenUI5/SAPUI5.png",
headerRightText: "This is a sap.m.Shell",
logout: function() {alert("Logout button was pressed");}
});
oShell.setApp(sap.ui.xmlview("view.shell")); //the view of the example in the documentation
return oShell;
In this way I can see the bar but I can't associate the root app in the content of shell
Now I use sap.ui.unified.Shell
jQuery.sap.require("sap.ui.unified.Shell");
jQuery.sap.require("sap.ui.unified.ShellHeadItem");
this.shell = new sap.ui.unified.Shell('');
var logout=new sap.ui.unified.ShellHeadItem({
tooltip: "Logout",
icon: "sap-icon://menu2"
});
this.shell.addHeadItem(logout);
this.shell.addContent(this.app);
How can I use a MVC pattern to manage the shell bar content? I want use an XML-view. And how can I avoid to write
jQuery.sap.require("sap.ui.unified.Shell");
jQuery.sap.require("sap.ui.unified.ShellHeadItem");
?
This works for me:
new sap.m.Shell("Shell", {
app: sap.ui.jsview("RootView", "my-app.view.App")
}).placeAt("root");
While the root control of my-app.view.App is a sap.m.SplitApp (or sap.m.App). Note that the sap.m.Shell is just providing a frame it is NOT providing any NavContainer, Page or similar concept you usually use in sap.m. What is the root control in your view.shell? From the docs:
getApp() : sap.ui.core.Control
Getter for aggregation app. A Shell contains an App or a SplitApp
(they may be wrapped in a View). Other control types are not allowed.
Btw: Your example link is not working for me.
BR
Chris
I'm working on to write a new payment plugin on nopcommerce.
How can I render a new partialview in PaymentInfo.cshtml? The new view locates the same path with PaymentInfo.cshtml.
to render any view in the plugins for nopCommerce it must be embedded resource and it must be written in fully qualified name like
#Html.Partial("Nop.Plugin.Something.Something.Views.Plugin.VIEWNAME", item)
You can create a Custom View Engine and add that to your payment plugin. This so you can add routes to Nopcommerce.
First you create a Custom View Engine
CustomViewEngine.cs
public class CustomViewEngine : RazorViewEngine
{
public CustomViewEngine()
{
PartialViewLocationFormats = new[] { "~/Plugins/Misc.HelloWorld/Views/{0}.cshtml" };
ViewLocationFormats = new[] { "~/Plugins/Misc.HelloWorld/Views/{0}.cshtml" };
}
}
Change paths of the Misc.Helloworld to the path of your plugin.
Change the .Edit to the action in your controller.
Change the other information of the controller and the action to the names in your plugin.
After that, create a RouteProvider.cs
ViewEngines.Engines.Insert(0, new CustomViewEngine());
var route = routes.MapRoute("Plugin.Misc.HelloWorld.Edit",
new { controller = "HelloWorld", action = "Edit", },
new { },
new[] { "Nop.Plugin.Misc.HelloWorld.Controllers" }
);
routes.Remove(route);
routes.Insert(0, route);
Change Misc.HelloWorld to the path of your Payment.Plugin,
After that u can add the following to the embedded source
#Html.Partial("Actionname", item)
For more information, see the blog of Alex Wolf
I am on my way building a Fiori like app using SAPUI5. I have successfully built the Master page, and on item click, I pass the context and navigate to Detail page.
The context path from Master page is something like /SUPPLIER("NAME"). The function in App.controoler.js is as follows:
handleListItemPress: function(evt) {
var context = evt.getSource().getBindingContext();
this.myNavContainer.to("Detail", context);
// ...
},
But I would like to know how I can access this context in the Detail page. I need this because I need to use $expand to build the URL and bind the items to a table.
There is an example in the UI5 Documentation on how to deal with this problem using an EventDelegate for the onBeforeShow function which is called by the framework automatically. I adapted it to your use case:
this.myNavContainer.to("Detail", context); // trigger navigation and hand over a data object
// and where the detail page is implemented:
myDetailPage.addEventDelegate({
onBeforeShow: function(evt) {
var context = evt.data.context;
}
});
The evt.data object contains all data you put in to(<pageId>, <data>). You could log it to the console to see the structure of the evt object.
Please refer the "shopping cart" example in SAP UI5 Demo Kit.
https://sapui5.hana.ondemand.com/sdk/test-resources/sap/m/demokit/cart/index.html?responderOn=true
Generally, in 'Component.js', the routes shall be configured for the different views.
And in the views, the route has to be listened to. Please see below.
In Component.js:
routes: [
{ pattern: "cart",
name: "cart",
view: "Cart",
targetAggregation: "masterPages"
}
]
And in Cart.controller.js, the route has to be listened. In this example, cart is a detail
onInit : function () {
this._router = sap.ui.core.UIComponent.getRouterFor(this);
this._router.attachRoutePatternMatched(this._routePatternMatched, this);
},
_routePatternMatched : function(oEvent) {
if (oEvent.getParameter("name") === "cart") {
//set selection of list back
var oEntryList = this.getView().byId("entryList");
oEntryList.removeSelections();
}
}
Hope this helps.