Author: sevein
Date: Wed Jun 29 15:58:40 2011
New Revision: 9226

Log:
Update accession/deaccession action/templates

Added:
   
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/editDeaccessionAction.class.php
   
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/indexDeaccessionAction.class.php
   
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/editDeaccessionSuccess.php
   
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/indexDeaccessionSuccess.php
Modified:
   
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/editAction.class.php
   
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/listAction.class.php
   trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/config/view.yml
   
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/editSuccess.php
   
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/indexSuccess.php
   
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/listSuccess.php

Modified: 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/editAction.class.php
==============================================================================
--- 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/editAction.class.php
      Wed Jun 29 15:57:54 2011        (r9225)
+++ 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/editAction.class.php
      Wed Jun 29 15:58:40 2011        (r9226)
@@ -27,7 +27,6 @@
       'condition',
       'content',
       'creator',
-      'date',
       'identifier',
       'locationInformation',
       'resourceType',
@@ -142,7 +141,6 @@
         break;
 
       case 'creator':
-      case 'date':
       case 'identifier':
       case 'receivedExtentUnits':
       case 'title':

Added: 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/editDeaccessionAction.class.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/editDeaccessionAction.class.php
   Wed Jun 29 15:58:40 2011        (r9226)
@@ -0,0 +1,155 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class qtAccessionPluginEditDeaccessionAction extends DefaultEditAction
+{
+  // Arrays not allowed in class constants
+  public static
+    $NAMES = array(
+      'description',
+      'extent',
+      'identifier',
+      'reason',
+      'scope');
+
+  public function earlyExecute()
+  {
+    $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
+
+    $this->resource = new QubitDeaccession;
+
+    if (isset($this->getRoute()->resource))
+    {
+      $this->resource = $this->getRoute()->resource;
+
+      // Check user authorization
+      if (!QubitAcl::check($this->resource, 'update'))
+      {
+        QubitAcl::forwardUnauthorized();
+      }
+    }
+    else
+    {
+      // Check user authorization
+      if (!QubitAcl::check($this->resource, 'create'))
+      {
+        QubitAcl::forwardUnauthorized();
+      }
+    }
+
+    $this->form->setDefault('accessionId', $this->request->accessionId);
+    $this->form->setValidator('accessionId', new sfValidatorInteger);
+    $this->form->setWidget('accessionId', new sfWidgetFormInputHidden);
+
+    /*
+    $title = $this->context->i18n->__('Add new deaccession record');
+    if (isset($this->getRoute()->resource))
+    {
+      if (1 > strlen($title = $this->resource->__toString()))
+      {
+        $title = $this->context->i18n->__('Untitled');
+      }
+
+      $title = $this->context->i18n->__('Edit %1%', array('%1%' => $title));
+    }
+
+    $this->response->setTitle("$title - {$this->response->getTitle()}");
+    */
+  }
+
+  protected function addField($name)
+  {
+    switch ($name)
+    {
+      case 'scope':
+        $this->form->setDefault('scope', 
$this->context->routing->generate(null, array($this->resource->scope, 'module' 
=> 'term')));
+        $this->form->setValidator('scope', new sfValidatorString);
+
+        $choices = array();
+        $choices[null] = null;
+        foreach 
(QubitTaxonomy::getTermsById(QubitTaxonomy::DEACCESSION_SCOPE_ID) as $item)
+        {
+          $choices[$this->context->routing->generate(null, array($item, 
'module' => 'term'))] = $item;
+        }
+
+        $this->form->setWidget('scope', new sfWidgetFormSelect(array('choices' 
=> $choices)));
+
+        break;    
+
+      case 'description':
+      case 'extent':
+      case 'reason':
+        $this->form->setDefault($name, $this->resource[$name]);
+        $this->form->setValidator($name, new sfValidatorString);
+        $this->form->setWidget($name, new sfWidgetFormTextarea);
+
+        break;
+
+      case 'identifier':
+        $this->form->setDefault($name, $this->resource[$name]);
+        $this->form->setValidator($name, new sfValidatorString);
+        $this->form->setWidget($name, new sfWidgetFormInput);
+
+        break;
+
+      default:
+
+        return parent::addField($name);
+    }
+  }
+
+  protected function processField($field)
+  {
+    switch ($field->getName())
+    {
+      case 'scope':
+        unset($this->resource->scope);
+
+        $value = $this->form->getValue('scope');
+        if (isset($value))
+        {
+          $params = $this->context->routing->parse(Qubit::pathInfo($value));
+          $this->resource->scope = $params['_sf_route']->resource;
+        }
+
+        break;
+
+      default:
+        return parent::processField($field);
+    }
+  }
+
+  public function execute($request)
+  {
+    parent::execute($request);
+
+    if ($request->isMethod('post'))
+    {
+      $this->form->bind($request->getPostParameters());
+      if ($this->form->isValid())
+      {
+        $this->processForm();
+
+        $this->resource->save();
+
+        $this->redirect(array($this->resource->accession, 'module' => 
'qtAccessionPlugin'));
+      }
+    }
+  }
+}

