Author: sevein
Date: Tue Jul 12 13:19:49 2011
New Revision: 9302
Log:
Create QubitContactInformation component, used in donor contact area, coulde be
also used in repository contact area
Added:
trunk/apps/qubit/modules/contactinformation/
trunk/apps/qubit/modules/contactinformation/actions/
trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php
trunk/apps/qubit/modules/contactinformation/templates/
trunk/apps/qubit/modules/contactinformation/templates/_relatedContactInformation.php
Modified:
trunk/plugins/qtAccessionPlugin/modules/donor/actions/editAction.class.php
trunk/plugins/qtAccessionPlugin/modules/donor/templates/editSuccess.php
trunk/plugins/qtAccessionPlugin/modules/donor/templates/indexSuccess.php
Added:
trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++
trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php
Tue Jul 12 13:19:49 2011 (r9302)
@@ -0,0 +1,62 @@
+<?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 ContactInformationRelatedContactInformationComponent extends sfComponent
+{
+ // Arrays not allowed in class constants
+ public static
+ $NAMES = array(
+ 'resource');
+
+ protected function addField($name)
+ {
+ switch ($name)
+ {
+ case 'resource':
+ break;
+ }
+ }
+
+ protected function processField($field)
+ {
+ switch ($field->getName())
+ {
+ default:
+ $this->relation[$field->getName()] =
$this->form->getValue($field->getName());
+ }
+ }
+
+ public function execute($request)
+ {
+ $this->form = new sfForm;
+ $this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
+
+
$this->form->getWidgetSchema()->setNameFormat('relatedContactInformation[%s]');
+
+ // HACK Use static::$NAMES in PHP 5.3,
+ // http://php.net/oop5.late-static-bindings
+ $class = new ReflectionClass($this);
+ foreach ($class->getStaticPropertyValue('NAMES') as $name)
+ {
+ $this->addField($name);
+ }
+
+ $this->relatedContactInformation = array();
+ }
+}
Added:
trunk/apps/qubit/modules/contactinformation/templates/_relatedContactInformation.php
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++
trunk/apps/qubit/modules/contactinformation/templates/_relatedContactInformation.php
Tue Jul 12 13:19:49 2011 (r9302)
@@ -0,0 +1,129 @@
+<?php
$sf_response->addStylesheet('/vendor/yui/container/assets/skins/sam/container',
'first') ?>
+
+<?php $sf_response->addJavaScript('date') ?>
+<?php $sf_response->addJavaScript('/vendor/yui/datasource/datasource-min') ?>
+<?php $sf_response->addJavaScript('/vendor/yui/container/container-min') ?>
+<?php $sf_response->addJavaScript('dialog') ?>
+<?php $sf_response->addJavaScript('multiDelete') ?>
+
+<?php use_helper('Javascript') ?>
+
+<div class="section">
+
+ <table id="relatedContactInformations">
+ <caption>
+ <?php echo __('Related contact informations') ?>
+ </caption><thead>
+ <tr>
+ <th style="width: 25%">
+ <?php echo __('Name') ?>
+ </th><th style="text-align: center; width: 10%">
+ <?php echo image_tag('delete', array('align' => 'top', 'class' =>
'deleteIcon')) ?>
+ </th>
+ </tr>
+ </thead><tbody>
+ <?php foreach ($relatedContactInformation as $item): ?>
+ <tr class="<?php echo 0 == ++$row % 2 ? 'even' : 'odd' ?>
related_obj_<?php echo $item->id ?>" id="<?php echo url_for(array($item,
'module' => 'relation')) ?>">
+ <td>
+ <?php if ($resource->id == $item->objectId): ?>
+ <?php echo render_title($item->subject) ?>
+ <?php else: ?>
+ <?php echo render_title($item->object) ?>
+ <?php endif; ?>
+ </td><td style="text-align: center">
+ <input class="multiDelete" name="deleteRelations[]"
type="checkbox" value="<?php echo url_for(array($item, 'module' => 'relation'))
?>"/>
+ </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->resource->renderName()}}
+ </td><td>
+ {{$form->type->renderName()}}
+ </td><td>
+ {{$form->description->renderName()}}
+ </td><td>
+ {{$form->date->renderName()}}
+ </td><td style="text-align: right">
+ $editHtml <button class="delete-small" name="delete" type="button"/>
+ </td>
+</tr>
+
+value
+);
+
+$url = url_for($resource);
+
+echo javascript_tag(<<<content
+
+// Add special rendering rules
+var handleFieldRender = function (fname)
+ {
+ if (-1 !== fname.indexOf('date')
+ && 1 > this.getField('date').value.length
+ && (0 < this.getField('startDate').value.length
+ || 0 < this.getField('endDate').value.length))
+ {
+ return this.getField('startDate').value + ' - ' +
this.getField('endDate').value;
+ }
+
+ return this.renderField(fname);
+ }
+
+Drupal.behaviors.relatedContactInformation = {
+ attach: function (context)
+ {
+ // Define dialog
+ var dialog = new QubitDialog('functionRelation', {
+ 'displayTable': 'relatedFunctions',
+ 'newRowTemplate': $rowTemplate,
+ 'handleFieldRender': handleFieldRender,
+ 'relationTableMap': function (response)
+ {
+ response.resource = response.object;
+ if ('$url' === response.resource)
+ {
+ response.resource = response.subject;
+ }
+
+ return response;
+ } });
+
+ // Add edit button to rows
+ jQuery('#relatedFunctions tr[id]', context)
+ .click(function ()
+ {
+ dialog.open(this.id);
+ })
+ .find('td:last')
+ .prepend('$editHtml');
+ } }
+
+content
+) ?>
+
+ <!-- NOTE dialog.js wraps this *entire* table in a YUI dialog -->
+ <div class="date section" id="contactInformationRelation">
+
+ <h3><?php echo __('Related contact information') ?></h3>
+
+ <div>
+
+ <?php /* echo $form->description
+ ->help(__('"Record a precise description of the nature of the
relationship between the function being described and the related function."
(ISDF 5.3.3) Note that the text entered in this field will also appear in the
related function.'))
+ ->renderRow() */ ?>
+
+ </div>
+
+ </div>
+
+</div>
Modified:
trunk/plugins/qtAccessionPlugin/modules/donor/actions/editAction.class.php
==============================================================================
--- trunk/plugins/qtAccessionPlugin/modules/donor/actions/editAction.class.php
Tue Jul 12 13:03:24 2011 (r9301)
+++ trunk/plugins/qtAccessionPlugin/modules/donor/actions/editAction.class.php
Tue Jul 12 13:19:49 2011 (r9302)
@@ -24,23 +24,6 @@
$NAMES = array(
'authorizedFormOfName');
- protected function addField($name)
- {
- switch ($name)
- {
- case 'authorizedFormOfName':
- $this->form->setDefault('authorizedFormOfName',
$this->resource->authorizedFormOfName);
- $this->form->setValidator('authorizedFormOfName', new
sfValidatorString);
- $this->form->setWidget('authorizedFormOfName', new sfWidgetFormInput);
-
- break;
-
- default:
-
- return parent::addField($name);
- }
- }
-
protected function earlyExecute()
{
$this->form->getValidatorSchema()->setOption('allow_extra_fields', true);
@@ -89,6 +72,27 @@
}
$this->response->setTitle("$title - {$this->response->getTitle()}");
+
+ $this->relatedContactInformationComponent = new
ContactInformationRelatedContactInformationComponent($this->context,
'contactinformation', 'relatedContactInformation');
+ $this->relatedContactInformationComponent->resource = $this->resource;
+ $this->relatedContactInformationComponent->execute($this->request);
+ }
+
+ protected function addField($name)
+ {
+ switch ($name)
+ {
+ case 'authorizedFormOfName':
+ $this->form->setDefault('authorizedFormOfName',
$this->resource->authorizedFormOfName);
+ $this->form->setValidator('authorizedFormOfName', new
sfValidatorString);
+ $this->form->setWidget('authorizedFormOfName', new sfWidgetFormInput);
+
+ break;
+
+ default:
+
+ return parent::addField($name);
+ }
}
public function execute($request)
@@ -101,12 +105,21 @@
if ($this->form->isValid())
{
+ $this->relatedContactInformationComponent->processForm();
+
+ if (isset($this->request->deleteRelations))
+ {
+ foreach ($this->request->deleteRelations as $item)
+ {
+ $params = $this->context->routing->parse(Qubit::pathInfo($item));
+ $params['_sf_route']->resource->delete();
+ }
+ }
+
$this->processForm();
$this->resource->save();
- // $this->updateContactInformation();
-
$this->redirect(array($this->resource, 'module' => 'donor'));
}
}
Modified:
trunk/plugins/qtAccessionPlugin/modules/donor/templates/editSuccess.php
==============================================================================
--- trunk/plugins/qtAccessionPlugin/modules/donor/templates/editSuccess.php
Tue Jul 12 13:03:24 2011 (r9301)
+++ trunk/plugins/qtAccessionPlugin/modules/donor/templates/editSuccess.php
Tue Jul 12 13:19:49 2011 (r9302)
@@ -20,6 +20,14 @@
</fieldset>
+ <fieldset class="collapsible" id="contactArea">
+
+ <legend><?php echo __('Contact area') ?></legend>
+
+ <?php echo get_partial('contactinformation/relatedContactInformation',
$relatedContactInformationComponent->getVarHolder()->getAll()) ?>
+
+ </fieldset>
+
<div class="actions section">
<h2 class="element-invisible"><?php echo __('Actions') ?></h2>
Modified:
trunk/plugins/qtAccessionPlugin/modules/donor/templates/indexSuccess.php
==============================================================================
--- trunk/plugins/qtAccessionPlugin/modules/donor/templates/indexSuccess.php
Tue Jul 12 13:03:24 2011 (r9301)
+++ trunk/plugins/qtAccessionPlugin/modules/donor/templates/indexSuccess.php
Tue Jul 12 13:19:49 2011 (r9302)
@@ -14,6 +14,19 @@
<?php echo render_show(__('Authorized form of name'),
render_value($resource->getAuthorizedFormOfName(array('cultureFallback' =>
true)))) ?>
+<div class="section" id="contactArea">
+
+ <h2><?php echo __('Contact area') ?></h2>
+
+ <?php // echo get_partial('...', ...) ?>
+
+ <div class="field">
+ <h3>TODO contacat area</h3>
+ <div class="value">TODO</div>
+ </div>
+
+</div> <!-- /.section#contactArea -->
+
<div class="actions section">
<h2 class="element-invisible"><?php echo __('Actions') ?></h2>
--
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.