Development

Changeset 29201

You must first sign up to be able to contribute.

Changeset 29201

Show
Ignore:
Timestamp:
04/19/10 06:50:29 (3 years ago)
Author:
jaimesuez
Message:

EMBEDDED FORMS:

Al agregarse embedded forms

Existentes aparece solo el link (si hay with_hide)
Nuevas aparecen expandidas

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/actions/actions.class.php

    r29199 r29201  
    9595    $number = intval($request->getParameter("number")); 
    9696 
    97     //"module" se refiere al modulo actual en el que se est√° (por ejemplo feligr√©s) 
     97    //"module" se refiere al modulo actual en el que se esta (por ejemplo feligres) 
    9898    $module_class = module_to_class($request->getParameter("module_name")); 
    9999    $module_form = class_to_form($module_class); 
     
    101101    $widget_name = $request->getParameter("widget_name"); 
    102102    $create_partial = $request->getParameter("create_partial"); 
     103    $with_hide = $request->getParameter("with_hide"); 
    103104 
    104105    $id_related_object = $request->getParameter("id_related_object"); 
  • plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_add_embedded_form.php

    r29200 r29201  
    99$columns = $form->getWidget($widget_name)->getOption('columns'); 
    1010$thumbnail = $form->getWidget($widget_name)->getOption('thumbnail'); 
     11$with_hide = $form->getWidget($widget_name)->getOption('with_hide'); 
     12 
     13if ($id_related_object > 0 && $with_hide == true) 
     14{ 
     15  $with_undo = true; 
     16} 
     17else 
     18{ 
     19  $with_undo = false; 
     20} 
    1121 
    1222?> 
     
    1424 
    1525<!--###############################  100% igual, refactorizar ################################## --> 
     26<!--###############################  PARTIAL DEL LINK AL FORMULARIO (solo si existe el objeto y no es nuevo) ################################## --> 
     27<?php if ($with_undo): ?> 
     28<div id="<?php echo $embedded_name ?>_related_object_form_name_<?php echo $number ?>" 
     29     class="<?php echo $embedded_name ?>_related_object_form_new_<?php echo $number ?> content"> 
     30  <a id="<?php echo $embedded_name ?>_related_object_form_link_<?php echo $number ?>" style="font-weight:bold;" 
     31     class="<?php echo $embedded_name ?>_related_object_form_new_<?php echo $number ?>"> 
     32 
     33    <!--  thumbnail opcional  --> 
     34      <?php echo include_partial("ajax_form/thumbnail", array("thumbnail_info" => $thumbnail, "object" => Doctrine::getTable(module_to_class($widget_module))->find($form[$embedded_name][$number]["id"]->getValue()))) ?> 
     35 
     36 
     37      <?php foreach ($columns as $column): ?> 
     38        <?php echo $form[$embedded_name][$number][$column]->getValue() . ' ' ?> 
     39      <?php endforeach ?> 
     40  </a> 
     41</div> 
     42<?php endif ?> 
     43 
     44 
     45 
    1646<!--###############################  PARTIAL DEL FORMULARIO  ################################## --> 
    17 <div class="sf_admin_form_field_<?php echo $embedded_name ?>" 
     47<div class="sf_admin_form_field_<?php echo $embedded_name ?>" style="<?php echo $with_undo ? "display:none" : "" ?>" 
    1848     id="<?php echo $embedded_name ?>_related_object_form_new_<?php echo $number ?>"> 
    1949       <?php echo $form[$embedded_name][$number]->renderError() ?> 
     
    2151  <div class="content"> 
    2252    <!--  thumbnail opcional  --> 
    23     <?php echo include_partial("ajax_form/thumbnail", array("thumbnail_info" => $thumbnail, "object" => Doctrine::getTable(module_to_class($widget_module))->find((int)$id_related_object) )) ?> 
     53    <?php echo include_partial("ajax_form/thumbnail", array("thumbnail_info" => $thumbnail, "object" => Doctrine::getTable(module_to_class($widget_module))->find((int) $id_related_object) )) ?> 
    2454 
    2555    <!--  La clase del link es el id del objeto que tiene que deshacer  --> 
    26     <a class="<?php echo $embedded_name ?>_related_object_form_new_<?php echo $number ?>" style="cursor:pointer" 
     56 
     57    <?php if ($with_undo): ?> 
     58      <?php echo _tag("a#{$embedded_name}_related_object_form_hide_{$number}.{$embedded_name}_related_object_form_new_{$number}.s16_arrow_down title=Ocultar", 'Ocultar') ?> 
     59    <?php endif ?> 
     60    <a class="<?php echo $embedded_name ?>_related_object_form_new_<?php echo $number ?>" 
    2761       id="<?php echo $embedded_name ?>_related_object_form_undo_<?php echo $number ?>"> 
    2862      <img align="top" src="/themeAdmin/images/icons/undo.gif"/>Deshacer 
     
    4478      id = $(this).attr("class"); 
    4579      $("#" + id).replaceWith(''); 
     80      $("." + id).replaceWith(''); 
    4681 
    4782      //mostramos el "autocomplete" y el "agregar" por si es y se borraron anteriormente 
     
    5287</script> 
    5388 
     89<!--###############################  JAVASCRIPT PARA OCULTAR UNA NUEVA EMBEDDED FORM DESPLEGADA ################################## --> 
     90<script type="text/javascript"> 
     91 
     92  $().ready(function() 
     93  { 
     94    $('a[id^="<?php echo $embedded_name ?>_related_object_form_hide"]').click(function() 
     95    { 
     96      //la clase del link es el id del objeto a deshacer 
     97      id = $(this).attr("class").replace("s16_arrow_down",""); 
     98      $("#" + id).hide(); 
     99      $("." + id).show(); 
     100    }); 
     101  }); 
     102</script> 
     103 
     104 
     105<!--###############################  JAVASCRIPT PARA MOSTRAR EL FORMULARIO AL APRETAR EL LINK  ################################## --> 
     106<script type="text/javascript"> 
     107 
     108  $().ready(function() 
     109  { 
     110    $('a[id^="<?php echo $embedded_name ?>_related_object_form_link"]').click(function() 
     111    { 
     112      //la clase del link es el id del objeto a deshacer 
     113      id = $(this).attr("class"); 
     114 
     115      $("#" + id).show(); 
     116      $(this).hide(); 
     117    }); 
     118  }); 
     119</script> 
     120 
     121 
     122 
    54123 
    55124<!--###############################  ASIGNA EL VALOR AL PRIMER CAMPO DE COLUMNS (excepto cuando es de un objeto ya existente) ################################## --> 
    56125<script type="text/javascript"> 
    57126 
    58   if ($("#<?php echo $module . '_form_' . $embedded_name .'_' . $number.'_'.$columns[0]?>").val().length == 0) 
     127  if ($("#<?php echo $module . '_form_' . $embedded_name . '_' . $number . '_' . $columns[0]?>").val().length == 0) 
    59128  { 
    60     $("#<?php echo $module . '_form_' . $embedded_name .'_' . $number.'_'.$columns[0]?>").val('<?php echo $value != 'undefined' ? $value : '' ?>'); 
     129    $("#<?php echo $module . '_form_' . $embedded_name . '_' . $number . '_' . $columns[0]?>").val('<?php echo $value != 'undefined' ? $value : '' ?>'); 
    61130  } 
    62131 
    63132  //lo selecciona 
    64   $("#<?php echo $module . '_form_' . $embedded_name .'_' . $number.'_'.$columns[0]?>").focus(); 
    65   $("#<?php echo $module . '_form_' . $embedded_name .'_' . $number.'_'.$columns[0]?>").select(); 
     133  $("#<?php echo $module . '_form_' . $embedded_name . '_' . $number . '_' . $columns[0]?>").focus(); 
     134  $("#<?php echo $module . '_form_' . $embedded_name . '_' . $number . '_' . $columns[0]?>").select(); 
    66135</script> 
  • plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_autocomplete_with_embedded_forms_default.php

    r29200 r29201  
    114114        'thumbnail' => $thumbnail, 
    115115        'create_partial' => $create_partial, 
     116        "with_hide" => $with_hide, 
    116117)); 
    117118?> 
  • plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_embedded_form_js.php

    r29200 r29201  
    7474        create_partial: "<?php echo $create_partial ?>", 
    7575        value: value, 
    76         id_related_object: id_related_object 
     76        id_related_object: id_related_object, 
    7777      }, 
    7878      async: false