diff --git a/app/Resources/views/planificacionseccion/new.html.twig b/app/Resources/views/planificacionseccion/new.html.twig
index 85ca9b0..c772437 100644
--- a/app/Resources/views/planificacionseccion/new.html.twig
+++ b/app/Resources/views/planificacionseccion/new.html.twig
@@ -12,6 +12,10 @@
+
+
{{ form_end(form) }}
@@ -29,55 +33,102 @@
var $collectionHolder;
// setup an "add a tag" link
+ var $addEspecificoLink = $('Añadir Objetivos Especificos');
var $addContenidoLink = $('Añadir conceptos');
var $RemoveContenidoLink = $('Quitar Conceptos');
- var $newLinkLi = $('').append($addContenidoLink);
+ var $newLinkLiContenido = $('').append($addContenidoLink);
+ var $newLinkLiEspecifico = $('').append($addEspecificoLink);
//$newLinkLi. = $('').append($RemoveContenidoLink);
jQuery(document).ready(function() {
// Get the ul that holds the collection of tags
- $collectionHolder = $('ul.contenido');
-
+ $contenidoHolder = $('ul.contenido');
+ $especificoHolder = $('ul.objetivoEspecifico');
// add the "add a tag" anchor and li to the tags ul
- $collectionHolder.append($newLinkLi);
+ $contenidoHolder.append($newLinkLiContenido);
+ $especificoHolder.append($newLinkLiEspecifico);
// count the current form inputs we have (e.g. 2), use that as the new
// index when inserting a new item (e.g. 2)
- $collectionHolder.data('index', $collectionHolder.find(':input').length);
+ $contenidoHolder.data('index', $contenidoHolder.find(':input').length);
+ $especificoHolder.data('index', $especificoHolder.find(':input').length);
$addContenidoLink.on('click', function(e) {
// prevent the link from creating a "#" on the URL
e.preventDefault();
// add a new tag form (see next code block)
- addContenidoForm($collectionHolder, $newLinkLi);
+ addContenidoForm($contenidoHolder, $newLinkLiContenido);
+ });
+
+ $addEspecificoLink.on('click', function(e) {
+ // prevent the link from creating a "#" on the URL
+ e.preventDefault();
+
+ // add a new tag form (see next code block)
+ addEspecificoForm($especificoHolder, $newLinkLiEspecifico);
});
- function addContenidoForm($collectionHolder, $newLinkLi) {
+ function addContenidoForm($contenidoHolder, $newLinkLiContenido) {
+ // Get the data-prototype explained earlier
+ var prototype = $contenidoHolder.data('prototype');
+
+ // get the new index
+ var index = $contenidoHolder.data('index');
+
+ // Replace '$$name$$' in the prototype's HTML to
+ // instead be a number based on how many items we have
+ var newFormContenido = prototype.replace(/__name__/g, index);
+
+ // increase the index with one for the next item
+ $contenidoHolder.data('index', index + 1);
+
+ // Display the form in the page in an li, before the "Add a tag" link li
+ var $newFormLiContenido = $('').append(newFormContenido);
+
+ // also add a remove button, just for this example
+ $newFormLiContenido.append('x');
+
+ $newLinkLiContenido.before($newFormLiContenido);
+
+ // handle the removal, just for this example
+ $('.remove-tag').click(function(e) {
+ e.preventDefault();
+
+ $(this).parent().remove();
+
+ return false;
+ });
+
+
+ }
+
+
+ function addEspecificoForm($especificoHolder, $newLinkLiEspecifico) {
// Get the data-prototype explained earlier
- var prototype = $collectionHolder.data('prototype');
+ var prototype = $especificoHolder.data('prototype');
// get the new index
- var index = $collectionHolder.data('index');
+ var index = $especificoHolder.data('index');
// Replace '$$name$$' in the prototype's HTML to
// instead be a number based on how many items we have
- var newForm = prototype.replace(/__name__/g, index);
+ var newFormEspecifico = prototype.replace(/__name__/g, index);
// increase the index with one for the next item
- $collectionHolder.data('index', index + 1);
+ $especificoHolder.data('index', index + 1);
// Display the form in the page in an li, before the "Add a tag" link li
- var $newFormLi = $('').append(newForm);
+ var $newFormLiEspecifico = $('').append(newFormEspecifico);
// also add a remove button, just for this example
- $newFormLi.append('x');
+ $newFormLiEspecifico.append('x');
- $newLinkLi.before($newFormLi);
+ $newLinkLiEspecifico.before($newFormLiEspecifico);
// handle the removal, just for this example
$('.remove-tag').click(function(e) {
diff --git a/src/AppBundle/Controller/PlanificacionSeccionController.php b/src/AppBundle/Controller/PlanificacionSeccionController.php
index 90505d9..946b953 100644
--- a/src/AppBundle/Controller/PlanificacionSeccionController.php
+++ b/src/AppBundle/Controller/PlanificacionSeccionController.php
@@ -63,6 +63,11 @@ class PlanificacionSeccionController extends Controller
$contenido->setPlanificacionSeccionId($planificacionSeccion);
$seccion->addPlanificacion($planificacionSeccion);
}
+
+ foreach($planificacionSeccion->getObjetivoEspecifico() as $especifico){
+ $especifico->setPlanificacionSeccionId($planificacionSeccion);
+ }
+
//var_dump($seccion->getPlanificacion()->count()); exit;
$em = $this->getDoctrine()->getManager();
$em->persist($planificacionSeccion);
diff --git a/src/AppBundle/Entity/PlanificacionSeccion.php b/src/AppBundle/Entity/PlanificacionSeccion.php
index 47f9bc6..8f9be82 100644
--- a/src/AppBundle/Entity/PlanificacionSeccion.php
+++ b/src/AppBundle/Entity/PlanificacionSeccion.php
@@ -35,7 +35,8 @@ class PlanificacionSeccion
/**
- * @ORM\OneToMany(targetEntity="PlanificacionSeccionEspecifico", mappedBy="idPlanificacionEspecifico")
+ * @ORM\OneToMany(targetEntity="PlanificacionSeccionEspecifico", mappedBy="planificacionSeccionId",cascade={"all"})
+ * @var \Doctrine\Common\Collections\ArrayCollection
*/
private $objetivoEspecifico;
@@ -169,38 +170,7 @@ class PlanificacionSeccion
return $this->idtemaUc;
}
- /**
- * Add objetivoEspecifico
- *
- * @param \AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico
- * @return PlanificacionSeccion
- */
- public function addObjetivoEspecifico(\AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico)
- {
- $this->objetivoEspecifico[] = $objetivoEspecifico;
-
- return $this;
- }
-
- /**
- * Remove objetivoEspecifico
- *
- * @param \AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico
- */
- public function removeObjetivoEspecifico(\AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico)
- {
- $this->objetivoEspecifico->removeElement($objetivoEspecifico);
- }
-
- /**
- * Get objetivoEspecifico
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getObjetivoEspecifico()
- {
- return $this->objetivoEspecifico;
- }
+
/**
* Add contenido
@@ -390,4 +360,37 @@ class PlanificacionSeccion
{
return $this->fechaUltimaActualizacion;
}
+
+ /**
+ * Add objetivoEspecifico
+ *
+ * @param \AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico
+ * @return PlanificacionSeccion
+ */
+ public function addObjetivoEspecifico(\AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico)
+ {
+ $this->objetivoEspecifico[] = $objetivoEspecifico;
+
+ return $this;
+ }
+
+ /**
+ * Remove objetivoEspecifico
+ *
+ * @param \AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico
+ */
+ public function removeObjetivoEspecifico(\AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico)
+ {
+ $this->objetivoEspecifico->removeElement($objetivoEspecifico);
+ }
+
+ /**
+ * Get objetivoEspecifico
+ *
+ * @return \Doctrine\Common\Collections\Collection
+ */
+ public function getObjetivoEspecifico()
+ {
+ return $this->objetivoEspecifico;
+ }
}
diff --git a/src/AppBundle/Entity/PlanificacionSeccion.php~ b/src/AppBundle/Entity/PlanificacionSeccion.php~
index 0286d06..721f083 100644
--- a/src/AppBundle/Entity/PlanificacionSeccion.php~
+++ b/src/AppBundle/Entity/PlanificacionSeccion.php~
@@ -9,8 +9,8 @@ use Doctrine\ORM\Mapping as ORM;
*
* @ORM\Table(name="planificacion_seccion",
* uniqueConstraints=
- * {@ORM\UniqueConstraint(name="uq_tema_uc",
- * columns={"id_tema_uc"})
+ * {@ORM\UniqueConstraint(name="uq_tema_uc_seccion",
+ * columns={"id_tema_uc", "seccion_id"})
* },
* indexes={
* @ORM\Index(name="fki_id_tema_uc",
@@ -26,7 +26,7 @@ class PlanificacionSeccion
/**
* @var \AppBundle\Entity\UnidadCurricularVolumenTema
*
- * @ORM\ManyToOne(targetEntity="AppBundle\Entity\UnidadCurricularVolumenTema")
+ * @ORM\ManyToOne(targetEntity="AppBundle\Entity\UnidadCurricularVolumenTema", inversedBy="hasPlanificacion")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="id_tema_uc", referencedColumnName="id", nullable=false)
* })
@@ -35,13 +35,14 @@ class PlanificacionSeccion
/**
- * @ORM\OneToMany(targetEntity="PlanificacionSeccionEspecifico", mappedBy="idPlanificacionEspecifico")
+ * @ORM\OneToMany(targetEntity="PlanificacionSeccionEspecifico", mappedBy="planificacionSeccionId")
+ * @var \Doctrine\Common\Collections\ArrayCollection
*/
private $objetivoEspecifico;
/**
- * @ORM\OneToMany(targetEntity="PlanificacionSeccionContenido", mappedBy="PlanificacionSeccion",cascade={"persist", "remove"})
+ * @ORM\OneToMany(targetEntity="PlanificacionSeccionContenido", mappedBy="planificacionSeccionId", cascade={"all"})
* @var \Doctrine\Common\Collections\ArrayCollection
*/
private $contenido;
@@ -169,38 +170,7 @@ class PlanificacionSeccion
return $this->idtemaUc;
}
- /**
- * Add objetivoEspecifico
- *
- * @param \AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico
- * @return PlanificacionSeccion
- */
- public function addObjetivoEspecifico(\AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico)
- {
- $this->objetivoEspecifico[] = $objetivoEspecifico;
-
- return $this;
- }
-
- /**
- * Remove objetivoEspecifico
- *
- * @param \AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico
- */
- public function removeObjetivoEspecifico(\AppBundle\Entity\PlanificacionSeccionEspecifico $objetivoEspecifico)
- {
- $this->objetivoEspecifico->removeElement($objetivoEspecifico);
- }
-
- /**
- * Get objetivoEspecifico
- *
- * @return \Doctrine\Common\Collections\Collection
- */
- public function getObjetivoEspecifico()
- {
- return $this->objetivoEspecifico;
- }
+
/**
* Add contenido
@@ -210,7 +180,9 @@ class PlanificacionSeccion
*/
public function addContenido(\AppBundle\Entity\PlanificacionSeccionContenido $contenido)
{
+ $contenido->setPlanificacionSeccionId($this);
$this->contenido[] = $contenido;
+
return $this;
}
diff --git a/src/AppBundle/Entity/PlanificacionSeccionEspecifico.php b/src/AppBundle/Entity/PlanificacionSeccionEspecifico.php
index d2d1139..97605e5 100644
--- a/src/AppBundle/Entity/PlanificacionSeccionEspecifico.php
+++ b/src/AppBundle/Entity/PlanificacionSeccionEspecifico.php
@@ -7,16 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* PlanificacionSeccionEspecifico
*
- * @ORM\Table(name="planificacion_seccion_especifico",
- * uniqueConstraints=
- * {@ORM\UniqueConstraint(name="uq_planificacion_seccion_especifico",
- * columns={"id_planificacion_seccion"})
- * },
- * indexes={
- * @ORM\Index(name="fki_id_planificacion_especifico",
- * columns={"id_planificacion_seccion"})
- * }
- * )
+ * @ORM\Table(name="planificacion_seccion_especifico")
* @ORM\Entity
*/
class PlanificacionSeccionEspecifico
@@ -41,23 +32,16 @@ class PlanificacionSeccionEspecifico
private $id;
- /**
- * @var \AppBundle\Entity\PlanificacionSeccion
- *
- * @ORM\ManyToOne(targetEntity="AppBundle\Entity\PlanificacionSeccion")
- * @ORM\JoinColumns({
- * @ORM\JoinColumn(name="id_planificacion_seccion", referencedColumnName="id", nullable=false)
- * })
- */
- private $idPlanificacionSeccion;
-
+
/**
* @ORM\ManyToOne(targetEntity="PlanificacionSeccion", inversedBy="objetivoEspecifico")
- * @ORM\JoinColumn(name="id_planificacion_especifico", referencedColumnName="id")
+ * @ORM\JoinColumn(name="planificacion_seccion_id", referencedColumnName="id", nullable=FALSE)
*/
- private $idPlanificacionEspecifico;
+ private $planificacionSeccionId;
+
+
/**
* Set objetivoEspecifico
*
@@ -92,48 +76,27 @@ class PlanificacionSeccionEspecifico
}
/**
- * Set idPlanificacionSeccion
+ * Set planificacionSeccionId
*
- * @param \AppBundle\Entity\PlanificacionSeccion $idPlanificacionSeccion
+ * @param \AppBundle\Entity\PlanificacionSeccion $planificacionSeccionId
* @return PlanificacionSeccionEspecifico
*/
- public function setIdPlanificacionSeccion(\AppBundle\Entity\PlanificacionSeccion $idPlanificacionSeccion)
+ public function setPlanificacionSeccionId(\AppBundle\Entity\PlanificacionSeccion $planificacionSeccionId)
{
- $this->idPlanificacionSeccion = $idPlanificacionSeccion;
+ $this->planificacionSeccionId = $planificacionSeccionId;
return $this;
}
/**
- * Get idPlanificacionSeccion
+ * Get planificacionSeccionId
*
* @return \AppBundle\Entity\PlanificacionSeccion
*/
- public function getIdPlanificacionSeccion()
+ public function getPlanificacionSeccionId()
{
- return $this->idPlanificacionSeccion;
- }
-
- /**
- * Set idPlanificacionEspecifico
- *
- * @param \AppBundle\Entity\PlanificacionSeccion $idPlanificacionEspecifico
- * @return PlanificacionSeccionEspecifico
- */
- public function setIdPlanificacionEspecifico(\AppBundle\Entity\PlanificacionSeccion $idPlanificacionEspecifico = null)
- {
- $this->idPlanificacionEspecifico = $idPlanificacionEspecifico;
-
- return $this;
- }
-
- /**
- * Get idPlanificacionEspecifico
- *
- * @return \AppBundle\Entity\PlanificacionSeccion
- */
- public function getIdPlanificacionEspecifico()
- {
- return $this->idPlanificacionEspecifico;
+ return $this->planificacionSeccionId;
}
+
+
}
diff --git a/src/AppBundle/Entity/PlanificacionSeccionEspecifico.php~ b/src/AppBundle/Entity/PlanificacionSeccionEspecifico.php~
index 173755a..cf9c49c 100644
--- a/src/AppBundle/Entity/PlanificacionSeccionEspecifico.php~
+++ b/src/AppBundle/Entity/PlanificacionSeccionEspecifico.php~
@@ -7,16 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
/**
* PlanificacionSeccionEspecifico
*
- * @ORM\Table(name="planificacion_seccion_especifico",
- * uniqueConstraints=
- * {@ORM\UniqueConstraint(name="uq_planificacion_seccion_especifico",
- * columns={"id_planificacion_seccion"})
- * },
- * indexes={
- * @ORM\Index(name="fki_id_planificacion_especifico",
- * columns={"id_planificacion_seccion"})
- * }
- * )
+ * @ORM\Table(name="planificacion_seccion_especifico")
* @ORM\Entity
*/
class PlanificacionSeccionEspecifico
@@ -41,23 +32,13 @@ class PlanificacionSeccionEspecifico
private $id;
- /**
- * @var \AppBundle\Entity\PlanificacionSeccion
- *
- * @ORM\ManyToOne(targetEntity="AppBundle\Entity\PlanificacionSeccion")
- * @ORM\JoinColumns({
- * @ORM\JoinColumn(name="id_planificacion_seccion", referencedColumnName="id", nullable=false)
- * })
- */
- private $idPlanificacionSeccion;
-
+
/**
* @ORM\ManyToOne(targetEntity="PlanificacionSeccion", inversedBy="objetivoEspecifico")
- * @ORM\JoinColumn(name="id_planificacion_especifico", referencedColumnName="id")
+ * @ORM\JoinColumn(name="planificacion_seccion_id", referencedColumnName="id", nullable=FALSE)
*/
- private $idPlanificacionEspecifico;
-
+ private $planificacionSeccionId;
-
+
}
diff --git a/src/AppBundle/Form/PlanificacionSeccionEspecificoType.php b/src/AppBundle/Form/PlanificacionSeccionEspecificoType.php
new file mode 100644
index 0000000..b07f1ca
--- /dev/null
+++ b/src/AppBundle/Form/PlanificacionSeccionEspecificoType.php
@@ -0,0 +1,31 @@
+add('objetivoEspecifico')
+ ;
+ }
+
+ /**
+ * @param OptionsResolver $resolver
+ */
+ public function configureOptions(OptionsResolver $resolver)
+ {
+ $resolver->setDefaults(array(
+ 'data_class' => 'AppBundle\Entity\PlanificacionSeccionEspecifico'
+ ));
+ }
+}
diff --git a/src/AppBundle/Form/PlanificacionSeccionType.php b/src/AppBundle/Form/PlanificacionSeccionType.php
index 986894f..50db5df 100644
--- a/src/AppBundle/Form/PlanificacionSeccionType.php
+++ b/src/AppBundle/Form/PlanificacionSeccionType.php
@@ -17,7 +17,9 @@ class PlanificacionSeccionType extends AbstractType
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
+ //que solo salga la seccion que estamos planificando
$this->seccion = $options['seccion'];
+ //que solo salgan los temas que no han sido planificados de esa seccion
$this->planificacion = $options['planificacion'];
if (!$this->planificacion){
$this->planes[] = 0;
@@ -54,12 +56,17 @@ class PlanificacionSeccionType extends AbstractType
));
;},
))
+ ->add('objetivoEspecifico', CollectionType::class, array(
+ 'entry_type' => PlanificacionSeccionEspecificoType::class,
+ 'allow_add' => true,
+ 'label' => false
+ ))
+
->add('contenido', CollectionType::class, array(
'entry_type' => PlanificacionSeccionContenidoType::class,
'allow_add' => true,
'label' => false
))
-
;
}