Jump to content

ProcessBatcher


Wanze

Recommended Posts

Thanks for your feedback raydale.

I think providing a link to edit the pages makes sense. I'll add this plus some permission checking in the next version.

But I also think that the current system to search the pages with a selector is mainly for superusers. For non-superusers, another search-system would be better. I was thinking of adding the option to create some pre-defined searches as links, which store the selectors behind the scenes. For example:

  • Display posts
  • Display architects

This could be done in the module config options with something like this:

Display posts||template=post, include=all, sort=-created
Display architects||template=architect
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Good morning/evening/night or whatever!

I just commited to Version 1.0.2. Here are the new Features:

  • Permission Checking: Don't show pages that aren't editable by the current user. Also removed all actions that the user doesn't have permissions to execute.
  • You can directly edit a single page over Fancybox by clicking the small "edit" link after a page (thanks raydale)
  • Added Batch-Creating of Pages

Batch-Creating

post-582-0-85307700-1362101361_thumb.png

Screenshot taken with Soma's great new Teflon theme

Includes permission checking and Family template restrictions. This means in detail:

  • The selected parent must accept children and their template
  • The pages template must accept the parents template
  • User needs the permission to add children to the selected parents template
  • User needs the permission to create Pages for the chosen Template

How does it work?

1) Select a parent where your new pages will be added as children

2) Add as many pages as you want by clicking "add Page"

3) Click "Create Pages"

You must enter a title and choose a template. The name is optional: If left empty, Pw will generate this for you.

Batch-creating tips

The chosen template and the statuses are always cloned from the last row. So if you need to add 30 pages

with the same template, define it first and the click "add Page" - i'll make your life easier ;-)

You can drag & drop the table rows should you want to change the order. The draging looks ugly but it works.

For the lazy dogs and keybord hackers among us, you can add a new row by pressing "ctrl+n".

This works (at least in firefox) only if no input has focus. After adding a new row, the title input gets the focus.

By pressing 3 times tab you arrive at the published-checkbox, here the short-cut works.

Restrict Batcher for a user to only allow editing or creating

Create permissions "batcher-edit" and/or "batcher-add". As soon those exists, the module checks if the current

user has those permissions.

Good night

  • Like 6
Link to comment
Share on other sites

Thanks Wanze, just what I needed.

The Actions tab was collapsed after installation and didn't expand when clicked.

ProcessBatcher.module line190   $actions->collapsed = 0;  changed to $actions->collapsed = 1;

Also, selecting change parent returns a text box rather than a selector, which works if you enter the parent id.

Edited by NooseLadder
Link to comment
Share on other sites

Hi Noose,

Glad the module could help you out!

Yeah, I actually set it collapsed because I want the users to first select the right

pages before choosing any action and hitting the Execute button.

If you could not open it, then I guess this is some sort of a javascript error. Also the change parent

works fine for me, it should render an "PageListSelect" instead of the textbox.

Could you tell me:

  • Version of ProcessWire
  • Operating system
  • Browser

I only tested with the newest dev version and Firefox/Chrome on Mac, so maybe you found a bug.

Ah and maybe have a look in your js-console to see if any errors appear.

Thanks!

Link to comment
Share on other sites

Hi Wanze, I have just been using Batcher with the latest dev version of PW and all is great - thanks! It's such a useful tool for site admins and I have already put it to a lot of use. The 'edit' link being a particularly strong workflow enhancement.

Another few suggestions (these are only suggestions as the workflow is already good) for a future release at some point would be:

  • Include a couple of 'quick filter' buttons such as 'Show site tree', 'Show non-admin' and 'Show all published'. These buttons would perform a search as soon as they are clicked. This would be a great feature for less technical site editors / admins who's main purpose for using Batcher would be for SEO (checking page titles and urls etc.) or for initial setup, saving them from having to perform selector queries.
  • Extra filters such as 'Locked', 'Published' and 'Trashed'.
  • Show parent child relationships via indented rows (could be difficult so maybe simple indented 'Title' fields would work)

Thanks again for a great plugin and a real workflow enhancer.

  • Like 1
Link to comment
Share on other sites

Hey Wanze, I somehow forgot about the "let's discuss..." :/ 

It would have been no issue if you wanted to take my WIP, it's up to you, no matter if not. PM me if you want to discuss about it. Or sometime on IRC?

However, I tried your module already a couple time now and have some little feedback.

- It would be nice to have the edit link more visible. In my theme (heh) it's hard to see. Maybe also just make the title edit link.

- After editing a set of pages it wouldn't it be nice to have the modified pages still there visible? Like saving the selector.

Keep up the good work!

Link to comment
Share on other sites

  • Include a couple of 'quick filter' buttons such as 'Show site tree', 'Show non-admin' and 'Show all published'. These buttons would perform a search as soon as they are clicked. This would be a great feature for less technical site editors / admins who's main purpose for using Batcher would be for SEO (checking page titles and urls etc.) or for initial setup, saving them from having to perform selector queries.
  • Extra filters such as 'Locked', 'Published' and 'Trashed'.
  • Show parent child relationships via indented rows (could be difficult so maybe simple indented 'Title' fields would work)

