Author: david
Date: Fri Oct  9 13:36:43 2009
New Revision: 3708

Log:
Switch name access points to new multi-select autocomplete.

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

Modified: 
trunk/apps/qubit/modules/informationobject/actions/editAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editAction.class.php     
Fri Oct  9 12:18:44 2009        (r3707)
+++ trunk/apps/qubit/modules/informationobject/actions/editAction.class.php     
Fri Oct  9 13:36:43 2009        (r3708)
@@ -218,6 +218,24 @@
         $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' 
=> $choices, 'multiple' => true)));
 
         break;
+      case 'nameAccessPoints':
+        $criteria = new Criteria;
+        $criteria->add(QubitRelation::SUBJECT_ID, 
$this->informationObject->id);
+        $criteria->add(QubitRelation::TYPE_ID, 
QubitTerm::NAME_ACCESS_POINT_ID);
+
+        $values = array();
+        $choices = array();
+        foreach (QubitRelation::get($criteria) as $relation)
+        {
+          $values[] = $this->context->routing->generate(null, array('module' 
=> 'actor', 'action' => 'show', 'id' => $relation->objectId));
+          $choices[$this->context->routing->generate(null, array('module' => 
'actor', 'action' => 'show', 'id' => $relation->objectId))] = 
$relation->getObject();
+        }
+
+        $this->form->setDefault($name, $values);
+        $this->form->setValidator($name, new sfValidatorPass);
+        $this->form->setWidget($name, new sfWidgetFormSelect(array('choices' 
=> $choices, 'multiple' => true)));
+
+        break;
     }
   }
 
@@ -280,6 +298,41 @@
 
         break;
 
+      case 'nameAccessPoints':
+        $filtered = $selected = array();
+        foreach ($this->form->getValue($name) as $value)
+        {
+          $params = 
$this->context->routing->parse(preg_replace('/.*'.preg_quote($this->request->getPathInfoPrefix(),
 '/').'/', null, $value));
+          $filtered[$params['id']] = $selected[$params['id']] = $params['id'];
+        }
+
+        $criteria = new Criteria;
+        $criteria->add(QubitRelation::SUBJECT_ID, 
$this->informationObject->id);
+        $criteria->add(QubitRelation::TYPE_ID, 
QubitTerm::NAME_ACCESS_POINT_ID);
+
+        foreach (QubitRelation::get($criteria) as $relation)
+        {
+          if (isset($selected[$relation->objectId]))
+          {
+            unset($filtered[$relation->objectId]);
+          }
+          else
+          {
+            $relation->delete();
+          }
+        }
+
+        foreach ($filtered as $id)
+        {
+          $relation = new QubitRelation;
+          $relation->objectId = $id;
+          $relation->typeId = QubitTerm::NAME_ACCESS_POINT_ID;
+
+          $this->informationObject->relationsRelatedBysubjectId[] = $relation;
+        }
+
+        break;
+
       default:
         $this->informationObject[$field->getName()] = 
$this->form->getValue($field->getName());
     }
@@ -385,24 +438,6 @@
     $this->titleNotes = $this->informationObject->getNotesByType($options = 
array ('noteTypeId' => QubitTerm::TITLE_NOTE_ID));
     $this->publicationNotes = 
$this->informationObject->getNotesByType($options = array ('noteTypeId' => 
QubitTerm::PUBLICATION_NOTE_ID));
 
-    //Access Points
-    $this->newSubjectAccessPoint = new QubitObjectTermRelation;
-    $this->newPlaceAccessPoint = new QubitObjectTermRelation;
-    $this->placeAccessPoints = 
$this->informationObject->getPlaceAccessPoints();
-
-    //$events = $this->informationObject->getEvents();
-
-    // Name access points
-    $this->nameSelectList = QubitActor::getAccessPointSelectList();
-    $this->nameAccessPoints = array();
-    foreach ($this->informationObject->relationsRelatedBysubjectId as 
$relation)
-    {
-      if (QubitTerm::NAME_ACCESS_POINT_ID == $relation->typeId)
-      {
-        $this->nameAccessPoints[] = $relation;
-      }
-    }
-
     if ($request->isMethod('post'))
     {
       $this->form->bind($request->getPostParameters());

Modified: 
trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php 
Fri Oct  9 12:18:44 2009        (r3707)
+++ trunk/apps/qubit/modules/informationobject/actions/editIsadAction.class.php 
Fri Oct  9 13:36:43 2009        (r3708)
@@ -38,6 +38,7 @@
       'archivalHistory',
       'arrangement',
       'creators',
+      'descriptionDetail',
       'descriptionIdentifier',
       'extentAndMedium',
       'findingAids',
@@ -46,9 +47,9 @@
       'languageOfDescription',
       'language',
       'levelOfDescription',
-      'descriptionDetail',
       'locationOfCopies',
       'locationOfOriginals',
+      'nameAccessPoints',
       'physicalCharacteristics',
       'placeAccessPoints',
       'relatedUnitsOfDescription',

Modified: 
trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php
==============================================================================
--- trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php    
Fri Oct  9 12:18:44 2009        (r3707)
+++ trunk/apps/qubit/modules/informationobject/templates/editIsadSuccess.php    
Fri Oct  9 13:36:43 2009        (r3708)
@@ -224,16 +224,11 @@
       <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">
-      <label><?php echo __('name access points') ?></label>
-      <?php if ($nameAccessPoints): ?>
-      <ul>
-      <?php foreach ($nameAccessPoints as $relation): ?>
-        <li><?php echo render_title($relation->object); ?></li>
-      <?php endforeach; ?>
-      </ul>
-      <?php endif; ?>
-      <?php echo select_tag('name_id', options_for_select($nameSelectList, 
null, array('include_blank' => true)), array('class'=>'multiInstance')) ?>
+    <div class="form-item">
+      <?php echo $form->nameAccessPoints->label(__('name access 
points'))->renderLabel() ?>
+      <?php echo $form->nameAccessPoints->render(array('class' => 
'form-autocomplete')) ?>
+      <input class="add" type="hidden" value="<?php echo 
url_for(array('module' => 'actor', 'action' => 'create')) ?> 
#authorized_form_of_name"/>
+      <input class="list" type="hidden" value="<?php echo 
url_for(array('module' => 'actor', 'action' => 'autocomplete')) ?>"/>
     </div>
   </fieldset>
 

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