Added: 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/indexDeaccessionAction.class.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/indexDeaccessionAction.class.php
  Wed Jun 29 15:58:40 2011        (r9226)
@@ -0,0 +1,54 @@
+<?php
+
+/*
+ * This file is part of Qubit Toolkit.
+ *
+ * Qubit Toolkit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Qubit Toolkit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Qubit Toolkit.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class qtAccessionPluginIndexDeaccessionAction extends sfAction
+{
+  public function execute($request)
+  {
+    $this->resource = $this->getRoute()->resource;
+
+    // Check user authorization
+    if (!QubitAcl::check($this->resource, 'read'))
+    {
+      QubitAcl::forwardToSecureAction();
+    }
+
+    if (1 > strlen($title = $this->resource->__toString()))
+    {
+      $title = $this->context->i18n->__('Untitled');
+    }
+
+    $this->response->setTitle("$title - {$this->response->getTitle()}");
+
+    if (QubitAcl::check($this->resource, 'update'))
+    {
+      $validatorSchema = new sfValidatorSchema;
+      $values = array();
+
+      try
+      {
+        $validatorSchema->clean($values);
+      }
+      catch (sfValidatorErrorSchema $e)
+      {
+        $this->errorSchema = $e;
+      }
+    }
+  }
+}

Modified: 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/listAction.class.php
==============================================================================
--- 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/listAction.class.php
      Wed Jun 29 15:57:54 2011        (r9225)
+++ 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/actions/listAction.class.php
      Wed Jun 29 15:58:40 2011        (r9226)
@@ -33,8 +33,6 @@
 
     $criteria = new Criteria;
 
-    $criteria->addAscendingOrderByColumn('date');
-
     // Page results
     $this->pager = new QubitPager('QubitAccession');
     $this->pager->setCriteria($criteria);

Modified: 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/config/view.yml
==============================================================================
--- trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/config/view.yml   
Wed Jun 29 15:57:54 2011        (r9225)
+++ trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/config/view.yml   
Wed Jun 29 15:58:40 2011        (r9226)
@@ -7,8 +7,21 @@
     /plugins/sfDrupalPlugin/vendor/drupal/misc/collapse:
     /plugins/sfDrupalPlugin/vendor/drupal/misc/form:
     /plugins/sfDrupalPlugin/vendor/drupal/misc/textarea:
-    date:
+
+editDeaccessionSuccess:
+  stylesheets:
+    /vendor/yui/autocomplete/assets/skins/sam/autocomplete: { position: first }
+    edit:
+  javascripts:
+    /plugins/sfDrupalPlugin/vendor/drupal/misc/jquery.once.js:
+    /plugins/sfDrupalPlugin/vendor/drupal/misc/collapse:
+    /plugins/sfDrupalPlugin/vendor/drupal/misc/form:
+    /plugins/sfDrupalPlugin/vendor/drupal/misc/textarea:
 
 indexSuccess:
   javascripts:
     blank:
+
+indexDeaccessionSuccess:
+  javascripts:
+    blank:

Added: 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/editDeaccessionSuccess.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/editDeaccessionSuccess.php
      Wed Jun 29 15:58:40 2011        (r9226)
@@ -0,0 +1,43 @@
+<h1><?php echo __('Edit deaccession record') ?></h1>
+
+<h1 class="label">&nbsp;</h1>
+
+<?php echo $form->renderGlobalErrors() ?>
+
+<?php if (isset($sf_request->getAttribute('sf_route')->resource)): ?>
+  <?php echo $form->renderFormTag(url_for(array($resource, 'module' => 
'deaccession', 'action' => 'edit')), array('id' => 'editForm')) ?>
+<?php else: ?>
+  <?php echo $form->renderFormTag(url_for(array('module' => 'deaccession', 
'action' => 'add')), array('id' => 'editForm')) ?>
+<?php endif; ?>
+
+  <?php echo $form->renderHiddenFields() ?>
+
+  <?php echo $form->identifier->renderRow() ?>
+
+  <?php echo $form->scope->renderRow() ?>
+
+  <?php echo render_field($form->description, $resource) ?>
+
+  <?php echo render_field($form->extent, $resource) ?>
+
+  <?php echo render_field($form->reason, $resource) ?>
+
+  <div class="actions section">
+
+    <h2 class="element-invisible"><?php echo __('Actions') ?></h2>
+
+    <div class="content">
+      <ul class="clearfix links">
+
+        <?php if (isset($resource->id)): ?>
+          <li><?php echo link_to(__('Cancel'), array($resource, 'module' => 
'accession')) ?></li>
+          <li><input class="form-submit" type="submit" value="<?php echo 
__('Save') ?>"/></li>
+        <?php else: ?>
+          <li><?php echo link_to(__('Cancel'), array('module' => 'accession', 
'action' => 'list')) ?></li>
+          <li><input class="form-submit" type="submit" value="<?php echo 
__('Create') ?>"/></li>
+        <?php endif; ?>
+
+      </ul>
+    </div>
+
+  </div>

Modified: 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/editSuccess.php
==============================================================================
--- 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/editSuccess.php
 Wed Jun 29 15:57:54 2011        (r9225)
+++ 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/editSuccess.php
 Wed Jun 29 15:58:40 2011        (r9226)
@@ -16,10 +16,6 @@
     ->label(__('Identifier').' <span class="form-required" title="'.__('This 
is a mandatory element.').'">*</span>')
     ->renderRow() ?>
 
-  <?php echo $form->date
-    ->label(__('Date').' <span class="form-required" title="'.__('This is a 
mandatory element.').'">*</span>')
-    ->renderRow(array('class' => 'dateiso')) ?>  
-
   <?php echo render_field($form->sourceOfAcquisition
     ->label(__('Source of acquisition').' <span class="form-required" 
title="'.__('This is a mandatory element.').'">*</span>'), $resource, 
array('class' => 'resizable')) ?>
 

Added: 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/indexDeaccessionSuccess.php
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/indexDeaccessionSuccess.php
     Wed Jun 29 15:58:40 2011        (r9226)
@@ -0,0 +1,29 @@
+<h1><?php echo __('View accession record') ?></h1>
+
+<?php echo link_to_if(QubitAcl::check($resource, 'update'), '<h1 
class="label">'.render_title($resource).'</h1>', array($resource, 'module' => 
'accession', 'action' => 'edit'), array('title' => __('Edit accession 
record'))) ?>
+
+<?php if (isset($errorSchema)): ?>
+  <div class="messages error">
+    <ul>
+      <?php foreach ($errorSchema as $error): ?>
+        <li><?php echo $error ?></li>
+      <?php endforeach; ?>
+    </ul>
+  </div>
+<?php endif; ?>
+
+<?php echo render_show(__('Identifier'), render_value($resource->identifier)) 
?>
+
+<div class="actions section">
+
+  <h2 class="element-invisible"><?php echo __('Actions') ?></h2>
+
+  <div class="content">
+    <ul class="clearfix links">
+
+        <li><?php echo link_to(__('Edit'), array($resource, 'module' => 
'deaccession', 'action' => 'editDeaccession')) ?></li>
+
+    </ul>
+  </div>
+
+</div>

Modified: 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/indexSuccess.php
==============================================================================
--- 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/indexSuccess.php
        Wed Jun 29 15:57:54 2011        (r9225)
+++ 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/indexSuccess.php
        Wed Jun 29 15:58:40 2011        (r9226)
@@ -58,6 +58,23 @@
 
 </div> <!-- /.section#rightsArea -->
 
+<div class="section" id="deaccessionArea">
+
+  <h2><?php echo __('Deaccession area') ?></h2>
+
+  <?php foreach ($resource->deaccessions as $deaccession): ?>
+
+    <div class="field">
+      <h3>Deaccession</h3>
+      <div>
+        <?php echo link_to($deaccession->__toString(), array($deaccession, 
'module' => 'deaccession')) ?>
+      </div>
+    </div>
+
+  <?php endforeach; ?>
+
+</div> <!-- /.section#deaccessionArea -->
+
 <div class="actions section">
 
   <h2 class="element-invisible"><?php echo __('Actions') ?></h2>
@@ -67,9 +84,9 @@
 
         <li><?php echo link_to(__('Edit'), array($resource, 'module' => 
'accession', 'action' => 'edit')) ?></li>
 
-        <li><?php echo link_to(__('Deaccession'), array($resource, 'module' => 
'accession', 'action' => 'editDeaccession')) ?></li>
+        <li><?php echo link_to(__('Deaccession'), array('module' => 
'deaccession', 'action' => 'add', 'accessionId' => $resource->id)) ?></li>
 
-        <li><?php echo link_to(__('Create %1%', array('%1%' => 
sfConfig::get('app_ui_label_informationobject'))), array($resource, 'module' => 
'accession', 'action' => 'edit')) ?></li>
+        <li><?php echo link_to(__('Create %1%', array('%1%' => 
sfConfig::get('app_ui_label_informationobject'))), array('module' => 
'informationobject', 'action' => 'add', 'accessionId' => $resource->id)) ?></li>
 
     </ul>
   </div>

Modified: 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/listSuccess.php
==============================================================================
--- 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/listSuccess.php
 Wed Jun 29 15:57:54 2011        (r9225)
+++ 
trunk/plugins/qtAccessionPlugin/modules/qtAccessionPlugin/templates/listSuccess.php
 Wed Jun 29 15:58:40 2011        (r9226)
@@ -15,7 +15,7 @@
         <td>
           <?php echo link_to(render_title($item), array($item, 'module' => 
'accession')) ?>
         </td><td>
-          <?php echo $item->getDate() ?>
+          
         </td>
       </tr>
     <?php endforeach; ?>

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