Fix poll not removed when hidden

This commit is contained in:
Thomas 2024-05-13 08:08:44 +02:00
parent 2cf43f4a50
commit 85e409a481
4 changed files with 22 additions and 1 deletions

View file

@ -191,7 +191,12 @@ class FediPlanController extends AbstractController
} }
$params['sensitive'] = ($data->getSensitive() == null || !$data->getSensitive()) ? false : true; $params['sensitive'] = ($data->getSensitive() == null || !$data->getSensitive()) ? false : true;
$pollOptions = $data->getPollOptions(); if($data->getAttachPoll() > 0) {
$pollOptions = $data->getPollOptions();
} else{
$pollOptions = array();
}
$pollExpiresAt = $data->getPollExpiresAt(); $pollExpiresAt = $data->getPollExpiresAt();
$isPollMultiple = $data->isPollMultiple(); $isPollMultiple = $data->isPollMultiple();
if (count($pollOptions) > 0) { if (count($pollOptions) > 0) {

View file

@ -19,6 +19,7 @@ use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType; use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\DateTimeType; use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
@ -76,6 +77,8 @@ class ComposeType extends AbstractType
'data' => $user->getDefaultVisibility(), 'data' => $user->getDefaultVisibility(),
'label' => 'page.schedule.form.visibility', 'label' => 'page.schedule.form.visibility',
'translation_domain' => 'fediplan']); 'translation_domain' => 'fediplan']);
$builder->add('attach_poll', HiddenType::class, ['required' => true, 'empty_data' => 0]);
$builder->add('timeZone', TimezoneType::class, $builder->add('timeZone', TimezoneType::class,
[ [
'label' => 'page.schedule.form.timeZone', 'label' => 'page.schedule.form.timeZone',

View file

@ -26,6 +26,17 @@ class Compose
private ?int $poll_expires_at = null; private ?int $poll_expires_at = null;
private ?bool $poll_multiple = null; private ?bool $poll_multiple = null;
public function getAttachPoll(): ?bool
{
return $this->attach_poll;
}
public function setAttachPoll(?bool $attach_poll): void
{
$this->attach_poll = $attach_poll;
}
private ?bool $attach_poll = null;
public function __construct() public function __construct()
{ {
$this->poll_options = array(); $this->poll_options = array();

View file

@ -479,8 +479,10 @@
$('#poll_switch').click(function (e) { $('#poll_switch').click(function (e) {
if($('#poll_container').hasClass("d-none") ){ if($('#poll_container').hasClass("d-none") ){
$('#poll_container').removeClass("d-none"); $('#poll_container').removeClass("d-none");
$('#compose_attach_poll').val(1);
}else{ }else{
$('#poll_container').addClass("d-none"); $('#poll_container').addClass("d-none");
$('#compose_attach_poll').val(0);
} }
}); });
var $collectionHolder; var $collectionHolder;