SAPUI5 list is not auto-growing - sapui5

I have a UI5 List which has the following attributes
growing="true"
growingTreshold="50"
growingScrollToLoad="true"
This list is inside a fragment which I include into my view. It used to work pretty well with my old project but unfortunatly since I refactored everything and included SAPUI5 Routing it doesn´t work anymore.
Now if I scroll down it shows me a [More] list item which shows the next 50 entries. Funny about that is, that I get an console error when I click on more stating
Uncaught Error: The segment {id} is required.
I guess this means the inhability of the list to auto-grow is somehow related to my new routing. The components I use look like this
{
pattern : "",
name : navigation.Constants.MyEvents,
view : navigation.Constants.MyEvents,
viewId : navigation.Constants.MyEvents,
targetAggregation : "pages",
targetControl : "idAppControl",
subroutes : [
{
pattern : "{id}",
name : navigation.Constants.EventDetailFragment,
view : navigation.Constants.EventDetailFragment
}
]
}
Does anyone now how to solve this problem? So far I couldn´t find anything related to my problem.

When navigating to the new page in your routing pass in the {id} parameter. i.e
this.getRouter().navTo("yourNewPage", {
from: currentView,
id: passedinHere
}, false);
Not having that is whats tripping up your code.

Related

sap.viz.ui5.controls.VizFrame.vizSelect() not working as expexted

