From 82bb0524b37abc6856cdf471a3ee712d6e269113 Mon Sep 17 00:00:00 2001 From: Andrew Short Date: Tue, 8 Oct 2013 09:30:59 +1100 Subject: [PATCH] Avoid manually constructing URLs. This means that URLs with query parameters are no longer incorrectly created. Closes #6, #23, #27. --- code/GridFieldOrderableRows.php | 6 ++++++ javascript/GridFieldExtensions.js | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/code/GridFieldOrderableRows.php b/code/GridFieldOrderableRows.php index b0c2b04..7fa3232 100755 --- a/code/GridFieldOrderableRows.php +++ b/code/GridFieldOrderableRows.php @@ -86,9 +86,15 @@ class GridFieldOrderableRows extends RequestHandler implements ); } + /** + * @param GridField $field + */ public function getHTMLFragments($field) { GridFieldExtensions::include_requirements(); + $field->addExtraClass('ss-gridfield-orderable'); + $field->setAttribute('data-url-reorder', $field->Link('reorder')); + $field->setAttribute('data-url-movetopage', $field->Link('movetopage')); } public function augmentColumns($grid, &$cols) { diff --git a/javascript/GridFieldExtensions.js b/javascript/GridFieldExtensions.js index 6afe043..9e92ede 100644 --- a/javascript/GridFieldExtensions.js +++ b/javascript/GridFieldExtensions.js @@ -192,7 +192,7 @@ }); grid.reload({ - url: grid.data("url") + "/reorder", + url: grid.data("url-reorder"), data: data.get() }); }; @@ -228,7 +228,7 @@ grid.find("tbody").sortable("cancel"); grid.reload({ - url: grid.data("url") + "/movetopage", + url: grid.data("url-movetopage"), data: [ { name: "move[id]", value: ui.draggable.data("id") }, { name: "move[page]", value: page }