Skip to content

Commit

Permalink
Replace simple "Multile answer" tick by radio buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ninsuo committed Jun 25, 2022
1 parent 4e1166d commit 52a29ec
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 22 deletions.
10 changes: 7 additions & 3 deletions symfony/src/Form/Type/EmailTriggerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use App\Form\Model\EmailTrigger;
use App\Manager\MediaManager;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
Expand Down Expand Up @@ -39,9 +39,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
parent::buildForm($builder, $options);

$builder
->add('multipleAnswer', CheckboxType::class, [
->add('multipleAnswer', ChoiceType::class, [
'label' => 'form.communication.fields.multiple_answer',
'required' => false,
'expanded' => true,
'choices' => [
'form.communication.fields.multiple_answer_one' => false,
'form.communication.fields.multiple_answer_several' => true,
],
])
->add('audience', AudienceType::class)
->add('language', LanguageType::class)
Expand Down
9 changes: 6 additions & 3 deletions symfony/src/Form/Type/SmsTriggerType.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use App\Security\Helper\Security;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\CallbackTransformer;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
Expand Down Expand Up @@ -81,9 +80,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'class' => 'collection',
],
])
->add('multipleAnswer', CheckboxType::class, [
->add('multipleAnswer', ChoiceType::class, [
'label' => 'form.communication.fields.multiple_answer',
'required' => false,
'expanded' => true,
'choices' => [
'form.communication.fields.multiple_answer_one' => false,
'form.communication.fields.multiple_answer_several' => true,
],
])
->add('test', SubmitType::class, [
'label' => 'form.communication.fields.test',
Expand Down
16 changes: 14 additions & 2 deletions symfony/templates/form_theme.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,18 @@
</div>
{% endblock %}

{# Toggle instead of tick #}
{% block radio_widget %}
<div>
{{ form_errors(form) }}
<label class="switch">
<input type="radio" {{ block('widget_attributes') }}{% if value is defined %} value="{{ value }}"{% endif %}{% if checked %} checked="checked"{% endif %} />
<span class="slider"></span>
</label>
<label for="{{ id }}">{{ form.vars.label|trans }}</label>
</div>
{% endblock %}

{# Campaign type (red, orange, green) #}
{% block types_row %}
<div class="form-group">
Expand Down Expand Up @@ -199,7 +211,7 @@
$(function () {
$('#{{ form.editor.vars.id }}').val(
$('#{{ form.e164.vars.id }}').val()
$('#{{ form.e164.vars.id }}').val()
);
var tel = document.querySelector('#{{ form.editor.vars.id }}');
Expand All @@ -213,7 +225,7 @@
if (iti.isValidNumber()) {
var e164 = $('#{{ form.editor.vars.id }}').data('e164');
$(e164).val(
iti.getNumber()
iti.getNumber()
);
}
}
Expand Down
4 changes: 1 addition & 3 deletions symfony/templates/new_communication/form_email.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@

{{ include('widget/prefilled_answers_editor.html.twig', {answers: form.answers}) }}

<br/>

{{ form_row(form.multipleAnswer) }}

<div class="h3">{{ 'form.communication.fields.preview'|trans }}</div>
Expand Down Expand Up @@ -98,7 +96,7 @@
editor.on('text-change', function () {
$('#{{ form.message.vars.id }}').val(
editor.root.innerHTML,
editor.root.innerHTML,
);
refreshPreview();
});
Expand Down
9 changes: 0 additions & 9 deletions symfony/templates/new_communication/form_sms.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,8 @@

{{ include('widget/prefilled_answers_editor.html.twig', {answers: form.answers}) }}

<br/>

{{ form_row(form.multipleAnswer) }}

{#
<div>
<div class="h3">{{ 'form.communication.fields.other_options'|trans }}</div>
</div>
#}

<div class="h3">{{ 'form.communication.fields.preview'|trans }}</div>

{{ include('new_communication/preview.html.twig') }}
Expand Down
4 changes: 3 additions & 1 deletion symfony/translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ form:
type_email: 'Message sent by email'
type_sms: 'Emergency message sent through SMS'
volunteers: Audience
multiple_answer_one: 'one answer'
multiple_answer_several: 'several answers'
nivols_search: 'Copy/paste a list of nivols'
nivols_separator: 'You can use any separator you want.'
sms: SMS
Expand Down Expand Up @@ -632,10 +634,10 @@ manage_volunteers:
message_received: 'Message received that conducted the volunteer data deletion received on %date% at %time% on trigger <a href="%url%">%trigger%</a>:'
nivol: 'NIVOL : %nivol%'
phone: 'Phone number : %phone%'
structures: 'Structure(s) : %structures%'
target: 'This message should be forwarded to the Local Unit secretary or its president.'
title: '[GDPR] RedCall - Update GAIA for #%external-id%'
who: 'Involved person:'
structures: 'Structure(s) : %structures%'
sms_content: 'Hello, we taken your request into account. You won''t receive messages from us. Sorry for the inconvenience.'
subject: '[GDPR] Data deletion request for %external-id%'
cancel: Cancel
Expand Down
4 changes: 3 additions & 1 deletion symfony/translations/messages.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,8 @@ form:
type_email: 'Message envoyé par email'
type_sms: 'Message urgent envoyé par SMS'
volunteers: Audience
multiple_answer_one: 'une réponse'
multiple_answer_several: 'plusieurs réponses'
nivols_search: 'Copier/coller une liste de nivols'
nivols_separator: 'Vous pouvez utiliser n''importe quel séparateur.'
sms: SMS
Expand Down Expand Up @@ -632,10 +634,10 @@ manage_volunteers:
message_received: 'Message reçu ayant conduit à la suppression de ce bénévole le %date% à %time% sur le déclenchement <a href="%url%">%trigger%</a> :'
nivol: 'NIVOL : %nivol%'
phone: 'Téléphone : %phone%'
structures: 'Structure(s) : %structures%'
target: 'Ce message doit être transféré au secrétaire de l''unité locale ou au président.'
title: '[RGPD] RedCall - Mettre à jour GAIA pour #%external-id%'
who: 'La personne concernée :'
structures: 'Structure(s) : %structures%'
sms_content: 'Bonjour, nous avons pris en compte votre demande. Vous ne recevrez plus de message de notre part. Toutes nos excuses pour la gêne occasionnée.'
subject: '[RGPD] Demande de suppression de données pour %external-id%'
cancel: Annuler
Expand Down

0 comments on commit 52a29ec

Please sign in to comment.