Changeset 32250
- Timestamp:
- 03/13/11 21:03:52 (2 years ago)
- Files:
-
- plugins/dcReloadedFormExtraPlugin/trunk/README (modified) (2 diffs)
- plugins/dcReloadedFormExtraPlugin/trunk/lib/validator/mtValidatorCuil.class.php (added)
- plugins/dcReloadedFormExtraPlugin/trunk/lib/validator/mtValidatorCuilExtended.class.php (added)
- plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/dcWidgetFormActivator.class.php (modified) (1 diff)
- plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/dcWidgetFormAjaxDependencePropel.class.php (added)
- plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/dcWidgetFormJQueryDependence.class.php (modified) (3 diffs)
- plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/dcWidgetFormJQueryPropelDependence.class.php (modified) (2 diffs)
- plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/mtWidgetFormCuil.class.php (added)
- plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/mtWidgetFormEmbed.class.php (added)
- plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/mtWidgetFormEmbedRenderer.class.php (added)
- plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/mtWidgetFormWrapper.class.php (modified) (2 diffs)
- plugins/dcReloadedFormExtraPlugin/trunk/modules/dc_ajax/actions/actions.class.php (modified) (1 diff)
- plugins/dcReloadedFormExtraPlugin/trunk/modules/dc_ajax/templates/mtWidgetFormEmbedAddSuccess.php (added)
- plugins/dcReloadedFormExtraPlugin/trunk/web/css/mtWidgetFormCuil.css (added)
- plugins/dcReloadedFormExtraPlugin/trunk/web/css/mtWidgetFormEmbed.css (added)
- plugins/dcReloadedFormExtraPlugin/trunk/web/images/clean.png (added)
- plugins/dcReloadedFormExtraPlugin/trunk/web/images/close-action.png (added)
- plugins/dcReloadedFormExtraPlugin/trunk/web/images/plus.png (added)
- plugins/dcReloadedFormExtraPlugin/trunk/web/images/reset.png (added)
- plugins/dcReloadedFormExtraPlugin/trunk/web/images/update.png (added)
- plugins/dcReloadedFormExtraPlugin/trunk/web/js/dc_widget_form_jquery_dependence.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/dcReloadedFormExtraPlugin/trunk/README
r31922 r32250 194 194 [php] 195 195 $this->setWidget("date", new mtWidgetFormInputDate()); 196 196 197 ### mtWidgetFormEmbed 198 199 Widgets that embeds a dinamic number of forms. This widget only does the 'view' part. The saving and deleting of new and previous object has to be done manually. 200 201 ### mtWidgetFormCuil 202 203 Represents an Argetine CUIL/CUIT 204 197 205 ## Validators 198 206 … … 200 208 201 209 Validates dates represented as strings. 210 211 ### mtValidatorCuil 212 213 Validates a CUIL/CUIT from a String 214 215 ### mtValidatorCuilExtended 216 217 Validates a CUIL/CUIT from a string made by mtWidgetFormCuil 202 218 203 219 ##### Usage plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/dcWidgetFormActivator.class.php
r31924 r32250 87 87 if (call_user_func($options['evaluate_method'], self::filterValues($dependant_values, $options['observed_boolean_ids']), isset($options['evaluate_method_extra_params'])? $options['evaluate_method_extra_params'] : null)) 88 88 { 89 return javascript_tag("jQuery('#".$options['id']."').removeAttr('disabled') ;");89 return javascript_tag("jQuery('#".$options['id']."').removeAttr('disabled').change();"); 90 90 } 91 91 else 92 92 { 93 return javascript_tag("jQuery('#".$options['id']."'). attr('disabled', 'disabled');");93 return javascript_tag("jQuery('#".$options['id']."').children('option:selected').removeAttr('selected').removeAttr('value').change(); jQuery('#".$options['id']."').attr('disabled', 'disabled')"); 94 94 } 95 95 } plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/dcWidgetFormJQueryDependence.class.php
r31274 r32250 30 30 * * no_value_text: Text to be shown when this widget can not be rendered 31 31 * because observed_widget_id has no value yet 32 * 33 * * observed_can_be_empty_ids: Array of html ids of inputs that, when empty, the 'no_value_text' won't be shown. 32 34 * 33 35 * @author Christian A. Rodriguez <car at cespi.unlp.edu.ar> … … 56 58 $this->addOption('event','change'); 57 59 $this->addOption('observed_boolean_ids',array()); 60 $this->addOption('observed_can_be_empty_ids', array()); 58 61 $this->addOption('loading_image',image_tag('/dcReloadedFormExtraPlugin/images/ajax-loader.gif',array('class'=>'ajax-loader-image', 'alt_title'=>'loading'))); 59 62 $this->addOption('no_value_text','Please select a dependant value to update'); … … 92 95 foreach ($dependant_values as $key=>$value) 93 96 { 94 if ( !in_array($key,$this->getOption('observed_boolean_ids')) && !empty($value)) 97 if (!in_array($key,$this->getOption('observed_boolean_ids')) 98 && (!empty($value) || in_array($key, $this->getOption('observed_can_be_empty_ids')))) 95 99 { 96 100 $render_widget=true; plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/dcWidgetFormJQueryPropelDependence.class.php
r31274 r32250 20 20 $this->addRequiredOption('related_column'); 21 21 $this->addOption('on_change',array(__CLASS__,'updateColumn')); 22 $this->addOption('observed_is_multiple', array()); 23 $this->addOption('criteria', null); 22 24 } 23 25 … … 30 32 static public function updateColumn(dcWidgetFormJQueryDependence $widget_dependece,$values) 31 33 { 34 $multiple = $widget_dependece->getOption('observed_is_multiple'); 32 35 $widget = $widget_dependece->getOption('widget'); 33 36 $c=$widget->hasOption('criteria')?$widget->getOption('criteria'):null; 34 37 $c=is_null($c)?new Criteria():$c; 35 foreach ($widget_dependece->getOption('related_column') as $id =>$column)38 foreach ($widget_dependece->getOption('related_column') as $id => $column) 36 39 { 37 40 if (!array_key_exists($id, $values)) 38 throw new LogicException ("Index $id not found in received values"); 41 { 42 throw new LogicException ("Index $id not found in received values"); 43 } 39 44 if (!empty($values[$id])) 40 45 { 41 $c->addAnd($column,$values[$id]); 46 if (isset($multiple[$id]) && $multiple[$id]) 47 { 48 $c->addAnd($column, $values[$id], Criteria::IN); 49 } 50 else 51 { 52 $c->addAnd($column, $values[$id]); 53 } 42 54 } 43 55 } plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/mtWidgetFormWrapper.class.php
r31946 r32250 15 15 * 'ajax_loader_css' : the CSS of the Ajax loader. Defaults to: 'display: none; width: 20px; margin-left: 5px; margin-right: 5px; float: right;' 16 16 * 'ajax_loader_id' : the id ot the ajax loader. Defaults to: "wrapper_loader_${input_id}" 17 * 'ajax_loader_url' : inside symfony path to the ajax loader image. Defaults to '/dc FormExtraPlugin/images/ajax-loader.gif'.17 * 'ajax_loader_url' : inside symfony path to the ajax loader image. Defaults to '/dcReloadedFormExtraPlugin/images/ajax-loader.gif'. 18 18 * 'provide_ajax_loader' : if set to true, the ajax loader will be drawn. 19 19 * … … 30 30 $this->addOption('ajax_loader_css', 'display: none; width: 20px; margin-left: 5px; margin-right: 5px; float: right;'); 31 31 $this->addOption('ajax_loader_id', null); 32 $this->addOption('ajax_loader_url', '/dc FormExtraPlugin/images/ajax-loader.gif');32 $this->addOption('ajax_loader_url', '/dcReloadedFormExtraPlugin/images/ajax-loader.gif'); 33 33 $this->addOption('provide_ajax_loader', false); 34 34 parent::configure($options, $attributes); plugins/dcReloadedFormExtraPlugin/trunk/modules/dc_ajax/actions/actions.class.php
r31922 r32250 153 153 return $this->renderPartial("dc_ajax/pmWidgetFormPropelJQuerySearch"); 154 154 } 155 156 public function executeMtWidgetFormEmbedAdd(sfWebRequest $request) 157 { 158 $parentFormName = mtWidgetFormEmbed::decode($request->getParameter('parent_form_name')); 159 $childFormName = mtWidgetFormEmbed::decode($request->getParameter('child_form_name')); 160 $formCreationMethod = mtWidgetFormEmbed::decode($request->getParameter('form_creation_method')); 161 $formCreationMethodParams = mtWidgetFormEmbed::decode($request->getParameter('form_creation_method_params')); 162 $childFormTitleMethod = mtWidgetFormEmbed::decode($request->getParameter('title_method')); 163 $this->widgetId = mtWidgetFormEmbed::decode($request->getParameter('widget_id')); 164 $this->formFormatter = mtWidgetFormEmbed::decode($request->getParameter('form_formatter')); 165 $this->rendererClass = $request->getParameter('renderer_class'); 166 $this->images = mtWidgetFormEmbed::decode($request->getParameter('images')); 167 $this->childCount = $request->getParameter('child_count'); 168 169 if (!empty($childFormTitleMethod)) 170 { 171 if (is_string($childFormTitleMethod)) 172 { 173 $this->title = $childFormTitleMethod; 174 } 175 elseif (is_array($childFormTitleMethod)) 176 { 177 $this->title = call_user_func($childFormTitleMethod); 178 } 179 } 180 181 $this->form = call_user_func($formCreationMethod, $formCreationMethodParams); 182 $this->form->getWidgetSchema()->setNameFormat("$parentFormName"."[".$childFormName."_".$this->childCount."][%s]"); 183 $this->form->getWidgetSchema()->setFormFormatterName($this->formFormatter); 184 $this->formTitle = $this->getFormTitle($this->form, $childFormTitleMethod); 185 186 unset($this->form['_csrf_token']); 187 } 188 189 protected function getFormTitle($form, $childFormTitleMethod) 190 { 191 $method = $childFormTitleMethod; 192 if (!empty($method)) 193 { 194 if (method_exists($form, $method)) 195 { 196 return $form->$method(); 197 return call_user_func(array($form, $method)); 198 } 199 return $method; 200 } 201 return ''; 202 } 203 155 204 } plugins/dcReloadedFormExtraPlugin/trunk/web/js/dc_widget_form_jquery_dependence.js
r31346 r32250 43 43 jQuery.each(widget.observed_array, function () 44 44 { 45 var input = jQuery("#"+this).is(':checkbox'); 46 if (!input) 47 { 45 48 observed_values[this]= jQuery("#"+this).val(); 49 } 50 else 51 { 52 observed_values[this]=jQuery("#"+this).is(':checked'); 53 } 46 54 }); 47 55 jQuery.ajax(