Jump to content


Photo

Module: StayOnTab (in nightly build PW2.2)

Module

  • Please log in to reply
9 replies to this topic

#1 Soma

Soma

    Hero Member

  • Moderators
  • 5,051 posts
  • 3818

  • LocationSH, Switzerland

Posted 20 February 2012 - 08:03 AM

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.

@somartist | modules created | support me, flattr my work flattr.com


#2 ryan

ryan

    Reiska

  • Administrators
  • 7,797 posts
  • 6572

  • LocationAtlanta, GA

Posted 20 February 2012 - 02:44 PM

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.

#3 Soma

Soma

    Hero Member

  • Moderators
  • 5,051 posts
  • 3818

  • LocationSH, Switzerland

Posted 20 February 2012 - 02:58 PM

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?

@somartist | modules created | support me, flattr my work flattr.com


#4 ryan

ryan

    Reiska

  • Administrators
  • 7,797 posts
  • 6572

  • LocationAtlanta, GA

Posted 20 February 2012 - 03:05 PM

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.

#5 Soma

Soma

    Hero Member

  • Moderators
  • 5,051 posts
  • 3818

  • LocationSH, Switzerland

Posted 20 February 2012 - 03:15 PM

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?

@somartist | modules created | support me, flattr my work flattr.com


#6 ryan

ryan

    Reiska

  • Administrators
  • 7,797 posts
  • 6572

  • LocationAtlanta, GA

Posted 20 February 2012 - 03:21 PM

You are right, in this case the redirect would have to include the hash. In PW1 there was no redirect, so that wasn't a consideration. Still, that won't be a problem.

#7 Soma

Soma

    Hero Member

  • Moderators
  • 5,051 posts
  • 3818

  • LocationSH, Switzerland

Posted 21 February 2012 - 04:26 PM

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. ::) It saves quite some time and interuption.

@somartist | modules created | support me, flattr my work flattr.com


#8 ryan

ryan

    Reiska

  • Administrators
  • 7,797 posts
  • 6572

  • LocationAtlanta, GA

Posted 22 February 2012 - 09:17 AM

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.

#9 ryan

ryan

    Reiska

  • Administrators
  • 7,797 posts
  • 6572

  • LocationAtlanta, GA

Posted 25 March 2012 - 01:51 PM

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.

#10 Soma

Soma

    Hero Member

  • Moderators
  • 5,051 posts
  • 3818

  • LocationSH, Switzerland

Posted 25 March 2012 - 02:37 PM

I already tested it and it's great addition! Also got used to it fast. The options are perfect and makes sense. Thanks!

@somartist | modules created | support me, flattr my work flattr.com






Also tagged with one or more of these keywords: Module

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users