Jump to content

Module: StayOnTab (in nightly build PW2.2)


Soma
 Share

Recommended Posts

This behavior has been integrated in current nightly build of PW 2.2. It can be configured via WireTabs module settings.

StayOnTab (Module for Processwire2+)

This new module remembers the active tab you are on and opens it after saving, or reloading page.

https://github.com/somatonic/StayOnTab

This is still in progress. Just wanted to share and recieve some feedback.

Link to comment
Share on other sites

This is great Soma. I've actually been meaning to have this capability built into WireTabs for quite awhile (it was in PW1 and just never made it over yet). Perhaps we could combine efforts and make this part of the core, as I think it's always better for it to return to the tab it was on when you click save.

Link to comment
Share on other sites

Great to hear! Yeah I started few weeks ago already and then put it away a little. It's only kinda proof of concept, but works well so far. Just some things to consider.

Currently it's just saved as session, so it opens the last "saved" tab, even if you go to another page or close, repopen it.

I wanted it to try to make it so, that it would only save tab when saving page. So when reopen the page it would first be on content tab again. But maybe it would be cool to always have the last selected open. I'm still not sure how it would be best.

How was it in PW1?

Link to comment
Share on other sites

Here's how I was thinking it could work (also the way it worked in PW1). The WireTabs class would auto-select a tab when the URL had a # in it. For instance, /processwire/page/edit/?id=1#children would automatically select the 'children' tab when the page was loaded. Then, every time a tab was clicked, some JS would modify the <form> action attribute to change the # property in the URL. It's a simple concept, but makes sense with the purpose of the '#' properties in a URL to be what auto-selects a tab, much like it would jump to a place in another HTML document.

Link to comment
Share on other sites

I think I saw some evidence of this in the source code :)

Yeah that would be a good concept. Though does the hash # stay in the address even after save? I don't think so. Isn't there a redirect in the edit page?

Link to comment
Share on other sites

I'm currently using my version with saving it in session, and I really love it how it makes creating fields and repeating changed to fields. Like doing now with the repeater. :rolleyes: It saves quite some time and interuption.

Link to comment
Share on other sites

Testing out here, I agree this is really nice. Perhaps we should just implement it at the session level in the core rather than in the URL. I'm still not totally sure I like deleting a page, and then getting put into the delete tab of the next page I edit (for example) but most of the time the change in behavior is welcome.

Link to comment
Share on other sites

  • 1 month later...

Soma I hope you don't mind, but I took this functionality and brought it into the core. After using your module for several days, I got used to the behavior and found I couldn't live without it. So it had to go in the core. :) Rather than integrating it in the session, it is now part of the JqueryWireTabs module (all JS) and uses cookies to remember tab positions. I figured I might as well let that WireTabs plugin be responsible for remembering the tab states.

I wasn't sure if everyone would want the behavior or not, so it is configurable under Modules > Jquery > Wire Tabs. By default, it only remembers tab positions between form posts (which I think is the most natural behavior). But you can set it to remember all tab positions between pages, or disable the behavior entirely.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...