Author: jaimesuez
Date: 2010-04-19 06:50:29 +0200 (Mon, 19 Apr 2010)
New Revision: 29201

Modified:
   plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/actions/actions.class.php
   
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_add_embedded_form.php
   
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_autocomplete_with_embedded_forms_default.php
   
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_embedded_form_js.php
Log:
EMBEDDED FORMS:
  Al agregarse embedded forms
    Existentes aparece solo el link (si hay with_hide)
    Nuevas aparecen expandidas


Modified: 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/actions/actions.class.php
===================================================================
--- 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/actions/actions.class.php    
    2010-04-19 03:22:32 UTC (rev 29200)
+++ 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/actions/actions.class.php    
    2010-04-19 04:50:29 UTC (rev 29201)
@@ -94,12 +94,13 @@
 
     $number = intval($request->getParameter("number"));
 
-    //"module" se refiere al modulo actual en el que se est√° (por ejemplo 
feligrés)
+    //"module" se refiere al modulo actual en el que se esta (por ejemplo 
feligres)
     $module_class = module_to_class($request->getParameter("module_name"));
     $module_form = class_to_form($module_class);
 
     $widget_name = $request->getParameter("widget_name");
     $create_partial = $request->getParameter("create_partial");
+    $with_hide = $request->getParameter("with_hide");
 
     $id_related_object = $request->getParameter("id_related_object");
     $value = $id_related_object > 0 ? '' : $request->getParameter("value");

Modified: 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_add_embedded_form.php
===================================================================
--- 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_add_embedded_form.php
 2010-04-19 03:22:32 UTC (rev 29200)
+++ 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_add_embedded_form.php
 2010-04-19 04:50:29 UTC (rev 29201)
@@ -8,22 +8,56 @@
 $is_autocomplete = 
$form->getWidget($widget_name)->getOption('is_autocomplete');
 $columns = $form->getWidget($widget_name)->getOption('columns');
 $thumbnail = $form->getWidget($widget_name)->getOption('thumbnail');
+$with_hide = $form->getWidget($widget_name)->getOption('with_hide');
 
+if ($id_related_object > 0 && $with_hide == true)
+{
+  $with_undo = true;
+}
+else
+{
+  $with_undo = false;
+}
+
 ?>
 
 
 <!--###############################  100% igual, refactorizar 
################################## -->
+<!--###############################  PARTIAL DEL LINK AL FORMULARIO (solo si 
existe el objeto y no es nuevo) ################################## -->
+<?php if ($with_undo): ?>
+<div id="<?php echo $embedded_name ?>_related_object_form_name_<?php echo 
$number ?>"
+     class="<?php echo $embedded_name ?>_related_object_form_new_<?php echo 
$number ?> content">
+  <a id="<?php echo $embedded_name ?>_related_object_form_link_<?php echo 
$number ?>" style="font-weight:bold;"
+     class="<?php echo $embedded_name ?>_related_object_form_new_<?php echo 
$number ?>">
+
+    <!--  thumbnail opcional  -->
+      <?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())))
 ?>
+
+
+      <?php foreach ($columns as $column): ?>
+        <?php echo $form[$embedded_name][$number][$column]->getValue() . ' ' ?>
+      <?php endforeach ?>
+  </a>
+</div>
+<?php endif ?>
+
+
+
 <!--###############################  PARTIAL DEL FORMULARIO  
################################## -->
-<div class="sf_admin_form_field_<?php echo $embedded_name ?>"
+<div class="sf_admin_form_field_<?php echo $embedded_name ?>" style="<?php 
echo $with_undo ? "display:none" : "" ?>"
      id="<?php echo $embedded_name ?>_related_object_form_new_<?php echo 
$number ?>">
        <?php echo $form[$embedded_name][$number]->renderError() ?>
 
   <div class="content">
     <!--  thumbnail opcional  -->
-    <?php echo include_partial("ajax_form/thumbnail", array("thumbnail_info" 
=> $thumbnail, "object" => 
Doctrine::getTable(module_to_class($widget_module))->find((int)$id_related_object)
 )) ?>
+    <?php echo include_partial("ajax_form/thumbnail", array("thumbnail_info" 
=> $thumbnail, "object" => 
Doctrine::getTable(module_to_class($widget_module))->find((int) 
$id_related_object) )) ?>
 
     <!--  La clase del link es el id del objeto que tiene que deshacer  -->
