Author: sevein
Date: Fri Apr  6 17:09:59 2012
New Revision: 11420

Log:
Issue 2288. Treeview, include id attribute in li tags, use it for XHR reqs

Modified:
   
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
   branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
   
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php
   branches/2.0/js/dominion.js

Modified: 
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
==============================================================================
--- 
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
  Fri Apr  6 16:02:11 2012        (r11419)
+++ 
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
  Fri Apr  6 17:09:59 2012        (r11420)
@@ -28,5 +28,21 @@
       $query = new Elastica_Query_Term(array('parentId' => 
QubitInformationObject::ROOT_ID));
       $this->resultSet = 
QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($query);
     }
+    else if ('item' == $request->show)
+    {
+      $query = new Elastica_Query_Ids('QubitInformationObject', 
array($request->id));
+      $results = 
QubitSearch::getInstance()->index->search($query)->getResults();
+      $doc = $results[0]->getData();
+      $this->ancestors = $doc['ancestors'];
+      $this->children = $doc['children'];
+
+      /*
+      $query = new Elastica_Query_Term(array('parentId' => 
$this->resource->parentId));
+      $this->siblings = 
QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($query);
+
+      $query = new Elastica_Query_Term(array('parentId' => 
$this->resource->id));
+      $this->children = 
QubitSearch::getInstance()->index->getType('QubitInformationObject')->search($query);
+      */
+    }
   }
 }

Modified: 
branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
==============================================================================
--- branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php   
Fri Apr  6 16:02:11 2012        (r11419)
+++ branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php   
Fri Apr  6 17:09:59 2012        (r11420)
@@ -17,7 +17,7 @@
       <li class="ancestor"><i></i><?php echo link_to($ancestor, 
array($ancestor, 'module' => 'informationobject')) ?></li>
     <?php endforeach; ?>
 
-    <li class="active"><i></i><?php echo link_to($resource, array($resource, 
'module' => 'informationobject')) ?></li>
+    <li class="active"><i></i><?php echo $resource ?></li>
 
     <?php if (false): ?>
     <?php foreach ($children->getResults() as $hit): ?>
@@ -29,7 +29,7 @@
       <?php unset($doc['i18n']) // continue; ?>
 
       <?php $title = $doc[$sf_user->getCulture()]['title'] ?: 
$doc[$doc['sourceCulture']]['title'] ?>
-      <?php $expand = 0 < @$doc['children'] ? ' expand' : '' ?>
+      <?php $expand = 0 < count(@$doc['children']) ? ' expand' : '' ?>
       <?php if ($hit->getId() == $resource->id): ?>
         <li class="active<?php echo $expand ?>"><?php echo $title ?></li>
       <?php else: ?>

Modified: 
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php
==============================================================================
--- 
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php 
    Fri Apr  6 16:02:11 2012        (r11419)
+++ 
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php 
    Fri Apr  6 17:09:59 2012        (r11420)
@@ -9,11 +9,15 @@
   <?php unset($doc['i18n']); // continue; ?>
 
   <?php $title = $doc[$sf_user->getCulture()]['title'] ?: 
$doc[$doc['sourceCulture']]['title'] ?>
-  <?php $expand = 0 < @$doc['children'] ? ' expand' : '' ?>
-  <?php if ($hit->getId() == $resource->id): ?>
-    <li class="active<?php echo $expand ?>"><?php echo $title ?></li>
-  <?php else: ?>
-    <li class="<?php echo $expand ?>"><?php echo link_to('<i></i>'.$title, 
array('module' => 'informationobject', 'slug' => $doc['slug'])) ?></li>
-  <?php endif; ?>
+  <?php $count = count(@$doc['children']) ?>
+  <?php $active = $hit->getId() == $resource->id ?>
+
+  <li class="<?php if (0 < $count) echo 'expand' ?> <?php if (0 < $active) 
echo 'active' ?>" data-id="<?php echo $hit->getId() ?>">
+    <?php if ($active): ?>
+      <?php echo (0 < $count ? '<i></i>' : '').$title ?>
+    <?php else: ?>
+      <?php echo link_to((0 < $count ? '<i></i>' : '').$title, array('module' 
=> 'informationobject', 'slug' => $doc['slug'])) ?>
+    <?php endif; ?>
+  </li>
 
 <?php endforeach; ?>

Modified: branches/2.0/js/dominion.js
==============================================================================
--- branches/2.0/js/dominion.js Fri Apr  6 16:02:11 2012        (r11419)
+++ branches/2.0/js/dominion.js Fri Apr  6 17:09:59 2012        (r11420)
@@ -326,7 +326,7 @@
               url: this.url,
               context: this,
               dataType: 'html',
-              data: { show: 'ancestor' },
+              data: { show: 'item', id: $element.data('id') },
               beforeSend: function ()
                 {
                   this.loading = true;
@@ -353,7 +353,7 @@
               url: this.url,
               context: this,
               dataType: 'html',
-              data: { show: 'ancestor' },
+              data: { show: 'item', id: $element.data('id') },
               beforeSend: function ()
                 {
                   this.loading = true;

-- 
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.

Reply via email to