ACF-Repeater-Collapser
ACF-Repeater-Collapser copied to clipboard
Collapsed by Default
Questions to answer:
- Is this set per-user? (e.g. Can one user have a fieldset open by default and the other collapsed?)
- Is this set per-field, per-fieldset, or universally?
- How is this set? An option on a settings page? An option on the fieldset settings? An option on the specific page?
- Is this the default behavior? (I am almost positive it's not.)
Thanks for opening this up. I personally say the default behavior should NOT collapse by default (like how it is now), but I think it should be a global option, probably on a per-user setting.
I'd propose that there is a settings page under Settings > ACF Repeater Collapser which displays a select or checkbox for "Default to Open" and "Default to Collapsed" and maybe a user or user role repeater that lets you override the selected option above. Maybe it could use wp_dropdown_roles()?
I might be willing to help make these changes if you don't have time. I have a client who requested this functionality so I wrote that little plugin but I don't feel super great about how it works (it just fires a jQuery "click" on your collapse all button after your JS loads).
@JulienMelissas Thanks for this good feedback. I think your vision for a rather simple implementation of this feature makes sense to me. I might consider tucking the option on the Settings > Writing screen if it's only going to be a single checkbox. If it's per-user, then it would probably go on the My Profile page even though that doesn't feel all that great to me.
Once we can hammer out the details of the feature and get the ACF5 support stable, I'd be happy to accept a pull request on this feature. You definitely took a quick and dirty approach in your version of the feature. Probably made sense for a one off, but we could definitely do better by catching it during the JS init functions.
I'd say simple implementation is the best option - you don't want your plugin to be too bloated. Today I was actually hanging out with a few friends of mine and I asked them where they would put the feature. One of them is a plugin developer and the other works for Automattic. One of them asked "can't you just make a button that toggles ALL of the rows?" and I mentioned that you had that. We talked about it a little more and thought that checking for user roles might not be reliable enough and that it's actually not an easy problem to solve, but that it might not need it's own settings page in the backend. I personally like the idea of a checkbox living in the writing settings page, only thing is that it might not be super intuitive.
I had been thinking about another option that one of my friends mentioned as well - what about a filter? It could be as simple as a if_function_exists and then inside that a flag for collapse_by_default = true or something like that. The could be placed in the theme's functions.php or even in a per-theme plugin. It's a little less intuitive but might be the best solution, as you could do checks for current_user_can and the like...
Just thought I would offer my 2cents. Either way I'm happy to help with implementation down the road once you're more comfortable with how the ACF5 support is coming and have made a decision about how you think it should work.
- Interesting thought on a filter. That may be a smart way to go as I imagine that it's mostly developers who are installing this plugin.
- If the setting goes on Writing, there can still be a Settings link on the plugins page too to help people find it.
- You've mentioned user roles now a couple times and I'm not quite sure what you have in mind. Is the idea that different roles have different defaults?
- I think this might be the best option, but I'm not sure... I agree that most people installing are developers.
- Totally!
- I mentioned user roles because that's how I personally set permissions up on the site when handing off to the client with Adminimize or whatever. My idea was that yes, maybe different roles could have different defaults. Like an admin could have the fields not collapsed by default but an editor might want them collapsed by default... That said, I don't know if that's a very good idea because it could be difficult to implement and someone could just do it with a filter.
- The by-user-role idea personally strikes me as a weird in-between of usefulness that would be more of a compromise if not allowing per-user settings. But like you said, a good filter would allow someone to do this if it made sense for their particular site, so that's another point in the filter's favor.
+1 for collapsed by default.
Ideally it would be either filterable or a setting somewhere. Doing it on a per-user basis sounds kind of like overkill to me, but overrides of a global setting on a per-field basis seems reasonable.
+1 for collapsed by default. Or a global option at least to either have it either the way it is now (all expanded) — or to have it all collapsed.
+1 for collapsed by default. My main reason for using this plug is so that the users don't have to scroll too much, but if the fields aren't collapsed by default and it's not really doing the job for me.
+1 for collapsed by default.
+1 for collapsed by default. Especially when you have a lot of items in a repeater field.
+1 for collapsed by default & more contrast between the rows too.
+1 collapse by default :)
+1 for this. And could the collapsed/expanded state be saved with the page? That would be good too.
+1 for this :)
Bumping this because I could really use this functionality 👍
Is there a way to do this?