Jump to content

Custom dashboard sorting MarkupAdminDataTable pages


Raymond Geerts
 Share

Recommended Posts

I'm building a dashboard, based on the dashboard from Kongondo's Blog.

In there i have Articles and Widgets. Articles are sorted by some date, but for the widgets i want to be able to use manual drag-n-drop sorting.

Widgets are all child pages from a certain parent page.

Is this possible and how would i be able to approach this?

Would it be possible to build manual sorting into MarkupAdminDataTable or should i use PageTable instead?

post-694-0-89064700-1421655359_thumb.png

update: Im looking in to ProcessPageSort to see if i can use that. Seems it needs an AJAX call.

update: Changed title of post

Edited by Raymond Geerts
Link to comment
Share on other sites

What I would try (Never done this before)

- Use jquerui sortable.

- start drag (or something), get de index of the item in the list of pages 

- stop drag (or something), get the new index of the dropped item.

- then from your list get the Page id's from start drag index till stop drag index and make from all id's a comma separated string.  (1234,3241,6473,1001,1234)

Then you need to do a post with Javascript to /processwire/page/sort/, use the following variables:

sort (comma separated list of ID's) 

parent_id
move_id (dragged page)
Edited by Martijn Geerts
copy pasted the wrong URL updated the post
  • Like 1
Link to comment
Share on other sites

Ok it seems i have set up everything now.

The table (specificly all children of tbody) are sortable now with

$('.blocksTable > tbody').sortable()

In sortable() i have set some options like axis:"y" and beforeStop

on beforeStop i gather the needed ids to pass as data, for example:

'TOKEN788378384X1421678958':'fXGyHPxU2xSBIFpuDI08ORL1Z1CTC0U5',
'id':1015,
'parent_id':1017,
'sort':'1015,1013,1014'

Where the TOKEN is grabbed from the hidden input field with class _post_token, 'id' is the id from the page that was 'moved', 'parent_id' is the id of the parent page, 'sort' are the ids of the pages in the new order.

These are posted with ajax to /processwire/page/sort/

The problem is i get the following message return, indicating the page is not saved because there are no changes.

{"error":true,"message":"You do not have permission to sort pages using this parent - \/partners\/partnername\/blocks\/"}

The strange thing is the current user has move and sort permissions, so i'm not sure what i'm missing here. Does anybody have a clue?

Edited by Raymond Geerts
Link to comment
Share on other sites

  • 1 year later...

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

×
×
  • Create New...