Communication between components with Vue and routes - vue.js

I'm just starting with vue but I'm stuck here: I want to pass info from a component to another one. I'm using routes.
If you click on teacher > student list > check (the first one) you render a component (student grade). There, I want to output data from the array students which is stored in student list.
How can I do that?
This is my work:
https://codesandbox.io/s/61xk8xjy63

I recommend use params in vue-router.
Sample: https://codesandbox.io/s/zrk6r0o4ml.
In sample used named path (docs: https://router.vuejs.org/essentials/named-routes.html) and params path (docs: https://router.vuejs.org/essentials/passing-props.html).
Also, i use v-for for display array of data (file StudentList.vue, docs: https://v2.vuejs.org/v2/guide/list.html#Mapping-an-Array-to-Elements-with-v-for).
Good luck.

Related

How to pass link query params to deeplink using Branch.io

Is it possible to create a branch link that receives a query param, and then use this parameters as a path param to the deeplink passed to the app?
Example:
Branch link - something.app.link/something_else?id=1
Deeplink configuration inside branch panel (ex: $ios_deeplink_path): myapp://something_else/:id
Would this be possible (having this dynamic :id parameter)?
If your use case is to create dynamic links then definitely it is possible. If you would like to append custom data to one of the Quick Links you can do it in the following way -
https://your.app.link/fzmLEhobLD?content_id=123
For long links which can be created without network calls to Branch, you can have something like this -
https://your.app.link/fzmLEhobLD?foo=bar&baz=456&$fallback_url=https%3A%2F%2Fbranch.io%2F
Similarly a dynamic long link would be -
https://your.app.link/?foo=bar&baz=456&$fallback_url=https%3A%2F%2Fbranch.io%2F
You can reference the following Branch Documents for all above examples -
https://help.branch.io/using-branch/docs/creating-a-deep-link#section-create-deep-links
https://help.branch.io/using-branch/docs/creating-a-deep-link#section-long-links

How to regularly update mongoose db in express js without req

I want to retrieve 'Content' instances sorted by a ranking factor, which changes by likes, dislikes and time. First solution I came up was adding 'ranking factor' virtual field on the 'Content' model, but mongoose didn't allow me to sort the instances by the virtual field when retrieving them. So the only solution I have now is adding 'ranking factor' field on the model and update all content instances regularly using setTimeOut function of node js. Then where should I add setTimeOut function in express js structure?
I considered adding setTimeOut(2000, // update all content instances here) on app.js file, but there was a feeling that it is not somewhat right. I'm planning to add the codes like below.
setTimeOut(2000, Content.findAndUpdate(*, {rankingFactor: calculateRankingFactorWithTime(window.currentDate, this.likes, this.dislike}))

vue-router: how to check if current route is a route or one of its subroutes?

I'm wrapping router-link to add some features.
I need to check if current route is a route or a subdolder of a route.
Something like the following
I know it cannot works, because :active need a boolean, but javascript String.match returns an array;: it's to explain my goal
:active="$route.name.match('customer_users*')"
In my router.js I definied that /customer/{customer_id}/users is named customer_users and that /customer/{customer_id}/users/{user_id} is named customer_users_edit.
So i'd like to be able to set ":active" in my wrapper for both these routes.
Use the $route.matched property to see if the current route is your customer_users or any of its children.
For example, using Array.prototype.some()
:active="$route.matched.some(({ name }) => name === 'customer_users')"
See https://v3.router.vuejs.org/api/#route-object-properties
$route.matched
type: Array<RouteRecord>
An Array containing route records for all nested path segments of the current route.

use google tag manager custom HTML tag to populate data on pages

I have a question about gtm.
so currently I have created a script that can create all the data I need into datalayer this is how the data layer looks like (from page source code):
<script>
dataLayer = [{"visitorLoginState":"Logged out","visitorType":"NOT LOGGED IN","visitorLifetimeValue":0,"visitorExistingCustomer":"No"}];
</script>
but all this is generated from my store, but they key would be to be able to use these variables through GTM.
so inside GTM UI i created a custom html tag and added:
<script>
dataLayer.push({'event': 'visitorLoginState'});
</script>
I also created a custom macro->data layer variable with the name of "visitorLoginState" hoping that it would show "NO" instead of visitorLoginState in the response. but it just showing "visitorLoginState"
I am new to GTM too and getting to grips with it all.
From what I can see it looks like you are using macros and the dataLayer incorrectly.
You are running a script to add another row called event to the datalayer whilst already declaring what you want in the data layer. So initially the output in the source would be along the lines of:
visitorLoginState: Logged Out
visitortype: Not Logged In
ETC...
With the script you have added in GTM it would go to:
visitorLoginState: Logged Out
visitortype: Not Logged In
event: visitorLoginState
ETC
What you want to do is actually create a macro called visitorLoginState with the Type of Data Layer Variable, using the Data Layer Variable Name of visitorLoginState (and so forth).
From there you can create a Rule in GTM which will activate something based on what is returned in the data layer.
So your Rule could be:
visitorLoginState equals Logged out.
You could then have your script in the tags part of GTM which would say something like:
<script>
dataLayer.push({'event': 'No'});
</script>

How to pass a field that is an array list in a java bean, within a JasperReports?

Could some indicate a working example or a snippet of code for JasperReports regarding ArrayList as a Field in a javabean datasource.
I have a List of Employees. Each Employee has a name field, and an array of Phone with type and number as its fields.
Do i use a subreport for Phones I have not found a working example? Cant seem to compile subreport_jasper file?
Do i use a list component instead...
<c:list ...>
<datasetRun subDataset="Addresses">
<datasetParameter name="Phone">
<datasetParameterExpression><![CDATA[$F{Phone}]]></datasetParameterExpression>
</datasetParameter>
</datasetRun>
This does seems to work either?
Thank in advance
I wrote this article while working with MongoDB. It deals with handling fields that are collections. It should be exactly what you need. (You can just ignore the MongoDB part.)
The key idea is that you use this to pass data to a List or Table or Subreport:
new net.sf.jasperreports.engine.data.JRMapCollectionDataSource($F{PhoneArray})