comanage-dev - [comanage-dev] r587 - in registry/trunk/app: Controller View/CoEnrollmentAttributes
Subject: COmanage Developers List
List archive
[comanage-dev] r587 - in registry/trunk/app: Controller View/CoEnrollmentAttributes
Chronological Thread
- From:
- To:
- Subject: [comanage-dev] r587 - in registry/trunk/app: Controller View/CoEnrollmentAttributes
- Date: Wed, 11 Sep 2013 15:04:34 -0400
Author: marie
Date: 2013-09-11 15:04:34 -0400 (Wed, 11 Sep 2013)
New Revision: 587
Added:
registry/trunk/app/View/CoEnrollmentAttributes/order.ctp
Modified:
registry/trunk/app/Controller/CoEnrollmentAttributesController.php
registry/trunk/app/View/CoEnrollmentAttributes/index.ctp
Log:
co470 - add drag/drop ordering for extended attributes
Modified: registry/trunk/app/Controller/CoEnrollmentAttributesController.php
===================================================================
--- registry/trunk/app/Controller/CoEnrollmentAttributesController.php
2013-09-07 03:52:56 UTC (rev 586)
+++ registry/trunk/app/Controller/CoEnrollmentAttributesController.php
2013-09-11 19:04:34 UTC (rev 587)
@@ -28,6 +28,9 @@
// Class name, used by Cake
public $name = "CoEnrollmentAttributes";
+ // Use the javascript helper for the Views (for drag/drop in particular)
+ public $helpers = array('Js');
+
// Establish pagination parameters for HTML views
public $paginate = array(
'limit' => 25,
@@ -84,7 +87,8 @@
// magic works. XXX It would be good to be more specific, and just call
unlockField()
// on specific fields, but some initial testing does not make it obvious
which
// fields need to be unlocked.
- $this->Security->unlockedActions = array('add', 'edit');
+ // Reorder was also unlocked so that the AJAX calls could get through
for drag/drop reordering.
+ $this->Security->unlockedActions = array('add', 'edit', 'reorder');
// Strictly speaking, this controller doesn't require a CO except to
redirect/render views.
// Figure out the CO ID associated with the current enrollment flow.
We'll specifically
@@ -205,10 +209,16 @@
// Edit an existing CO Enrollment Attribute?
$p['edit'] = ($roles['cmadmin'] || $roles['coadmin']);
+
+ // Edit an existing CO Enrollment Attribute's order?
+ $p['order'] = ($roles['cmadmin'] || $roles['coadmin']);
// View all existing CO Enrollment Attributes?
$p['index'] = ($roles['cmadmin'] || $roles['coadmin']);
+ // Modify ordering for display via AJAX
+ $p['reorder'] = ($roles['cmadmin'] || $roles['coadmin']);
+
// View an existing CO Enrollment Attributes?
$p['view'] = ($roles['cmadmin'] || $roles['coadmin']);
@@ -217,6 +227,19 @@
}
/**
+ * Modify order of Enrollment Attributes; essentially like the index page
plus an AJAX call
+ *
+ * @since COmanage Registry v0.8.2
+ */
+
+ function order() {
+ // Show more for ordering
+ $this->paginate['limit'] = 200;
+
+ parent::index();
+ }
+
+ /**
* Determine the conditions for pagination of the index view, when
rendered via the UI.
*
* @since COmanage Registry v0.3
@@ -250,4 +273,20 @@
'action' => 'index',
'coef' => $coefid));
}
+
+ /**
+ * Save changes to the ordering made via drag/drop; called via AJAX.
+ * - postcondition: Database modified
+ *
+ * @since COmanage Registry v0.8.2
+ */
+
+ public function reorder() {
+ foreach ($this->data['CoEnrollmentAttributeId'] as $key => $value) {
+ $this->CoEnrollmentAttribute->id = $value;
+ $this->CoEnrollmentAttribute->saveField("ordr",$key + 1);
+ }
+
+ exit();
+ }
}
Modified: registry/trunk/app/View/CoEnrollmentAttributes/index.ctp
===================================================================
--- registry/trunk/app/View/CoEnrollmentAttributes/index.ctp 2013-09-07
03:52:56 UTC (rev 586)
+++ registry/trunk/app/View/CoEnrollmentAttributes/index.ctp 2013-09-11
19:04:34 UTC (rev 587)
@@ -29,18 +29,6 @@
// Add buttons to sidebar
$sidebarButtons = $this->get('sidebarButtons');
-
- // Cancel button
- $sidebarButtons[] = array(
- 'icon' => 'circle-close',
- 'title' => _txt('op.back'),
- 'url' => array(
- 'controller' => 'co_enrollment_flows',
- 'action' => ($permissions['edit'] ? 'edit' : 'view'),
- $vv_coefid,
- 'co' => $vv_coid
- )
- );
// Add button
if($permissions['add']) {
@@ -54,7 +42,22 @@
)
);
}
-
+
+ if($permissions['order']) {
+ // Reorder button
+ $sidebarButtons[] = array(
+ 'icon' => 'pencil',
+ 'title' => _txt('op.order.attr'),
+ 'url' => array(
+ 'controller' => 'co_enrollment_attributes',
+ 'action' => 'order',
+ 'coef' => $vv_coefid,
+ 'direction' => 'asc',
+ 'sort' => 'ordr'
+ )
+ );
+ }
+
$this->set('sidebarButtons', $sidebarButtons);
?>
- [comanage-dev] r587 - in registry/trunk/app: Controller View/CoEnrollmentAttributes, svnlog, 09/11/2013
Archive powered by MHonArc 2.6.16.