Author: sevein Date: Thu Aug 18 17:29:44 2011 New Revision: 9539 Log: Update contact information component code to work without QubitRelation entity
Added: trunk/apps/qubit/modules/contactinformation/actions/indexAction.class.php Modified: trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php trunk/apps/qubit/modules/contactinformation/templates/_relatedContactInformation.php Added: trunk/apps/qubit/modules/contactinformation/actions/indexAction.class.php ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/apps/qubit/modules/contactinformation/actions/indexAction.class.php Thu Aug 18 17:29:44 2011 (r9539) @@ -0,0 +1,107 @@ +<?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 ContactInformationIndexAction extends sfAction +{ + public function execute($request) + { + $resource = QubitContactInformation::getById($request->id); + + if (!isset($resource)) + { + $this->forward404(); + } + + $value = array(); + + $value['primaryContact'] = (bool)$this->resource->primaryContact; + + if (isset($this->resource->contactPerson)) + { + $value['contactPerson'] = $this->resource->contactPerson; + } + + if (isset($this->resource->streetAddress)) + { + $value['streetAddress'] = $this->resource->streetAddress; + } + + if (isset($this->resource->website)) + { + $value['website'] = $this->resource->website; + } + + if (isset($this->resource->email)) + { + $value['email'] = $this->resource->email; + } + + if (isset($this->resource->telephone)) + { + $value['telephone'] = $this->resource->telephone; + } + + if (isset($this->resource->fax)) + { + $value['fax'] = $this->resource->fax; + } + + if (isset($this->resource->postalCode)) + { + $value['postalCode'] = $this->resource->postalCode; + } + + if (isset($this->resource->countryCode)) + { + $value['countryCode'] = $this->resource->countryCode; + } + + if (isset($this->resource->latitude)) + { + $value['latitude'] = $this->resource->latitude; + } + + if (isset($this->resource->longitude)) + { + $value['longitude'] = $this->resource->longitude; + } + + if (isset($this->resource->city)) + { + $value['city'] = $this->resource->city; + } + + if (isset($this->resource->region)) + { + $value['region'] = $this->resource->region; + } + + if (isset($this->resource->note)) + { + $value['note'] = $this->resource->note; + } + + if (isset($this->resource->contactType)) + { + $value['contactType'] = $this->resource->contactType; + } + + return $this->renderText(json_encode($value)); + } +} Modified: trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php ============================================================================== --- trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php Thu Aug 18 17:28:36 2011 (r9538) +++ trunk/apps/qubit/modules/contactinformation/actions/relatedContactInformationComponent.class.php Thu Aug 18 17:29:44 2011 (r9539) @@ -81,7 +81,7 @@ switch ($field->getName()) { default: - $this->relation[$field->getName()] = $this->form->getValue($field->getName()); + $this->resource[$field->getName()] = $this->form->getValue($field->getName()); } } @@ -118,12 +118,12 @@ { if (isset($item['id'])) { - $params = $this->context->routing->parse(Qubit::pathInfo($item['id'])); - $this->relation = $params['_sf_route']->resource; + // $params = $this->context->routing->parse(Qubit::pathInfo($item['id'])); + // $this->relation = $params['_sf_route']->resource; } else { - $this->resource->relationsRelatedBysubjectId[] = $this->relation = new QubitRelation; + // $this->resource->relationsRelatedBysubjectId[] = $this->relation = new QubitRelation; } foreach ($this->form as $field) @@ -135,6 +135,19 @@ } } } + + if (isset($this->request->deleteContactInformations)) + { + foreach ($this->request->deleteContactInformations as $item) + { + $contactInformation = QubitContactInformation::getById($item); + + if (isset($contactInformation)) + { + $contactInformation->delete(); + } + } + } } public function execute($request) @@ -148,7 +161,5 @@ { $this->addField($name); } - - $this->relatedContactInformation = $this->resource->getContactInformation(); } } Modified: trunk/apps/qubit/modules/contactinformation/templates/_relatedContactInformation.php ============================================================================== --- trunk/apps/qubit/modules/contactinformation/templates/_relatedContactInformation.php Thu Aug 18 17:28:36 2011 (r9538) +++ trunk/apps/qubit/modules/contactinformation/templates/_relatedContactInformation.php Thu Aug 18 17:29:44 2011 (r9539) @@ -1,6 +1,7 @@ <?php $sf_response->addStylesheet('/vendor/yui/tabview/assets/skins/sam/tabview', 'first') ?> <?php $sf_response->addStylesheet('/vendor/yui/container/assets/skins/sam/container', 'first') ?> +<?php $sf_response->addJavaScript('/vendor/yui/connection/connection-min') ?> <?php $sf_response->addJavaScript('/vendor/yui/datasource/datasource-min') ?> <?php $sf_response->addJavaScript('/vendor/yui/container/container-min') ?> <?php $sf_response->addJavaScript('/vendor/yui/tabview/tabview-min') ?> @@ -11,31 +12,27 @@ <div class="section"> - <table id="relatedContactInformationsa"> + <table id="relatedContactInformations"> <caption> <?php echo __('Related contact informations') ?> </caption><thead> <tr> <th style="width: 25%"> - <?php echo __('Name') ?> + <?php echo __('Contact person') ?> </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')) ?>"> + <?php foreach ($resource->contactInformations 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' => 'contactinformation')) ?>"> <td> - <?php if ($resource->id == $item->objectId): ?> - <?php echo render_title($item->subject) ?> - <?php else: ?> - <?php echo render_title($item->object) ?> - <?php endif; ?> + <?php echo $item->contactPerson ?> </td><td style="text-align: center"> - <input class="multiDelete" name="deleteRelations[]" type="checkbox" value="<?php echo url_for(array($item, 'module' => 'relation')) ?>"/> + <input class="multiDelete" name="deleteContactInformations[]" type="checkbox" value="<?php echo url_for(array($item, 'module' => 'contactinformation')) ?>"/> </td> </tr> - <?php endforeach; */ ?> + <?php endforeach; ?> </tbody> </table> @@ -66,17 +63,7 @@ // Define dialog var dialog = new QubitDialog('contactInformationRelation', { 'displayTable': 'relatedContactInformations', - 'newRowTemplate': $rowTemplate, - 'relationTableMap': function (response) - { - response.resource = response.object; - if ('$url' === response.resource) - { - response.resource = response.subject; - } - - return response; - } }); + 'newRowTemplate': $rowTemplate }); // Add edit button to rows jQuery('#relatedContactInformations tr[id]', context) @@ -112,6 +99,8 @@ <?php // TODO jquery error echo $form->primaryContact->renderRow() ?> + <?php echo $form->contactPerson->renderRow() ?> + <?php echo $form->telephone->renderRow() ?> <?php echo $form->fax->renderRow() ?> @@ -122,8 +111,6 @@ ->label(__('URL')) ->renderRow() ?> - <?php echo $form->city->renderRow() ?> - </div> <div id="contactInformationRelation_Tab2"> @@ -136,6 +123,8 @@ <?php echo $form->postalCode->renderRow() ?> + <?php echo $form->city->renderRow() ?> + <?php echo $form->latitude->renderRow() ?> <?php echo $form->longitude->renderRow() ?> @@ -144,8 +133,6 @@ <div id="contactInformationRelation_Tab3"> - <?php echo $form->contactPerson->renderRow() ?> - <?php echo $form->contactType->renderRow() ?> <?php echo $form->note->renderRow() ?> -- 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.