I use the library sap.viz.ui5.controls.VizFrame to create a pie chart. The chart only contains two values, and I need the first to be highlighted. By Highlighted, I mean selected like if the user would have clicked it, to stand out and show the summary.
Using the vizSelection like this does not work:
oVizFrame.vizSelection(
oVizFrame.getModel().getProperty('/myPath/0'),
{clearSelection : true});
I need to appear the graph showing the relevant value highlighted. /myPath is mapped to the vizFrame.
var oDataset = new sap.viz.ui5.data.FlattenedDataset({
dimensions : [{
name : 'Object',
value : "{obj}"}],
measures : [{
name : 'Count',
value : '{Count}'} ],
data : {
path : "/myPath"
}
I found this example:
https://sapui5.hana.ondemand.com/#/sample/sap.viz.sample.SelectionByApi/preview
Confusingly it also does not act as I would expect it after the end-point was highligthed.
sap.ui.getCore().byId('Graphics').vizSelection( selection,{clearSelection : true});
you can use this command and it will work:
selection is an array:
data[Value:1, _context_row_number:1]

Meteor / Mongo 'findOne' function returning "undefined"

I'm (obiously) a beginner, first post. I'm creating a flashcards project with Meteor. I have a db called "cardsets" that contains lots of documents that look similar to this:
{ "_id" : "asdfg00724",
"setTitle" : "Les animaux",
"vocab" : [
[ "the dog", "le chien" ],
[ "the cat", "le chat" ],
[ "the rabbit", "le lapin" ],
[ "the horse", "le cheval" ] ] }
What I'm trying to do is to access a single document from the collection and assign each field in the document to a variable of the same name, with the 'vocab' field being brought in as an array.
I have an /imports/api/cardsets.js that contains this:
import { Mongo } from 'meteor/mongo';
export const Cardsets = new Mongo.Collection('cardsets');
The /server/main.js includes this line:
import '../imports/api/cardsets.js';
And the /client/main.js file includes this line:
import { Cardsets } from '/imports/api/cardsets.js';
In the /client/main.js file, I am able to directly 'insert' new documents into the database, so I know the Cardfiles const is accessible in main.js:
Cardsets.insert( {language: "Chinese", course: "CHIN102"});
Works as expected. (This is only for testing). However, NOTHING I have done with the "findOne" has produced any results:
var asdf = Cardsets.findOne( { _id : "asdfg00724"});
console.log("asdf = "+asdf);
Produces "asdf = undefined" in the console.
And if I type "Cardsets.find({}).fetch()" in the browser console, I get an error: "Cardsets is not defined."
I've tried this as well:
Cardsets.findOne({ _id : "asdfg00724"}, function(err, document) {
console.log(document.name);
});
But this produces a huge error containing the text "Match error: Failed Match.OneOf, Match.Maybe or Match.Optional validation".
I realize that there's probably a very easy thing I'm missing, but after working on this for many days non-stop, I felt it's time to ask for help.
find() and findOne() do not accept callbacks as parameters, hence your huge error.
your variables (including collections) will not be available in the console unless you're at a breakpoint inside a function where those variables are defined,
most likely you're trying to access Cardsets before the client has received that data from the server via pub-sub. Once you implement actual publications and subscriptions you'll be able to look at the .ready() state of subscriptions to know when your data is available.

Component reuse in manifest.json file

We are currently building a set of apps, where there is a lot of reuse.
Currently we got it working by using
jQuery.sap.registerModulePath and jQuery.sap.require.
But according to
Using and Nesting Components you should be able to declare your reuse components in the manifest.json file.
I had a look in the SAPUI5 Developer Guide, but couldn't really make it work. As far as i can see I need to add the following:
"sap.App" :{
"embeddedBy" : "../.."
},
"sap.ui5": {
"componentUsages" :{
"<string for my reuse component>" : {
"name" : "<name of the component>"
}
"dependencies" :{
"components" : {
"<namespace of my component>"
}}
Anyone got a working example?
Here is a working example with nested components: https://embed.plnkr.co/e7KS48/
The descriptor attribute componentUsages is available since 1.47.0. Once defined, UI5 takes care of resolving the Component and its module path before rendering the owning ComponentContainer.
ComponentContainer is needed because a Component cannot be placed into the UI without a container. In my example above, the Container is defined declaratively in Home.view.xml with the respective usage property.
<core:ComponentContainer id="containerForChildComponent"
autoPrefixId="true"
settings="{id: 'childComponent'}"
usage="reuseAnotherComponent"
manifest="true"
height="100%"
async="true"
/>
"sap.ui5": {
"componentUsages": {
"reuseAnotherComponent": {
"name": "anotherComponent",
"lazy": false
}
},
"resourceRoots": {
"anotherComponent": "./component_B"
},
// ...
}
As you can see, the resourceRoots can be also defined in the descriptor which could point to other component / app locations.
Example for UI5 apps w/ version below 1.47: https://embed.plnkr.co/ytXZJ9

Is html form requried when using Google Sitelinks Searchbox

I am trying to implement Google sitelink on a website. I read Error: Page contains property "query-input" which is not part of the schema and few other articles.
I am using JSON LD format. Here is what it looks like...
[{
"#context" : "https://schema.org",
"#type" : "Organization",
"name" : "yrshaikh.com",
"url" : "https://www.yrshaikh.com/",
"logo" : "https://yrshaikh.com/smile.png",
"sameAs" : [
"https://www.facebook.com/yrshaikh",
"https://www.instagram.com/yrshaikh/",
"https://www.pinterest.com/yrshaikhdotcom/",
"https://www.youtube.com/user/yrshaikh",
"https://twitter.com/yrshaikh",
"https://plus.google.com/+yrshaikh",
"https://www.linkedin.com/company/yrshaikh",
"https://en.wikipedia.org/wiki/yrshaikh.com"
]
},
{
"#context":"https://schema.org",
"#type":"WebSite",
"name":"yrshaikh",
"alternateName":"yrshaikh.com",
"url":"https://www.yrshaikh.com/",
"potentialAction":{
"#type":"SearchAction",
"target":"https://www.yrshaikh.com/search.html?text={search_term_string}&pop=1766357",
"query-input":"required name=search_term_string"
}
}]
(pls ignore the domain name, have replaced the actual one with a dummy domain one - yrshaikh.com)
I do not have any <form> tag on my homepage.
When I search for my domain on Google I do see a Sitelinks Searchbox, but when I enter a search term and search, it does not redirect to my target url with the search term, instead it searches in Google by whatever-search-term site:yrshaikh.com.
I have also tested my JSON LD on Google's Structured Data Testing Tool and it looks good to me, no errors/warnings.
Also another point worth noting is that this search url is internally redirected to a different route based on the incoming keyword.
Please advice.
With an array of objects. Seems like the way to go forward can be this
(i.e. using #graph instead of a normal json array):
Can you try and check for your website?
source references: https://webmasters.stackexchange.com/a/90319, https://stackoverflow.com/a/33457312/1670511
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#graph":
[
{
"#type": "WebSite"
},
{
"#type": "Organization"
}
]
}
</script>

Operations in a "RESTful" API

I have slideshows. Each slideshow consists of slide.
The following will return a list of ordered slides in a slideshow:
GET api/slideshows/123/slides:
{
{
slideId : "22",
name : "My slide"
},
{
slideId : "25",
name : "My second slide"
},
{
slideId : "26",
name : "Another slide"
}
}
I want to perform the following operation, for example:
Move slide 26 to the position after slide 22
What is a good way to expose such a request?
Either we can PUT the whole slides collection in a different order, but this will replace all the slide data if there happen to be more changes. Plus it could be a lot of data to transfer.
PUT api/slideshows/123/slides
Another option is to supply a moveAfter "operation":
POST api/slideshows/123/slides/26?action=moveAfter
body:
{
referenceId : "22"
}
I understand that this isn't entirely RESTful, but what other practical solutions exist?
I would do something like this: PUT api/slideshows/123/slides/26/position 22.
Btw. it is interesting. You can do it 2 ways:
every slide has a unique id, which does not depend on the order
the id is the same as the order index (or position) - in this case you have to update the whole collection after every move, because the server maintains the resource state and not the client, so it will be much slower.
I would go with the following design.
The key point here is that the slides for a slideshow are just an array of URIs pointing to the constituent slide resources. To reorder, add, or remove slides from a slideshow, you PATCH the slideshow resource with the new slides array.
Creating a slide is done independent of the slideshow that references it. Associations between slideshows and slides can only be changed by doing a PATCH on the slideshow resource.
Resource URIs do not nest deeply. That is a poor design choice that can come back to bite you later.
I illustrate it with a series of request-response pairs.
GET /slideshows/17
200 OK
{
"slideshow_id": 17,
"slides": [
"/slides/15",
"/slides/42",
"/slides/76",
"/slides/31"
]
}
POST /slides
{
"content": "..."
}
201 Created
Location: /slides/93
GET /slides/93
200 OK
{
"slide_id": 93,
"slideshow_association": null,
"content": "..."
}
PATCH /slideshows/17
{
"slides": [
"/slides/15",
"/slides/31"
"/slides/42",
"/slides/76",
"/slides/93"
]
}
204 No Content
GET /slides/93
200 OK
{
"slide_id": 93,
"slideshow_association": {
"slideshow": "/slideshows/17",
"index": 4,
"previous_slide": "/slides/76",
"next_slide": null
},
"content": "..."
}