Author: david
Date: Mon Oct  5 15:04:15 2009
New Revision: 3666

Log:
Switch place access points to Jack's cool autocomplete style.

Modified:
   trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
   trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php

Modified: 
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php 
Mon Oct  5 13:59:31 2009        (r3665)
+++ trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php 
Mon Oct  5 15:04:15 2009        (r3666)
@@ -60,6 +60,7 @@
       'script',
       'sources',
       'subjectAccessPoints',
+      'placeAccessPoints',
       'descriptionStatus',
       'publicationStatus',
       'title');
@@ -98,22 +99,32 @@
         break;
 
       case 'subjectAccessPoints':
+      case 'placeAccessPoints':
         $criteria = new Criteria;
         $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID, 
Criteria::INNER_JOIN);
-        $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::SUBJECT_ID);
         $criteria->add(QubitObjectTermRelation::OBJECT_ID, 
$this->informationObject->id);
 
+        switch($name)
+        {
+          case 'subjectAccessPoints':
+            $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::SUBJECT_ID);
+            break;
+          case 'placeAccessPoints':
+            $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PLACE_ID);
+            break;
+        }
+
         $values = array();
         $choices = array();
-        foreach (QubitObjectTermRelation::get($criteria) as 
$subjectAccessPoint)
+        foreach (QubitObjectTermRelation::get($criteria) as $otRelation)
         {
-          $values[] = $this->context->routing->generate(null, array('module' 
=> 'term', 'action' => 'show', 'id' => $subjectAccessPoint->term->id));
-          $choices[$this->context->routing->generate(null, array('module' => 
'term', 'action' => 'show', 'id' => $subjectAccessPoint->term->id))] = 
$subjectAccessPoint->term;
+          $values[] = $this->context->routing->generate(null, array('module' 
=> 'term', 'action' => 'show', 'id' => $otRelation->term->id));
+          $choices[$this->context->routing->generate(null, array('module' => 
'term', 'action' => 'show', 'id' => $otRelation->term->id))] = 
$otRelation->term;
         }
 
-        $this->form->setDefault('subjectAccessPoints', $values);
-        $this->form->setValidator('subjectAccessPoints', new sfValidatorPass);
-        $this->form->setWidget('subjectAccessPoints', new 
sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true)));
+        $this->form->setDefault($name, $values);
+        $this->form->setValidator($name, new sfValidatorPass);
+        $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' 
=> $choices, 'multiple' => true)));
 
         break;
     }
@@ -171,6 +182,7 @@
         break;
 
       case 'subjectAccessPoints':
+      case 'placeAccessPoints':
         $filtered = $selected = array();
         foreach ($this->form->getValue($name) as $value)
         {
@@ -178,7 +190,21 @@
           $filtered[$params['id']] = $selected[$params['id']] = $params['id'];
         }
 
-        foreach 
($this->informationObject->objectTermRelationsRelatedByobjectId as 
$objectTermRelation)
+        $criteria = new Criteria;
+        $criteria->addJoin(QubitObjectTermRelation::TERM_ID, QubitTerm::ID);
+        $criteria->add(QubitObjectTermRelation::OBJECT_ID, 
$this->informationObject->id);
+
+        switch ($name)
+        {
+          case 'subjectAccessPoints':
+            $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::SUBJECT_ID);
+            break;
+          case 'placeAccessPoints':
+            $criteria->add(QubitTerm::TAXONOMY_ID, QubitTaxonomy::PLACE_ID);
+            break;
+        }
+
+        foreach (QubitObjectTermRelation::get($criteria) as 
$objectTermRelation)
         {
           if (isset($selected[$objectTermRelation->term->id]))
           {

Modified: 
trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php    
Mon Oct  5 13:59:31 2009        (r3665)
+++ trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php    
Mon Oct  5 15:04:15 2009        (r3666)
@@ -210,34 +210,10 @@
       <input class="list" type="hidden" value="<?php echo 
url_for(array('module' => 'term', 'action' => 'autocomplete', 'taxonomyId' => 
QubitTaxonomy::SUBJECT_ID)) ?>"/>
     </div>
 
-    <div class="form-item" id="placeAccessPoints">
-      <table class="inline">
-        <tr>
-          <th style="width: 90%;"><?php echo __('place access points') ?></th>
-          <th style="width: 10%; text-align: right;"><?php echo 
image_tag('delete', array('align' => 'top', 'class' => 'deleteIcon')) ?></th>
-        </tr>
-      <?php if ($placeAccessPoints): ?>
-        <?php foreach ($placeAccessPoints as $place): ?>
-        <tr class="<?php echo 'related_obj_'.$place->getId() ?>">
-          <td><div class="animateNicely">
-            <?php echo $place->getTerm() ?>
-          </div></td>
-          <td style="text-align: right"><div class="animateNicely">
-            <input type="checkbox" name="delete_object_term_relations[<?php 
echo $place->getId() ?>]" value="delete" class="multiDelete" />
-          </div></td>
-        </tr>
-        <?php endforeach; ?>
-      <?php endif; ?>
-        <tr>
-          <td colspan="2">
-            <input id="placeId" type="hidden" name="placeId" />
-            <div id="placeAutoComplete" style="padding-bottom:2em; width:95%">
-              <input id="placeAcInput" type="text" name="placeTerm" />
-              <div id="placeAcList"></div>
-            </div>
-          </td>
-        </tr>
-      </table>
+    <div class="form-item">
+      <?php echo $form->placeAccessPoints->label(__('place access 
points'))->renderLabel() ?>
+      <?php echo $form->placeAccessPoints->render(array('class' => 
'form-autocomplete')) ?>
+      <input class="list" type="hidden" value="<?php echo 
url_for(array('module' => 'term', 'action' => 'autocomplete', 'taxonomyId' => 
QubitTaxonomy::PLACE_ID)) ?>"/>
     </div>
 
     <div class="form-item" id="nameAccessPoints">

--~--~---------~--~----~------------~-------~--~----~
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.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to