Development

Changeset 32250

You must first sign up to be able to contribute.

Changeset 32250

Show
Ignore:
Timestamp:
03/13/11 21:03:52 (2 years ago)
Author:
mtorres
Message:

Options and fixes added to dcWidgetFormJQueryDependence, added widgets and validators for argentinian cui[l|t], the dcWidgetFormActivator now cleans the value and sends the 'change' signal on the disabled widget, added mtWidgetFormEmbed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/dcReloadedFormExtraPlugin/trunk/README

    r31922 r32250  
    194194    [php] 
    195195    $this->setWidget("date", new mtWidgetFormInputDate()); 
    196      
     196 
     197### mtWidgetFormEmbed 
     198 
     199Widgets 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 
     203Represents an Argetine CUIL/CUIT 
     204 
    197205## Validators 
    198206 
     
    200208 
    201209Validates dates represented as strings. 
     210 
     211### mtValidatorCuil 
     212 
     213Validates a CUIL/CUIT from a String 
     214 
     215### mtValidatorCuilExtended 
     216 
     217Validates a CUIL/CUIT from a string made by mtWidgetFormCuil 
    202218 
    203219##### Usage 
  • plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/dcWidgetFormActivator.class.php

    r31924 r32250  
    8787    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)) 
    8888    { 
    89       return javascript_tag("jQuery('#".$options['id']."').removeAttr('disabled');"); 
     89      return javascript_tag("jQuery('#".$options['id']."').removeAttr('disabled').change();"); 
    9090    } 
    9191    else 
    9292    { 
    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')"); 
    9494    } 
    9595  } 
  • plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/dcWidgetFormJQueryDependence.class.php

    r31274 r32250  
    3030 *  * no_value_text:    Text to be shown when this widget can not be rendered 
    3131 *                      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. 
    3234 * 
    3335 * @author Christian A. Rodriguez <car at cespi.unlp.edu.ar> 
     
    5658    $this->addOption('event','change'); 
    5759    $this->addOption('observed_boolean_ids',array()); 
     60    $this->addOption('observed_can_be_empty_ids', array()); 
    5861    $this->addOption('loading_image',image_tag('/dcReloadedFormExtraPlugin/images/ajax-loader.gif',array('class'=>'ajax-loader-image', 'alt_title'=>'loading'))); 
    5962    $this->addOption('no_value_text','Please select a dependant value to update'); 
     
    9295    foreach ($dependant_values as $key=>$value) 
    9396    { 
    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')))) 
    9599      { 
    96100        $render_widget=true; 
  • plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/dcWidgetFormJQueryPropelDependence.class.php

    r31274 r32250  
    2020    $this->addRequiredOption('related_column'); 
    2121    $this->addOption('on_change',array(__CLASS__,'updateColumn')); 
     22    $this->addOption('observed_is_multiple', array()); 
     23    $this->addOption('criteria', null); 
    2224  } 
    2325 
     
    3032  static public function updateColumn(dcWidgetFormJQueryDependence $widget_dependece,$values) 
    3133  { 
     34    $multiple = $widget_dependece->getOption('observed_is_multiple'); 
    3235    $widget = $widget_dependece->getOption('widget'); 
    3336    $c=$widget->hasOption('criteria')?$widget->getOption('criteria'):null; 
    3437    $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) 
    3639    { 
    3740      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      } 
    3944      if (!empty($values[$id])) 
    4045      { 
    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        } 
    4254      } 
    4355    } 
  • plugins/dcReloadedFormExtraPlugin/trunk/lib/widget/mtWidgetFormWrapper.class.php

    r31946 r32250  
    1515 *  'ajax_loader_css' : the CSS of the Ajax loader. Defaults to: 'display: none; width: 20px; margin-left: 5px; margin-right: 5px; float: right;' 
    1616 *  '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 '/dcFormExtraPlugin/images/ajax-loader.gif'. 
     17 *  'ajax_loader_url' : inside symfony path to the ajax loader image. Defaults to '/dcReloadedFormExtraPlugin/images/ajax-loader.gif'. 
    1818 *  'provide_ajax_loader' : if set to true, the ajax loader will be drawn. 
    1919 * 
     
    3030    $this->addOption('ajax_loader_css', 'display: none; width: 20px; margin-left: 5px; margin-right: 5px; float: right;'); 
    3131    $this->addOption('ajax_loader_id', null); 
    32     $this->addOption('ajax_loader_url',  '/dcFormExtraPlugin/images/ajax-loader.gif'); 
     32    $this->addOption('ajax_loader_url',  '/dcReloadedFormExtraPlugin/images/ajax-loader.gif'); 
    3333    $this->addOption('provide_ajax_loader', false); 
    3434    parent::configure($options, $attributes); 
  • plugins/dcReloadedFormExtraPlugin/trunk/modules/dc_ajax/actions/actions.class.php

    r31922 r32250  
    153153    return $this->renderPartial("dc_ajax/pmWidgetFormPropelJQuerySearch"); 
    154154  } 
     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   
    155204} 
  • plugins/dcReloadedFormExtraPlugin/trunk/web/js/dc_widget_form_jquery_dependence.js

    r31346 r32250  
    4343    jQuery.each(widget.observed_array, function () 
    4444    { 
     45      var input = jQuery("#"+this).is(':checkbox'); 
     46      if (!input) 
     47      { 
    4548        observed_values[this]= jQuery("#"+this).val(); 
     49      } 
     50      else 
     51      { 
     52        observed_values[this]=jQuery("#"+this).is(':checked'); 
     53      } 
    4654    }); 
    4755    jQuery.ajax(