Good question. I’ve not tried this, except to load a LoginForm that doesn’t have any routing behaviour.
I think just using standard open_form('SecondaryMainRouter') will work (with some limitations).
this will make SecondaryMainRouter the MainRouter and it should sort of behave as you would expect…
except that things will get tricksy if you use the back button to load a route that is not part of SecondaryMainRouters known routes.
If there are no differences between the route Forms of PrimaryMainRouters and SecondaryMainRouter then there should be no issue.
If there are differences then you would probably need to customize the MainRouteron_navigation function…
pseudo code that might work…
def on_navigation (self, **nav_args):
if nav_args['url_pattern'] is from the OtherMainRouter:
open_form(OtherMainRouter)
# this probably won't work ... but maybe
If you produce a minimum code example with a clone link, I would be happy to take a look.
and if necessary include the feature if it can’t be hacked.
If I’m not mistaken, loading the secondary router with open_form(SecondaryMainRouter) essentially disables the routes on the URL right?
The scenario that I’m trying to address is:
URL - /Workspace (uses the Main Router with the side bar)
URL - /Projects (uses the Secondary Router without the side bar)
So the need for the secondary router is inside the users workflow, not something as discrete as Login which happens prior to the users’ workflow.
What about having a single main_router and using the on_navigation function… just hiding the sidebar column panel depending on the url_pattern And changing anything in the address bar that needs changing…
Yes, I’m going down that path right now where given the url_pattern, I completely hide the sidebar and the hamburger nav and enable it by adding the following JS function in the standard-page.html file and calling it using the anvil.js.call_js() method.
function disableSidebar() {
/* hide the hamburger nav */
var ln = $('.structure > .app-bar > .sidebar-toggle');
ln.css("display", "none");
/* hide the sidebar itself */
this.hideSidebar();
}
function enableSidebar(){
/* show the hamburger nav */
var ln = $('.structure > .app-bar > .sidebar-toggle');
ln.css("display", "block");
/* show the sidebar itself */
this.showSidebar();
}
The above does the trick as all I needed to remove was the sidebar.