Author: sevein
Date: Wed Aug 8 18:05:06 2012
New Revision: 12053
Log:
Separate treeview sorting logic creating a new new action treeViewSortAction
Added:
trunk/apps/qubit/modules/informationobject/actions/treeViewSortAction.class.php
Modified:
trunk/js/treeView.js
Added:
trunk/apps/qubit/modules/informationobject/actions/treeViewSortAction.class.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++
trunk/apps/qubit/modules/informationobject/actions/treeViewSortAction.class.php
Wed Aug 8 18:05:06 2012 (r12053)
@@ -0,0 +1,70 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class InformationObjectTreeViewSortAction extends sfAction
+{
+ public function execute($request)
+ {
+ $this->resource = $this->getRoute()->resource;
+
+ // Check parameter
+ if (!in_array($request->move, array('moveAfter', 'moveBefore')))
+ {
+ $this->forward404();
+ }
+
+ // Check permissions and make sure that the user is not playing with
+ // the root object, we do not want to sort that one
+ if (QubitInformationObject::ROOT_ID == $this->resource->id
+ || !QubitAcl::check($this->resource, 'update'))
+ {
+ QubitAcl::forwardUnauthorized();
+ }
+
+ // This is the object reference that it will be used for sorting
+ // The object dragged in the treeview will be put before or after this one
+ $params =
$this->context->routing->parse(Qubit::pathInfo($request->target));
+
+ // Make sure the object exists
+ if (!isset($params['_sf_route']))
+ {
+ $this->forward404();
+ }
+ $target = $params['_sf_route']->resource;
+
+ // Go! This operation is delegated to the ORM
+ // It could take a long time if the tree is very big
+ switch ($request->move)
+ {
+ case 'moveAfter':
+ $this->resource->moveToNextSiblingOf($target);
+ echo "after";
+
+ break;
+
+ case 'moveBefore':
+ $this->resource->moveToPrevSiblingOf($target);
+ echo "before";
+
+ break;
+ }
+
+ return sfView::NONE;
+ }
+}
Modified: trunk/js/treeView.js
==============================================================================
--- trunk/js/treeView.js Wed Aug 8 09:36:06 2012 (r12052)
+++ trunk/js/treeView.js Wed Aug 8 18:05:06 2012 (r12053)
@@ -255,15 +255,15 @@
if ($prev.is('.back, .ancestor'))
{
- data = { show: 'moveBefore', target: $next.data('xhr-location') };
+ data = { move: 'moveBefore', target: $next.data('xhr-location') };
}
else
{
- data = { show: 'moveAfter', target: $prev.data('xhr-location') };
+ data = { move: 'moveAfter', target: $prev.data('xhr-location') };
}
$.ajax({
- url: ui.item.data('xhr-location'),
+ url: ui.item.data('xhr-location').replace(/treeView$/,
'treeViewSort'),
context: this,
dataType: 'html',
data: data,
--
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/qubit-commits?hl=en.