VueJS : Dynamically change the URL depending on filters - vue.js

I have a project for which I use VueJS (2.x) for the frontend part.
I've made a component to do some filtering :
And I'd like to be able to change the URL according to the filters, so that I can share the URL and another user would land on the same search. At the stage of my screenshot, the URL should look like : my/long/url?username=test&email=#test. But I don't know how to achieve it.
Currently, when I add/remove a filter, I create a new URLSearchParams object that I commit to the vuex store and with a watch statement I query my backend again with the updated filters.
The thing is that my URL doesn't change, of course, because I do not pass by a this.$router.push(...) or whatever.
Maybe I started it wrong.
What is the good way of achieving this ? Knowing that routing to the same view with a new query part does trigger the error DuplicateNavigation...
Thanks in advance for your help :)

I had achieved something similar to this by using the history.pushState
This basically allows you to modify your URL even if you are not using $router.push
You can follow the URL for more details
https://developer.mozilla.org/en-US/docs/Web/API/History/pushState

Related

Dynamic routes but not in the traditional sense

I wanted to know if there is a way to dynamically generate routes based on data from a database?
Currently, i am defining my routes in a routes file and then importing that into my vue project. Is there a way i can have specific configurations stored on a database such as the path, name, meta data and then when the application loads, depending on the auth level of the user, create routes for that user?
Reason why I'm asking to create and not use a pre-written route with params is because i want to give my users (at some point in the future) the ability to create their own pages from my system.
So just wanted to know from the community if there is a way to do this based on an axios call or something?
You can just use dynamic routing. To create new templates, code must be changed anyway.
I think technically you are still better off using a title parameter with a common prefix and just looking up that title. In theory it sounds nice to have a completely dynamic application where anyone can create any page... until someone decides to use "login" as the page name and override your own login component, making the app unusable.
That said, you can use router.addRoutes to dynamically add routes to your router. Create a router with the static routes (e.g. your homepage, your login page, your 404 page), then extend your router based on an api call.

Is there a way to make Prestashop's Layared Filter Module to use query parameters instead of anchors (hashes)?

Is there any way to make the standart PrestaShop's Layered filters module to use URL parameters instead of anchors (the part after hash)?
I ment that I want the layered filter generate and accept the URLs like this (or maybe somehow diferrent, but the key is to use parameters and not to use hashes):
my-example-shop.ru/some-category/?color=red&size=xl
instead of this:
my-example-shop.ru/some-category#/color-red/size-xl
The reason is that the most of advertisment systems could add some parameters to the URL, but they usuaul add it directly to the end of the URL, and dont trying to analyze url structure and insert parameters to the right place.
So, as far as i see, the obvious solution is to avoid using hashes in url, using just query parameters, and to use history.pushState to change URL without refreshing whole page...
It seems obvious, usable, but I cant find any ready-to-use solution that do this such way, and I cant find even information about how does someone did it..
So the questions are:
is there any ready-to-use solution?
is there any described way to reach this by myself?
Thanks in advance.
UPD
All I found by myself for now is that such URLs could be accepted:
my-example-shop.ru/some-category/color-red/size-xl
my-example-shop.ru/some-category?selected_filters=/color-red/size-xl
BUT any filters changing causes using hashes again (afaik, hashed filters values overrides values passed via selected_filters parameter, so subsequent navigation just ignores selected_filters). In other words - I just can clear the entry URL, BUT I couldnt make URLs to be clean for subsequent navigation.
The change is very large.
You should create the override classes/Dispatcher.php
For filters instead you should edit the file: blocklayered/blocklayered.php
find function: getSelectedFilters()
Inside are two foreach, you should withdraw from the url "featured" fields that you need and compile the new array "$selected_filters"

CloudConnect: Dynamic URL in REST Connector

What is the best way to create a dynamic request URL for the REST Connector in CloudConnect?
e.g. I want the URL to be for example www.myservice.com/api/{todays-date}/report.json and the URL must change accordingly everytime the ETL runs.
Is there some way to make this happen by code in CloudConnect? I didn't find any straight forward way but I found that one might be able to import a remote file containing the URL.
Does anyone have experience or tips on this subject?
what should work the best is to generate this parameter (e.g. in Data Generator) or read some data from the source (e.g. list of IDs) and send it to the REST component as an input parameter (e.g. metadata field name is 'today_date', so use ${today_date}). As far as I know this should work.
Another option is to use a parameter from a *.prm file (like workspace.prm). You can use ${PARAMETER_NAME} in your URL and this should also work correctly.
Hope this helps.
Radek

Passing the arguments to a website

Well the title is tricky. I was not sure if this has been already there and how to put it.
Example:
Lets suppose my site is accessible:
http://mysite.com
if mysite does additions: with 2 inputs
Now If the end user need to pass an argument to site like this (so i load the page like this):
http://mysite.com/argument1/argument2
so it should be able to thus go to the result directly: arg1+arg2
This brings to the question:when user types this, how can i retreive argument1 and argument2 and load my site according to that? Is it possible? If yes, Any client site programming solutions?
Thanks in advance.
Found the solution after searching a lot. The correct term for this process is URL-routing. We can overcome this by using #.
www.mysite.com/#/argu1/argu2
Then in the document.ready() we can read the url in the following manner:
var url = window.location;
More sophisticated way is to use the "backbone.js" for the routing. The documentation on the link explains everything
Backbone.js routing

How to create custom context in OpenERP

I want to create custom context in OpenERP. Need something like polish notation in domain with '|'. Need also hierarchial like 'region_id','child_of','region_id.parent_id'. is it possible?
thanks :)
As far as I know, you can dump any data you want into the context, and it's up to the server-side code to interpret that data. The only time I've run into trouble with context was when two screens used the same key in context but put conflicting data there. Then visiting one screen would break the other screen.