Jump to content

Limit PageTable


Robin S
 Share

Recommended Posts

LimitPageTable

A module for ProcessWire CMS/CMF. Allows limits and restrictions to be placed on selected PageTable fields.

Usage

Install the LimitPageTable module.

For the PageTable field you want to limit, on the "Input" tab include "template" or "template.label" in "Table fields to display in admin". You can skip this step if your PageTable field only allows a single template.

In the module config, fill out the fields in the fieldset row:

  • PageTable field you want to limit
  • Role that restrictions will apply to
  • Template you want to limit (only needed if your PageTable field allows more than one template)
  • Field you have included in the "Table fields to display in admin" setting (only needed if your PageTable field allows more than one template)
  • Limit
  • Option to prevent drag sorting of items (affects all rows regardless of template)
  • Option to prevent trashing of items (affects all rows regardless of template)
  • Option to disable all "Add" buttons for any template

You can add rows as needed using the "Add another row" button.

If you are using translated text for the default PageTable "Add New" button then enter the translation in "Text for default 'Add New' button".

Please note that limits and restrictions are applied with CSS/JS so should not be considered tamper-proof.

 

http://modules.processwire.com/modules/limit-page-table/
https://github.com/Toutouwai/LimitPageTable

 

Module config:

ptconfig2.png

 

Demo showing PageTable limited to 2 pages using 'Blank' template:

limitpt.gif

  • Like 13
Link to comment
Share on other sites

@Robin S I think I've found an issue with the module. 

It seems to stop image fields from working correctly. When I upload images now I get a thumb + spinner but the spinner never stops.

This is what I see in the inspector:

Uncaught SyntaxError: Unexpected token < in JSON at position 0(…)
parseJSON @ JqueryCore.js?v=1479135253:2
(anonymous function) @ InputfieldImage.min.js?v=119-1479135253:1

When I uninstall the module, image fields work as expected again.

  • Like 1
Link to comment
Share on other sites

v0.0.6 released.

  • PageTables may now be restricted by role (uses CSS/JS so not suitable for mission-critical restrictions)
  • New options to prevent trash, prevent drag sorting, and removal of all "Add" buttons regardless of template.
  • Improved config system (screenshot in first post updated)

 

  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Hi Robin

Thanks for your hard work on this.

One thing I noticed was that if you do not restrict the actions to a role, then none of the restrictions are applied at all. For example, I want to hide the trash buttons for everyone, including superusers, but by not selecting a restriction by role, none of the modifications are made for anyone, and all the buttons and functionality is in place as if you weren't using the module.

Kind regards

Nik

 

Link to comment
Share on other sites

5 hours ago, NikNak said:

One thing I noticed was that if you do not restrict the actions to a role, then none of the restrictions are applied at all.

Hi NikNak. That's correct - think of the role dropdown as a required field. Come to think of it, I will set the that config inputfield as required in a module update.

5 hours ago, NikNak said:

For example, I want to hide the trash buttons for everyone, including superusers, but by not selecting a restriction by role, none of the modifications are made for anyone, and all the buttons and functionality is in place as if you weren't using the module.

While it would be possible to restrict PageTables for superusers with this module, I deliberately excluded superusers from the role dropdown. My view is that it is part of the PW philosophy that the superuser role is not subject to any access restrictions and I want the module to be consistent with that. IMHO the only user that should have the superuser role is the site developer - you shouldn't give superuser access to a client. Better to create new role for the client with whatever access is needed.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

v0.0.9 released. You can now select multiple roles to be affected by the limit/restrictions, including the superuser role and "all roles".

@NikNak, I had a change of thinking on this issue and can now see that there are situations when it is useful for the module to affect superusers, mostly to serve as a reminder and prevent accidental changes. In any case a superuser can access the module config and so change any restrictions that are affecting them when needed.

  • Like 5
Link to comment
Share on other sites

not sure if this could be handled by the module, and haven't researched yet about this...

but i wonder about the possibility of hide and unpublish buttons on a page table, because it is something that would save my users a lot of time;

example would be we have homepage sections which are handled by a page table. there can be many sections to the page table, but sometimes a user might want to hide one and unhide another one; in the current functionality of PT afaik you need to open the item, go to the settings page and check the buttons...

TIA for reading!

  • Like 1
Link to comment
Share on other sites

41 minutes ago, Macrura said:

but i wonder about the possibility of hide and unpublish buttons on a page table, because it is something that would save my users a lot of time

Sounds like a useful thing to have. In terms of UI I imagine something like the action buttons in Page List, where publish/unpublish/hide/unhide buttons appear when hovering the title link in the table. Will investigate how this could be added.

Not sure if it's something that belongs in LimitPageTable, or should be a separate module, or perhaps added to AdminOnSteroids. Will have a think.

  • Like 3
Link to comment
Share on other sites

Here's my idea on how a repeater field could be limited. Instead of a hard lmit there could be a "separator", eg. consider a scenario of limit 3:

  1. Item above limit
  2. Item above limit
  3. Item above limit
  4. ------ separator -----
  5. Item below limit
  6. Item below limit
  7. Item below limit
  8. ...

As you can see there is no real limit but only a visual separator. Moving item 6 to the top would push all other items one place down, but still only the first 3 would be above the limit. The advantage would be that you shouldn't need to delete an item and can reuse them later.

Anyway, I'm fine with the current solution, just wanted to share :) 

  • Like 2
Link to comment
Share on other sites

57 minutes ago, Robin S said:

Sounds like a useful thing to have. In terms of UI I imagine something like the action buttons in Page List, where publish/unpublish/hide/unhide buttons appear when hovering the title link in the table. Will investigate how this could be added.

Not sure if it's something that belongs in LimitPageTable, or should be a separate module, or perhaps added to AdminOnSteroids. Will have a think.

cool, thanks!

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...