Thanks for your feedback!

  • Yeah at the moment the module still is a tool for Superusers or users with at least some technical knowledge how the Selectors work. In a next version, I will try to set up some sort of predefined search queries where you can define a title, selector and (optionally) a user-role. Instead of writing a query with the selector, a list of links is displayed that execute the search behind the scene.
  • Extra filters: I think it's not possible to filter pages by locked or published with a selector. There exists only "include=all" which includes hidden, locked and unpublished pages. And then also "include=hidden", which includes only the hidden pages.
  • Not sure about your third point, the pages you get can be sorted in any possible way. To see parent-child relationships it's better to look at the page tree.

Hey Wanze, I somehow forgot about the "let's discuss..." :/ 

It would have been no issue if you wanted to take my WIP, it's up to you, no matter if not. PM me if you want to discuss about it. Or sometime on IRC?

However, I tried your module already a couple time now and have some little feedback.

- It would be nice to have the edit link more visible. In my theme (heh) it's hard to see. Maybe also just make the title edit link.

- After editing a set of pages it wouldn't it be nice to have the modified pages still there visible? Like saving the selector.

Keep up the good work!

Sorry I forgot too.

Actually I didn't look at your code because I wanted to learn how everything works by myself.

But the UI is inspired by your module of course :)

Will stop by in the IRC sooner or later!

Thanks for the feedback.

  • First I had the titles as links, but it didn't look nice. At least not with the default-theme and most others. It's also not the purpose of the module to edit each page separate, so I thought the link shoud not be "too" big.
  • True. I do a redirect with $session to prevent "double executing" of stuff. Maybe that's not really necessary, I'll figure out a solution for the next release.
Link to comment
Share on other sites

Wanze, just a crazy idea. How about building a "visual query builder" as a separate module? That would be the tool that non superuser could use to create pages->find queries. Then people could build on top of that some additional modules on what to do with selected pages.

Not sure if I understand myself what I just wrote, but it does sound cool :)

  • Like 1
Link to comment
Share on other sites

Wanze, just a crazy idea. How about building a "visual query builder" as a separate module? That would be the tool that non superuser could use to create pages->find queries. Then people could build on top of that some additional modules on what to do with selected pages.

Not sure if I understand myself what I just wrote, but it does sound cool :)

It sure does sound cool. If i understand you correctly maybe the whole 'visual' part (clicking together a query with checkboxes, sliders etc.?) could be added on top of a module like this: http://processwire.com/talk/topic/1859-module-testrun-selectors-find-from-admin-processselectortest/

Link to comment
Share on other sites

Hi Wanze,

Love the work here, I can definitely see this saving some time in my routine.

Running into one issue though, not sure if it's a bug or something on my end.

After using a selector, I select a list of pages I want to batch edit, in this case I want to Publish, click Execute and I'm greeted with this lovely item:

Method Page::of does not exist or is not callable in this context

Any ideas of what could be happening here?

Mac OS X 10.8.2

Chrome 25.0.1364.160

ProcessWire v2.2.0

Thanks in advance,

Andy

Link to comment
Share on other sites

Hi andyrak,

Thanks!

Looks like the Page::of() method (shortcut for setting outputformatting) does not exist in Pw 2.2.0.

Can you update your ProcessWire installation to the current stable or dev version?

I think this should fix it for you.

Link to comment
Share on other sites

Hi Wanze,

Didn't think to check JS errors.

There is indeed an error.

TypeError: 'undefined' is not a function (evaluating '$(document).on')

ProcessBatcher.js: 97
 

Maybe a conflict with another module's JS?

Link to comment
Share on other sites

Reno,

Seems like your Pw installation uses an "old" jQuery version < 1.7 which does not yet support $(document).on().

Can you update Pw to latest dev?

I don't want to use $('selector').live('') because it's deprecated since 1.7

If you cannot update Pw, change line 93 of /site/modules/ProcessBatcher/ProcessBatcher.js:

//Change this line
$(document).on('click', '.remove_page', function(){
//to
$('.remove_page').live('click', function(){

Then it should work.

Link to comment
Share on other sites

I don't want to use $('selector').live('') because it's deprecated since 1.7

If you cannot update Pw, change line 93 of /site/modules/ProcessBatcher/ProcessBatcher.js:

//Change this line
$(document).on('click', '.remove_page', function(){
//to
$('.remove_page').live('click', function(){

Since this seems to be only place where you're using .on(), you could also check for it's existence first and provide a fallback in order to support both versions:

var remove_tr = function() { ... }
if ($.isFunction($(this).on)) {
    $(document).on('click', '.remove_page', remove_tr);
} else {
    $('.remove_page').live('click', remove_tr);
} 

Not properly tested, just posting it here as a rough idea.. :)

Another thing you could do (though it'd still make sense to use .on() if it's available) is replacing .live() with .delegate(), which was added in 1.4.2 and even though it's been effectively deprecated by .on() it still exists in new jQuery versions:

$(document).delegate('.remove_page', 'click', function() { ...});
  • Like 2
Link to comment
Share on other sites

@teppo

WoW thanks for your code, it worked perfectly! Didn't know about the .isFunction.

Commited version 1.0.3 to GitHub.

  • The user needs permission 'batcher' to see the page in admin. If you update, please create the permission manually and add it to the user role. (Thanks Soma for the hint!)
  • Fix javascript to support jQuery .live function for older Pw installations
  • Like 4
Link to comment
Share on other sites

  • 1 month later...

Hi Wanze, great module.

Wouldn't it be great if in the creation tab, the input fields would reflect the chosen template? That way one could batch create page content with all the custom fields too.

This however could get messy when it comes to Repeaters or FieldSetTabs.

Perhaps one should be able to chose fields in a comma separated manner?

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
×
×
  • Create New...