comanage-dev - [comanage-dev] r599 - in registry/trunk/app: Controller Model View/CoEnrollmentAttributes View/NavigationLinks webroot/css
Subject: COmanage Developers List
List archive
[comanage-dev] r599 - in registry/trunk/app: Controller Model View/CoEnrollmentAttributes View/NavigationLinks webroot/css
Chronological Thread
- From:
- To:
- Subject: [comanage-dev] r599 - in registry/trunk/app: Controller Model View/CoEnrollmentAttributes View/NavigationLinks webroot/css
- Date: Mon, 16 Sep 2013 15:34:08 -0400
Author: marie
Date: 2013-09-16 15:34:08 -0400 (Mon, 16 Sep 2013)
New Revision: 599
Added:
registry/trunk/app/View/NavigationLinks/order.ctp
Modified:
registry/trunk/app/Controller/NavigationLinksController.php
registry/trunk/app/Model/NavigationLink.php
registry/trunk/app/View/CoEnrollmentAttributes/order.ctp
registry/trunk/app/View/NavigationLinks/index.ctp
registry/trunk/app/webroot/css/comanage.css
Log:
co691 drag/drop ordering of navigation links
Modified: registry/trunk/app/Controller/NavigationLinksController.php
===================================================================
--- registry/trunk/app/Controller/NavigationLinksController.php 2013-09-16
03:54:58 UTC (rev 598)
+++ registry/trunk/app/Controller/NavigationLinksController.php 2013-09-16
19:34:08 UTC (rev 599)
@@ -27,7 +27,10 @@
class NavigationLinksController extends StandardController {
// Class name, used by Cake
public $name = "NavigationLinks";
-
+
+ // 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,
@@ -37,6 +40,25 @@
);
/**
+ * Callback before other controller methods are invoked or views are
rendered.
+ * - postcondition: Auth component is configured
+ *
+ * @since COmanage Registry v0.8.2
+ */
+
+ function beforeFilter() {
+
+ parent::beforeFilter();
+
+ // Sub optimally, we need to unlock reorder so that the AJAX calls could
get through
+ // for drag/drop reordering.
+ // 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('reorder');
+ }
+
+ /**
* Get location options for view.
* - postcondition: vv_link_location_options set
*
@@ -83,10 +105,44 @@
// View all existing Links?
$p['index'] = ($roles['cmadmin'] );
+ // Reorder Links?
+ $p['reorder'] = ($roles['cmadmin'] );
+ $p['order'] = ($roles['cmadmin'] );
+
// View an existing Link?
$p['view'] = ($roles['cmadmin'] );
$this->set('permissions', $p);
return $p[$this->action];
}
+
+ /**
+ * 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;
+ $this->log("order", 'debug');
+
+ parent::index();
+ }
+
+ /**
+ * 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['NavigationLinkId'] as $key => $value) {
+ $this->NavigationLink->id = $value;
+ $this->NavigationLink->saveField("ordr",$key + 1);
+ }
+ exit();
+ }
+
}
Modified: registry/trunk/app/Model/NavigationLink.php
===================================================================
--- registry/trunk/app/Model/NavigationLink.php 2013-09-16 03:54:58 UTC (rev
598)
+++ registry/trunk/app/Model/NavigationLink.php 2013-09-16 19:34:08 UTC (rev
599)
@@ -52,7 +52,8 @@
'url' => array(
'rule' => 'url',
'required' => false,
- 'allowEmpty' => true
+ 'allowEmpty' => true,
+ 'message' => 'A valid URL must be given.'
),
'ordr' => array(
Modified: registry/trunk/app/View/CoEnrollmentAttributes/order.ctp
===================================================================
--- registry/trunk/app/View/CoEnrollmentAttributes/order.ctp 2013-09-16
03:54:58 UTC (rev 598)
+++ registry/trunk/app/View/CoEnrollmentAttributes/order.ctp 2013-09-16
19:34:08 UTC (rev 599)
@@ -23,16 +23,6 @@
*/
-->
-<style>
- .order .ui-icon{
- float: left;
- }
-
- .order {
- padding-left: 18px;
- }
-</style>
-
<?php
// Set page title
$params = array('title' => $title_for_layout);
@@ -75,7 +65,7 @@
<tbody id="sortable">
<?php foreach ($co_enrollment_attributes as $c): ?>
<tr id = "CoEnrollmentAttributeId_<?php print
$c['CoEnrollmentAttribute']['id']?>" class="line1">
- <td class = "order">
+ <td class = "order">
<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
</td>
<td>
Modified: registry/trunk/app/View/NavigationLinks/index.ctp
===================================================================
--- registry/trunk/app/View/NavigationLinks/index.ctp 2013-09-16 03:54:58
UTC (rev 598)
+++ registry/trunk/app/View/NavigationLinks/index.ctp 2013-09-16 19:34:08
UTC (rev 599)
@@ -25,13 +25,36 @@
$params = array('title' => $title_for_layout);
print $this->element("pageTitle", $params);
- if($permissions['add'])
- print $this->Html->link(_txt('op.add') . ' ' .
_txt('ct.navigation_links.1'),
- array('controller' => 'navigation_links',
'action' => 'add'),
- array('class' => 'addbutton')) . '
- <br />
- <br />
- ';
+ // Add buttons to sidebar
+ $sidebarButtons = $this->get('sidebarButtons');
+
+ // Add button
+ if($permissions['add']) {
+ $sidebarButtons[] = array(
+ 'icon' => 'circle-plus',
+ 'title' => _txt('op.add') . ' ' . _txt('ct.navigation_links.1'),
+ 'url' => array(
+ 'controller' => 'navigation_links',
+ 'action' => 'add'
+ )
+ );
+ }
+
+ if($permissions['order']) {
+ // Reorder button
+ $sidebarButtons[] = array(
+ 'icon' => 'pencil',
+ 'title' => _txt('op.order.attr'),
+ 'url' => array(
+ 'controller' => 'navigation_links',
+ 'action' => 'order',
+ 'direction' => 'asc',
+ 'sort' => 'ordr'
+ )
+ );
+ }
+
+ $this->set('sidebarButtons', $sidebarButtons);
?>
<table id="navigation_links" class="ui-widget">
Modified: registry/trunk/app/webroot/css/comanage.css
===================================================================
--- registry/trunk/app/webroot/css/comanage.css 2013-09-16 03:54:58 UTC (rev
598)
+++ registry/trunk/app/webroot/css/comanage.css 2013-09-16 19:34:08 UTC (rev
599)
@@ -257,6 +257,15 @@
float:right;
}
+ /* Drag/drop ordering */
+ .order .ui-icon{
+ float: left;
+ }
+
+ .order {
+ padding-left: 18px;
+ }
+
/* Sidebar (right) */
#sidebar {
float: left;
- [comanage-dev] r599 - in registry/trunk/app: Controller Model View/CoEnrollmentAttributes View/NavigationLinks webroot/css, svnlog, 09/16/2013
Archive powered by MHonArc 2.6.16.