Jump to content
Robin S

Limit PageTable

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

Share this post


Link to post
Share on other sites

Wonderful, thank you @Robin S - installed on 3.0.39 and all seems to be working perfectly.

This kind of extra control over PageTable fields is something I find more need of the more I use this type of field.

 

 

  • Like 3

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
12 hours ago, alexcapes said:

It seems to stop image fields from working correctly.

Thanks for the bug report. If you grab the latest version from GitHub the issue should be fixed.

  • Like 2

Share this post


Link to post
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 1

Share this post


Link to post
Share on other sites

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

 

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Thanks Robin.

Understood about superuser, and agreed - never let a client have superuser access. 

Kind regards

Nik

  • Like 1

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
On 5/02/2017 at 10:31 AM, 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

@Macrura, I have released a new module PageTable Extra Actions that provides this feature.

  • Like 2

Share this post


Link to post
Share on other sites

Have to find a project where I can use PageTables :)

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...