Author: sevein
Date: Fri Apr 6 23:33:29 2012
New Revision: 11421
Log:
Issue 2288. Treeview: rendering ancestors and children...
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 17:09:59 2012 (r11420)
+++
branches/2.0/apps/qubit/modules/informationobject/actions/treeViewAction.class.php
Fri Apr 6 23:33:29 2012 (r11421)
@@ -31,18 +31,10 @@
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'];
+ $this->current = QubitSearch::getInstance()->index->search($query);
- /*
- $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));
+ $query = new Elastica_Query_Term(array('parentId' => $request->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 17:09:59 2012 (r11420)
+++ branches/2.0/apps/qubit/modules/informationobject/templates/_treeView.php
Fri Apr 6 23:33:29 2012 (r11421)
@@ -14,12 +14,11 @@
<?php foreach($doc['ancestors'] as $id): ?>
<?php if ($id == QubitInformationObject::ROOT_ID) continue; ?>
<?php $ancestor = QubitInformationObject::getById($id) ?>
- <li class="ancestor"><i></i><?php echo link_to($ancestor,
array($ancestor, 'module' => 'informationobject')) ?></li>
+ <li class="ancestor" data-id="<?php echo $id ?>"><i></i><?php echo
link_to($ancestor, array($ancestor, 'module' => 'informationobject')) ?></li>
<?php endforeach; ?>
<li class="active"><i></i><?php echo $resource ?></li>
- <?php if (false): ?>
<?php foreach ($children->getResults() as $hit): ?>
<?php $doc = $hit->getData() ?>
@@ -37,7 +36,6 @@
<?php endif; ?>
<?php endforeach; ?>
- <?php endif; ?>
</ul>
Modified:
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php
==============================================================================
---
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php
Fri Apr 6 17:09:59 2012 (r11420)
+++
branches/2.0/apps/qubit/modules/informationobject/templates/treeViewSuccess.php
Fri Apr 6 23:33:29 2012 (r11421)
@@ -1,8 +1,38 @@
-<?php $items = $resultSet->getResults() ?>
+<?php if ('all' == $sf_request->show): ?>
-<?php foreach ($items as $hit): ?>
+ <?php foreach ($resultSet->getResults() as $hit): ?>
+
+ <?php $doc = $hit->getData() ?>
+ <?php foreach ($doc['i18n'] as $i18n): ?>
+ <?php $doc[$i18n['culture']] = $i18n ?>
+ <?php endforeach; ?>
+ <?php unset($doc['i18n']); // continue; ?>
+
+ <?php $title = $doc[$sf_user->getCulture()]['title'] ?:
$doc[$doc['sourceCulture']]['title'] ?>
+ <?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; ?>
+
+<?php elseif ('item' == $sf_request->show): ?>
+
+ <?php $resultSet = $current->getResults() ?>
+ <?php $doc = $resultSet[0]->getData() ?>
+
+ <?php foreach ($doc['ancestors'] as $id): ?>
+ <?php if (QubitInformationObject::ROOT_ID == $id) continue; ?>
+ <?php $item = QubitInformationObject::getById($id) ?>
+ <li class="ancestor" data-id="<?php echo $id ?>"><?php echo
link_to('<i></i>'.$item, array($item, 'module' => 'informationobject')) ?></li>
+ <?php endforeach; ?>
- <?php $doc = $hit->getData() ?>
<?php foreach ($doc['i18n'] as $i18n): ?>
<?php $doc[$i18n['culture']] = $i18n ?>
<?php endforeach; ?>
@@ -10,14 +40,38 @@
<?php $title = $doc[$sf_user->getCulture()]['title'] ?:
$doc[$doc['sourceCulture']]['title'] ?>
<?php $count = count(@$doc['children']) ?>
- <?php $active = $hit->getId() == $resource->id ?>
+ <?php $active = $resultSet[0]->getId() == $resource->id ?>
- <li class="<?php if (0 < $count) echo 'expand' ?> <?php if (0 < $active)
echo 'active' ?>" data-id="<?php echo $hit->getId() ?>">
+ <li class="ancestor <?php if (0 < $active) echo 'active' ?>" data-id="<?php
echo $resultSet[0]->getId() ?>">
<?php if ($active): ?>
- <?php echo (0 < $count ? '<i></i>' : '').$title ?>
+ <?php echo '<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; ?>
+ <?php foreach ($children->getResults() as $hit): ?>
+
+ <?php if ($hit->getId() == $resource->id) continue; ?>
+
+ <?php $doc = $hit->getData() ?>
+ <?php foreach ($doc['i18n'] as $i18n): ?>
+ <?php $doc[$i18n['culture']] = $i18n ?>
+ <?php endforeach; ?>
+ <?php unset($doc['i18n']); // continue; ?>
+
+ <?php $title = $doc[$sf_user->getCulture()]['title'] ?:
$doc[$doc['sourceCulture']]['title'] ?>
+ <?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; ?>
+
+<?php endif; ?>
Modified: branches/2.0/js/dominion.js
==============================================================================
--- branches/2.0/js/dominion.js Fri Apr 6 17:09:59 2012 (r11420)
+++ branches/2.0/js/dominion.js Fri Apr 6 23:33:29 2012 (r11421)
@@ -280,7 +280,7 @@
if ($li.hasClass('ancestor'))
{
- return this.showAncestor($li);
+ return this.showItem($li);
}
else if ($li.hasClass('expand'))
{
@@ -320,33 +320,6 @@
return this;
},
- showAncestor: function($element)
- {
- $.ajax({
- url: this.url,
- context: this,
- dataType: 'html',
- data: { show: 'item', id: $element.data('id') },
- beforeSend: function ()
- {
- this.loading = true;
- },
- success: function (data)
- {
- this.$showAllButton.show();
- },
- complete: function ()
- {
- this.loading = false;
- },
- error: function ()
- {
- }
- });
-
- return this;
- },
-
showItem: function($element)
{
$.ajax({
@@ -360,7 +333,10 @@
},
success: function (data)
{
- this.$showAllButton.show();
+ this.$showAllButton
+ .show()
+ .nextAll().remove().end()
+ .after(data);
},
complete: function ()
{
--
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.