Author: sevein
Date: Fri Jul 29 15:06:21 2011
New Revision: 9421
Log:
Unify right components
Added:
trunk/apps/qubit/modules/right/templates/_edit.php
- copied unchanged from r9408,
trunk/plugins/qtAccessionPlugin/modules/accession/templates/_right.php
Deleted:
trunk/plugins/qtAccessionPlugin/modules/accession/actions/rightComponent.class.php
trunk/plugins/qtAccessionPlugin/modules/accession/templates/_right.php
Modified:
trunk/apps/qubit/modules/right/actions/editComponent.class.php
trunk/plugins/qtAccessionPlugin/modules/accession/actions/editAction.class.php
Modified: trunk/apps/qubit/modules/right/actions/editComponent.class.php
==============================================================================
--- trunk/apps/qubit/modules/right/actions/editComponent.class.php Fri Jul
29 14:07:06 2011 (r9420)
+++ trunk/apps/qubit/modules/right/actions/editComponent.class.php Fri Jul
29 15:06:21 2011 (r9421)
@@ -19,6 +19,15 @@
class RightEditComponent extends sfComponent
{
+ // Arrays not allowed in class constants
+ public static
+ $NAMES = array(
+ 'act',
+ 'basis',
+ 'copyrightNote',
+ 'endDate',
+ 'startDate');
+
protected function addField($name)
{
switch ($name)
@@ -174,5 +183,7 @@
{
$this->addField($name);
}
+
+ $this->rights =
QubitRelation::getRelationsBySubjectId($this->resource->id, array('typeId' =>
QubitTerm::RIGHT_ID));
}
}
Copied: trunk/apps/qubit/modules/right/templates/_edit.php (from r9408,
trunk/plugins/qtAccessionPlugin/modules/accession/templates/_right.php)
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/apps/qubit/modules/right/templates/_edit.php Fri Jul 29 15:06:21
2011 (r9421, copy of r9408,
trunk/plugins/qtAccessionPlugin/modules/accession/templates/_right.php)
@@ -0,0 +1,119 @@
+<?php
$sf_response->addStylesheet('/vendor/yui/container/assets/skins/sam/container',
'first') ?>
+
+<?php $sf_response->addJavaScript('/vendor/yui/datasource/datasource-min') ?>
+<?php $sf_response->addJavaScript('/vendor/yui/container/container-min') ?>
+<?php $sf_response->addJavaScript('dialog') ?>
+
+<?php use_helper('Javascript') ?>
+
+<div class="section">
+
+ <table id="rightDisplay">
+ <caption>
+ <?php echo __('Right records') ?>
+ </caption><thead>
+ <tr>
+ <th>
+ <?php echo __('Start') ?>
+ </th><th>
+ <?php echo __('End') ?>
+ </th><th>
+ <?php echo __('Act') ?>
+ </th><th>
+ <?php echo __('Basis') ?>
+ </th><th><th style="text-align: center; width: 10%">
+ <?php echo image_tag('delete', array('align' => 'top', 'class' =>
'deleteIcon')) ?>
+ </th>
+ </tr>
+ </thead><tbody>
+ <?php foreach ($rights as $item): ?>
+ <tr class="<?php echo 0 == ++$row % 2 ? 'even' : 'odd' ?>
related_obj_<?php echo $item->id ?>" id="<?php echo
url_for(array($item->object, 'module' => 'right')) ?>">
+ <td>
+ <?php echo $item->object->startDate ?>
+ </td><td>
+ <?php echo $item->object->endDate ?>
+ </td><td>
+ <?php echo $item->object->act ?>
+ </td><td>
+ <?php echo $item->object->basis ?>
+ </td><td style="text-align: center">
+ <input class="multiDelete" name="deleteRights[]" type="checkbox"
value="<?php echo url_for(array($item->object, 'module' => 'right')) ?>"/>
+ </td>
+ </tr>
+ <?php endforeach; ?>
+ </tbody>
+ </table>
+
+<?php
+
+// Template for new display table rows
+$editHtml = image_tag('pencil', array('alt' => 'edit', 'style' => 'align:
top'));
+
+$rowTemplate = json_encode(<<<value
+<tr id="{{$form->getWidgetSchema()->generateName('id')}}">
+ <td>
+ {{$form->startDate->renderName()}}
+ </td><td>
+ {{$form->endDate->renderName()}}
+ </td><td>
+ {{$form->act->renderName()}}
+ </td><td>
+ {{$form->basis->renderName()}}
+ </td><td style="text-align: right">
+ $editHtml <button class="delete-small" name="delete" type="button"/>
+ </td>
+</tr>
+
+value
+);
+
+// Omit edit button if object is being duplicated
+$editButtonJs = null;
+if (!isset($sf_request->source))
+{
+ $editButtonJs = <<<editButtonJs
+// Add edit button to rows
+jQuery('#rightDisplay tr[id]', context)
+ .click(function ()
+ {
+ dialog.open(this.id);
+ })
+ .find('td:last')
+ .prepend('$editHtml');
+
+editButtonJs;
+}
+
+echo javascript_tag(<<<content
+Drupal.behaviors.right = {
+ attach: function (context)
+ {
+ // Define dialog
+ var dialog = new QubitDialog('updateRight', {
+ 'displayTable': 'rightDisplay',
+ 'newRowTemplate': $rowTemplate });
+
+ $editButtonJs
+ } }
+
+content
+) ?>
+
+ <!-- NOTE dialog.js wraps this *entire* table in a YUI dialog -->
+ <div class="section" id="updateRight">
+
+ <h3><?php echo __('Right') ?></h3>
+
+ <?php echo $form->startDate->renderRow() ?>
+
+ <?php echo $form->endDate->renderRow() ?>
+
+ <?php echo $form->act->renderRow() ?>
+
+ <?php echo $form->basis->renderRow() ?>
+
+ <?php echo $form->copyrightNote->renderRow() ?>
+
+ </div>
+
+</div>
Modified:
trunk/plugins/qtAccessionPlugin/modules/accession/actions/editAction.class.php
==============================================================================
---
trunk/plugins/qtAccessionPlugin/modules/accession/actions/editAction.class.php
Fri Jul 29 14:07:06 2011 (r9420)
+++
trunk/plugins/qtAccessionPlugin/modules/accession/actions/editAction.class.php
Fri Jul 29 15:06:21 2011 (r9421)
@@ -80,9 +80,9 @@
$this->relatedDonorComponent->resource = $this->resource;
$this->relatedDonorComponent->execute($this->request);
- $this->rightComponent = new AccessionRightComponent($this->context,
'accession', 'right');
- $this->rightComponent->resource = $this->resource;
- $this->rightComponent->execute($this->request);
+ $this->rightEditComponent = new RightEditComponent($this->context,
'right', 'edit');
+ $this->rightEditComponent->resource = $this->resource;
+ $this->rightEditComponent->execute($this->request);
}
protected function addField($name)
@@ -287,7 +287,7 @@
{
$this->relatedDonorComponent->processForm();
- $this->rightComponent->processForm();
+ $this->rightEditComponent->processForm();
if (isset($this->request->deleteRelations))
{
--
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.