-    <a class="<?php echo $embedded_name ?>_related_object_form_new_<?php echo 
$number ?>" style="cursor:pointer"
+
+    <?php if ($with_undo): ?>
+      <?php echo 
_tag("a#{$embedded_name}_related_object_form_hide_{$number}.{$embedded_name}_related_object_form_new_{$number}.s16_arrow_down
 title=Ocultar", 'Ocultar') ?>
+    <?php endif ?>
+    <a class="<?php echo $embedded_name ?>_related_object_form_new_<?php echo 
$number ?>"
        id="<?php echo $embedded_name ?>_related_object_form_undo_<?php echo 
$number ?>">
       <img align="top" src="/themeAdmin/images/icons/undo.gif"/>Deshacer
     </a>
@@ -43,6 +77,7 @@
       //la clase del link es el id del objeto a deshacer
       id = $(this).attr("class");
       $("#" + id).replaceWith('');
+      $("." + id).replaceWith('');
 
       //mostramos el "autocomplete" y el "agregar" por si es y se borraron 
anteriormente
       $("#autocomplete_<?php echo $module ?>_form_<?php echo $widget_name 
?>").show();
@@ -51,16 +86,50 @@
   });
 </script>
 
+<!--###############################  JAVASCRIPT PARA OCULTAR UNA NUEVA 
EMBEDDED FORM DESPLEGADA ################################## -->
+<script type="text/javascript">
 
+  $().ready(function()
+  {
+    $('a[id^="<?php echo $embedded_name 
?>_related_object_form_hide"]').click(function()
+    {
+      //la clase del link es el id del objeto a deshacer
+      id = $(this).attr("class").replace("s16_arrow_down","");
+      $("#" + id).hide();
+      $("." + id).show();
+    });
+  });
+</script>
+
+
+<!--###############################  JAVASCRIPT PARA MOSTRAR EL FORMULARIO AL 
APRETAR EL LINK  ################################## -->
+<script type="text/javascript">
+
+  $().ready(function()
+  {
+    $('a[id^="<?php echo $embedded_name 
?>_related_object_form_link"]').click(function()
+    {
+      //la clase del link es el id del objeto a deshacer
+      id = $(this).attr("class");
+
+      $("#" + id).show();
+      $(this).hide();
+    });
+  });
+</script>
+
+
+
+
 <!--###############################  ASIGNA EL VALOR AL PRIMER CAMPO DE 
COLUMNS (excepto cuando es de un objeto ya existente) 
################################## -->
 <script type="text/javascript">
 
-  if ($("#<?php echo $module . '_form_' . $embedded_name .'_' . 
$number.'_'.$columns[0]?>").val().length == 0)
+  if ($("#<?php echo $module . '_form_' . $embedded_name . '_' . $number . '_' 
. $columns[0]?>").val().length == 0)
   {
-    $("#<?php echo $module . '_form_' . $embedded_name .'_' . 
$number.'_'.$columns[0]?>").val('<?php echo $value != 'undefined' ? $value : '' 
?>');
+    $("#<?php echo $module . '_form_' . $embedded_name . '_' . $number . '_' . 
$columns[0]?>").val('<?php echo $value != 'undefined' ? $value : '' ?>');
   }
 
   //lo selecciona
-  $("#<?php echo $module . '_form_' . $embedded_name .'_' . 
$number.'_'.$columns[0]?>").focus();
-  $("#<?php echo $module . '_form_' . $embedded_name .'_' . 
$number.'_'.$columns[0]?>").select();
+  $("#<?php echo $module . '_form_' . $embedded_name . '_' . $number . '_' . 
$columns[0]?>").focus();
+  $("#<?php echo $module . '_form_' . $embedded_name . '_' . $number . '_' . 
$columns[0]?>").select();
 </script>

Modified: 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_autocomplete_with_embedded_forms_default.php
===================================================================
--- 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_autocomplete_with_embedded_forms_default.php
  2010-04-19 03:22:32 UTC (rev 29200)
+++ 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_autocomplete_with_embedded_forms_default.php
  2010-04-19 04:50:29 UTC (rev 29201)
@@ -113,6 +113,7 @@
         'credentials' => $credentials,
         'thumbnail' => $thumbnail,
         'create_partial' => $create_partial,
+        "with_hide" => $with_hide,
 ));
 ?>
 

Modified: 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_embedded_form_js.php
===================================================================
--- 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_embedded_form_js.php
  2010-04-19 03:22:32 UTC (rev 29200)
+++ 
plugins/sfDoctrineAjaxFormPlugin/modules/ajax_form/templates/_embedded_form_js.php
  2010-04-19 04:50:29 UTC (rev 29201)
@@ -73,7 +73,7 @@
         widget_name: "<?php echo $widget_name ?>",
         create_partial: "<?php echo $create_partial ?>",
         value: value,
-        id_related_object: id_related_object
+        id_related_object: id_related_object,
       },
       async: false
     }).responseText;

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" 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/symfony-svn?hl=en.

Reply via email to