Skip to Content.
Sympa Menu

comanage-dev - [comanage-dev] r600 - in registry/trunk/app: Controller View/CoNavigationLinks

Subject: COmanage Developers List

List archive

[comanage-dev] r600 - in registry/trunk/app: Controller View/CoNavigationLinks


Chronological Thread 
  • From:
  • To:
  • Subject: [comanage-dev] r600 - in registry/trunk/app: Controller View/CoNavigationLinks
  • Date: Mon, 16 Sep 2013 18:23:04 -0400

Author: marie
Date: 2013-09-16 18:23:04 -0400 (Mon, 16 Sep 2013)
New Revision: 600

Added:
registry/trunk/app/View/CoNavigationLinks/order.ctp
Modified:
registry/trunk/app/Controller/CoEnrollmentAttributesController.php
registry/trunk/app/Controller/CoNavigationLinksController.php
registry/trunk/app/Controller/NavigationLinksController.php
registry/trunk/app/Controller/StandardController.php
registry/trunk/app/View/CoNavigationLinks/index.ctp
Log:
CO691 - add drag/drop to Co Nav Links; refactor controller components into
StandardController

Modified: registry/trunk/app/Controller/CoEnrollmentAttributesController.php
===================================================================
--- registry/trunk/app/Controller/CoEnrollmentAttributesController.php
2013-09-16 19:34:08 UTC (rev 599)
+++ registry/trunk/app/Controller/CoEnrollmentAttributesController.php
2013-09-16 22:23:04 UTC (rev 600)
@@ -227,19 +227,6 @@
}

/**
- * 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
@@ -273,20 +260,4 @@
'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/Controller/CoNavigationLinksController.php
===================================================================
--- registry/trunk/app/Controller/CoNavigationLinksController.php
2013-09-16 19:34:08 UTC (rev 599)
+++ registry/trunk/app/Controller/CoNavigationLinksController.php
2013-09-16 22:23:04 UTC (rev 600)
@@ -39,6 +39,25 @@
// This controller needs a CO to be set
public $requires_co = true;

+ /**
+ * 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,6 +102,10 @@
// Edit an existing CO Link?
$p['edit'] = ($roles['cmadmin'] || $roles['coadmin']);

+ // Reorder Links?
+ $p['reorder'] = ($roles['cmadmin'] || $roles['coadmin']);
+ $p['order'] = ($roles['cmadmin'] || $roles['coadmin']);
+
// View all existing CO Links?
$p['index'] = ($roles['cmadmin'] || $roles['coadmin']);

@@ -92,4 +115,4 @@
$this->set('permissions', $p);
return $p[$this->action];
}
-}
+}
\ No newline at end of file

Modified: registry/trunk/app/Controller/NavigationLinksController.php
===================================================================
--- registry/trunk/app/Controller/NavigationLinksController.php 2013-09-16
19:34:08 UTC (rev 599)
+++ registry/trunk/app/Controller/NavigationLinksController.php 2013-09-16
22:23:04 UTC (rev 600)
@@ -115,34 +115,4 @@
$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();
- }
-
-}
+}
\ No newline at end of file

Modified: registry/trunk/app/Controller/StandardController.php
===================================================================
--- registry/trunk/app/Controller/StandardController.php 2013-09-16
19:34:08 UTC (rev 599)
+++ registry/trunk/app/Controller/StandardController.php 2013-09-16
22:23:04 UTC (rev 600)
@@ -698,6 +698,39 @@
}

/**
+ * Modify order of items via drag/drop; 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->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() {
+ // Get a pointer to our model
+ $req = $this->modelClass;
+ $model = $this->$req;
+
+ foreach ($this->data[$req.'Id'] as $key => $value) {
+ $model->id = $value;
+ $model->saveField("ordr",$key + 1);
+ }
+
+ exit();
+ }
+
+ /**
* Determine the conditions for pagination of the index view, when
rendered via the UI.
*
* @since COmanage Registry v0.1

Modified: registry/trunk/app/View/CoNavigationLinks/index.ctp
===================================================================
--- registry/trunk/app/View/CoNavigationLinks/index.ctp 2013-09-16 19:34:08
UTC (rev 599)
+++ registry/trunk/app/View/CoNavigationLinks/index.ctp 2013-09-16 22:23:04
UTC (rev 600)
@@ -25,13 +25,38 @@
$params = array('title' => $title_for_layout);
print $this->element("pageTitle", $params);

- if($permissions['add'])
- print $this->Html->link(_txt('op.add') . ' ' .
_txt('ct.co_navigation_links.1'),
- array('controller' => 'co_navigation_links',
'action' => 'add', 'co' => $cur_co['Co']['id']),
- 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.co_navigation_links.1'),
+ 'url' => array(
+ 'controller' => 'co_navigation_links',
+ 'action' => 'add',
+ 'co' => $cur_co['Co']['id']
+ )
+ );
+ }
+
+ if($permissions['order']) {
+ // Reorder button
+ $sidebarButtons[] = array(
+ 'icon' => 'pencil',
+ 'title' => _txt('op.order.attr'),
+ 'url' => array(
+ 'controller' => 'co_navigation_links',
+ 'action' => 'order',
+ 'direction' => 'asc',
+ 'sort' => 'ordr',
+ 'co' => $cur_co['Co']['id']
+ )
+ );
+ }
+
+ $this->set('sidebarButtons', $sidebarButtons);
?>

<table id="co_navigation_links" class="ui-widget">



  • [comanage-dev] r600 - in registry/trunk/app: Controller View/CoNavigationLinks, svnlog, 09/16/2013

Archive powered by MHonArc 2.6.16.

Top of Page