Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pouvoir ajouter une url sur un poste de bénévolat #597

Merged
merged 3 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions app/DoctrineMigrations/Version20221105112542.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace Application\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20221105112542 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE job ADD url VARCHAR(255) DEFAULT NULL');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('ALTER TABLE job DROP url');
}
}
5 changes: 5 additions & 0 deletions app/Resources/views/admin/job/_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
{{ form_errors(form.description) }}
{{ form_widget(form.description) }}
</div>
<div class="row">
{{ form_label(form.url) }}
{{ form_errors(form.url) }}
{{ form_widget(form.url) }}
</div>
<div class="row">
{{ form_errors(form.enabled) }}
<label>
Expand Down
8 changes: 6 additions & 2 deletions app/Resources/views/admin/job/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
<table class="responsive-table striped">
<thead>
<tr>
<th>id</th>
<th>Poste</th>
<th>Couleur</th>
<th>Description</th>
<th>Lien<br />(vers une doc)</th>
<th>Nombre de créneaux<br />(semaine type)</th>
<th>Actions</th>
</tr>
Expand All @@ -26,14 +26,18 @@
<tbody>
{% for job in jobs %}
<tr>
<td>{{ job.id }}</td>
<td {% if not job.enabled %}style="text-decoration: line-through"{% endif %}>{{ job.name }}</td>
<td class="{{ job.color }} white-text">{{ job.color }}</td>
<td class="center-align">
{% if job.description is not empty %}
<i class="material-icons" title="{{ job.description }}">playlist_add_check</i>
{% endif %}
</td>
<td class="center-align">
{% if job.url is not empty %}
<a href="{{ job.url }}" target="_blank">lien</a>
{% endif %}
</td>
<td>{{ job.periods | length }}</td>
<td>
<a href="{{ path('job_edit', { 'id': job.id }) }}"><i class="material-icons">edit</i>editer</a>
Expand Down
20 changes: 9 additions & 11 deletions src/AppBundle/Controller/JobController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ class JobController extends Controller
* @Method("GET")
* @Security("has_role('ROLE_ADMIN')")
*/
public function listAction(Request $request){

public function listAction(Request $request)
{
$em = $this->getDoctrine()->getManager();
$jobs = $em->getRepository('AppBundle:Job')->findAll();

return $this->render('admin/job/list.html.twig', array(
'jobs' => $jobs
));
Expand All @@ -55,22 +56,20 @@ public function newAction(Request $request){
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {

$em->persist($job);
$em->flush();

$session->getFlashBag()->add('success', 'Le nouveau poste a été créé !');

return $this->redirectToRoute('job_list');
}

return $this->render('admin/job/new.html.twig', array(
'form' => $form->createView()
));

}

/**
* add new job.
* Edit job.
*
* @Route("/edit/{id}", name="job_edit")
* @Method({"GET","POST"})
Expand All @@ -85,24 +84,22 @@ public function editAction(Request $request, Job $job){
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {

$em->persist($job);
$em->flush();

$session->getFlashBag()->add('success', 'Le poste a bien été édité !');

return $this->redirectToRoute('job_list');
}

return $this->render('admin/job/edit.html.twig', array(
'form' => $form->createView(),
'delete_form' => $this->getDeleteForm($job)->createView()
));

}


/**
* job delete
* Delete job.
*
* @Route("/{id}", name="job_delete")
* @Method({"DELETE"})
Expand All @@ -113,12 +110,14 @@ public function removeAction(Request $request,Job $job)
$session = new Session();
$form = $this->getDeleteForm($job);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($job);
$em->flush();
$session->getFlashBag()->add('success', 'Le poste a bien été supprimée !');
}

return $this->redirectToRoute('job_list');
}

Expand All @@ -132,5 +131,4 @@ protected function getDeleteForm(Job $job){
->setMethod('DELETE')
->getForm();
}

}
4 changes: 2 additions & 2 deletions src/AppBundle/Controller/ServiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@


/**
* Task controller.
* Service controller.
*
* @Route("services")
*/
Expand Down Expand Up @@ -136,7 +136,7 @@ public function editAction(Request $request,Service $service)


/**
* edit service.
* delete service.
*
* @Route("/{id}", name="service_remove")
* @Method({"DELETE"})
Expand Down
31 changes: 31 additions & 0 deletions src/AppBundle/Entity/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ class Job
*/
private $description;

/**
* @var string
*
* @ORM\Column(name="url", type="string", length=255, nullable=true)
*/
private $url;

/**
* @var int
*
Expand Down Expand Up @@ -291,6 +298,30 @@ public function setDescription(string $description): Job
return $this;
}

/**
* Set url
*
* @param string $url
*
* @return Job
*/
public function setUrl($url)
{
$this->url = $url;

return $this;
}

/**
* Get url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}

/**
* Get createdAt
*
Expand Down
15 changes: 8 additions & 7 deletions src/AppBundle/Entity/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ class Service
*/
private $clients;

/**
* Constructor
*/
public function __construct()
{
$this->users = new \Doctrine\Common\Collections\ArrayCollection();
}

/**
* @ORM\PrePersist
*/
Expand Down Expand Up @@ -220,13 +228,6 @@ public function getUrl()
{
return $this->url;
}
/**
* Constructor
*/
public function __construct()
{
$this->users = new \Doctrine\Common\Collections\ArrayCollection();
}

/**
* Add user
Expand Down
1 change: 1 addition & 0 deletions src/AppBundle/Form/JobType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add('min_shifter_alert', IntegerType::class, array('label' => 'Nombre minimum de bénévoles inscrits sur le créneau pour ne pas envoyer d\'alerte', 'required' => true, 'data' => 2, 'empty_data' => 2))
->add('color', TextType::class, array('label'=>'Couleur des créneaux dans le planning'))
->add('description', MarkdownEditorType::class, array('label' => 'Description', 'required' => false, 'empty_data' => ''))
->add('url', TextType::class, array('label'=>'Lien vers une documentation', 'required' => false))
->add('enabled', CheckboxType::class, array('required' => false, 'label' => 'Poste activé', 'attr' => array('class' => 'filled-in')));
}

Expand Down