diff --git a/src/Bundle/ChillMainBundle/Entity/SavedExport.php b/src/Bundle/ChillMainBundle/Entity/SavedExport.php index 3ac361e81..81ca33e72 100644 --- a/src/Bundle/ChillMainBundle/Entity/SavedExport.php +++ b/src/Bundle/ChillMainBundle/Entity/SavedExport.php @@ -18,6 +18,7 @@ use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Doctrine\ORM\Mapping as ORM; use Ramsey\Uuid\Uuid; use Ramsey\Uuid\UuidInterface; +use Symfony\Component\Validator\Constraints as Assert; /** * @ORM\Entity @@ -31,6 +32,7 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) + * @Assert\NotBlank */ private string $description = ''; @@ -53,6 +55,7 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface /** * @ORM\Column(type="text", nullable=false, options={"default": ""}) + * @Assert\NotBlank */ private string $title = ''; @@ -96,9 +99,9 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface return $this->user; } - public function setDescription(string $description): SavedExport + public function setDescription(?string $description): SavedExport { - $this->description = $description; + $this->description = (string) $description; return $this; } @@ -117,9 +120,9 @@ class SavedExport implements TrackCreationInterface, TrackUpdateInterface return $this; } - public function setTitle(string $title): SavedExport + public function setTitle(?string $title): SavedExport { - $this->title = $title; + $this->title = (string) $title; return $this; } diff --git a/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php b/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php index 2c90379f2..5b5bff6b3 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/PickRollingDateType.php @@ -16,6 +16,8 @@ use Chill\MainBundle\Service\RollingDate\RollingDate; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\FormInterface; +use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\Validator\Constraints\Callback; use Symfony\Component\Validator\Context\ExecutionContextInterface; @@ -59,8 +61,13 @@ class PickRollingDateType extends AbstractType if (RollingDate::T_FIXED_DATE === $data->getRoll() && null === $data->getFixedDate()) { $context ->buildViolation('rolling_date.When fixed date is selected, you must provide a date') - ->atPath('roll') + ->atPath('fixedDate') ->addViolation(); } } + + public function buildView(FormView $view, FormInterface $form, array $options) + { + $view->vars['uniqid'] = uniqid('rollingdate-'); + } } diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss b/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss index 7cd3f5479..eaa11e3d6 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/chillmain.scss @@ -524,6 +524,7 @@ div.exports-list { flex-basis: 33%; @include media-breakpoint-down(lg) { flex-basis: 50%; } @include media-breakpoint-down(sm) { flex-basis: 100%; } + div:last-child, p:last-child { margin-top: auto; } diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/pick-rolling-date/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/pick-rolling-date/index.js new file mode 100644 index 000000000..2600ea40b --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/module/pick-rolling-date/index.js @@ -0,0 +1,28 @@ +import {ShowHide} from 'ChillMainAssets/lib/show_hide/index'; + +document.addEventListener('DOMContentLoaded', function(_e) { + console.log('pick-rolling-date'); + document.querySelectorAll('div[data-rolling-date]').forEach( (picker) => { + const + roll_wrapper = picker.querySelector('div.roll-wrapper'), + fixed_wrapper = picker.querySelector('div.fixed-wrapper'); + + new ShowHide({ + froms: [roll_wrapper], + container: [fixed_wrapper], + test: function (elems) { + console.log('testing'); + console.log('elems', elems); + for (let el of elems) { + for (let select_roll of el.querySelectorAll('select[data-roll-picker]')) { + console.log('select_roll', select_roll); + console.log('value', select_roll.value); + return select_roll.value === 'fixed_date'; + } + } + return false; + } + }) + }); +}); + diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/layout.html.twig index b86f617b4..873ace4ac 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/layout.html.twig @@ -52,20 +52,18 @@

{{ 'Ungrouped exports'|trans }}

{% endif %} -
+
{% for export_alias,export in grouped_exports['_'] %} - -
-
-
-

{{ export.title|trans }}

-

{{ export.description|trans }}

-

- - {{ 'Create an export'|trans }} - -

-
+ +
+
+

{{ export.title|trans }}

+

{{ export.description|trans }}

+

+ + {{ 'Create an export'|trans }} + +

diff --git a/src/Bundle/ChillMainBundle/Resources/views/Export/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Export/new.html.twig index e1605a4c2..8ef4c3ad7 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Export/new.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Export/new.html.twig @@ -22,6 +22,7 @@ {% block css %} {{ encore_entry_link_tags('mod_pickentity_type') }} + {{ encore_entry_link_tags('mod_pick_rolling_date') }} {% endblock %} {% block js %} @@ -30,6 +31,7 @@ {% if export_alias == 'count_social_work_actions' %} {{ encore_entry_script_tags('vue_export_action_goal_result') }} {% endif %} + {{ encore_entry_script_tags('mod_pick_rolling_date') }} {% endblock js %} {% block content %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig index 2b006fc4d..0e3ddbd4f 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Form/fields.html.twig @@ -257,3 +257,16 @@
{% endblock %} + +{% block pick_rolling_date_widget %} +
+
+ {{ form_widget(form.roll, { 'attr': { 'data-roll-picker': 'data-roll-picker'}}) }} + {{ form_errors(form.roll) }} +
+
+ {{ form_widget(form.fixedDate) }} + {{ form_errors(form.fixedDate) }} +
+
+{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/views/SavedExport/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/SavedExport/edit.html.twig index 937d42201..98cfd6281 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/SavedExport/edit.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/SavedExport/edit.html.twig @@ -3,6 +3,7 @@ {% block title %}{{ 'saved_export.Edit'|trans }}{% endblock %} {% block content %} +

{{ block('title') }}

{{ form_start(form) }} @@ -18,4 +19,5 @@ {{ form_end(form) }} +
{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig index 17792ecd2..fd0cda2a7 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/SavedExport/index.html.twig @@ -3,7 +3,7 @@ {% block title %}{{ 'saved_export.My saved exports'|trans }}{% endblock %} {% block content %} -
+
{{ include('@ChillMain/Export/_navbar.html.twig', {'current' : 'my'}) }} @@ -16,26 +16,25 @@ {% for group, saveds in grouped_exports %} {% if group != '_' %}

{{ group }}

-
+
{% for s in saveds %} -
-
-
-

{{ s.saved.title }}

-

{{ s.export.title|trans }}

- -
- {{ s.saved.description|chill_markdown_to_html }} -
- -
{{ 'saved_export.Created on %date%'|trans({'%date%': s.saved.createdAt|format_datetime('long', 'short')}) }}
- +
+
+

{{ s.export.title|trans }}

+

{{ s.saved.title }}

+ +
{{ 'saved_export.Created on %date%'|trans({'%date%': s.saved.createdAt|format_datetime('long', 'short')}) }}
+ +
+ {{ s.saved.description|chill_markdown_to_html }} +
+ +
-
@@ -44,33 +43,30 @@ {% endif %} {% endfor %} - {% if grouped_exports|keys|length > 1 and grouped_exports['_']|length > 0 %} + {% if grouped_exports|keys|length > 1 and grouped_exports['_']|default([])|length > 0 %}

{{ 'Ungrouped exports'|trans }}

{% endif %} -
+
{% for saveds in grouped_exports['_']|default([]) %} {% for s in saveds %} -
-
-
-
-

{{ s.saved.title }}

-

{{ s.export.title|trans }}

- -
- {{ s.saved.description|chill_markdown_to_html }} -
- -
{{ 'saved_export.Created on %date%'|trans({'%date%': s.saved.createdAt|format_datetime('long', 'short')}) }}
- -
    -
  • -
  • -
  • -
- -
+
+
+

{{ s.export.title|trans }}

+

{{ s.saved.title }}

+ +
{{ 'saved_export.Created on %date%'|trans({'%date%': s.saved.createdAt|format_datetime('long', 'short')}) }}
+ +
+ {{ s.saved.description|chill_markdown_to_html }} +
+ +
+
    +
  • +
  • +
  • +
diff --git a/src/Bundle/ChillMainBundle/Resources/views/SavedExport/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/SavedExport/new.html.twig index 037adb0fc..317f53e42 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/SavedExport/new.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/SavedExport/new.html.twig @@ -3,6 +3,7 @@ {% block title %}{{ 'saved_export.New'|trans }}{% endblock %} {% block content %} +

{{ block('title') }}

{{ form_start(form) }} @@ -18,4 +19,5 @@ {{ form_end(form) }} +
{% endblock %} \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/chill.webpack.config.js b/src/Bundle/ChillMainBundle/chill.webpack.config.js index 73f539739..0e4924b03 100644 --- a/src/Bundle/ChillMainBundle/chill.webpack.config.js +++ b/src/Bundle/ChillMainBundle/chill.webpack.config.js @@ -71,6 +71,7 @@ module.exports = function(encore, entries) encore.addEntry('mod_entity_workflow_pick', __dirname + '/Resources/public/module/entity-workflow-pick/index.js'); encore.addEntry('mod_wopi_link', __dirname + '/Resources/public/module/wopi-link/index.js'); encore.addEntry('mod_pick_postal_code', __dirname + '/Resources/public/module/pick-postal-code/index.js'); + encore.addEntry('mod_pick_rolling_date', __dirname + '/Resources/public/module/pick-rolling-date/index.js'); // Vue entrypoints encore.addEntry('vue_address', __dirname + '/Resources/public/vuejs/Address/index.js'); diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index fe4d5c0ed..37672d449 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -558,12 +558,12 @@ rolling_date: fixed_date_date: Date fixe saved_export: - Any saved export: Aucun rapport enregistré - New: Nouveau rapport enregistré - Edit: Modifier un rapport enregistré - Delete saved ?: Supprimer un rapport enregistré ? - Are you sure you want to delete this saved ?: Êtes-vous sûr·e de vouloir supprimer ce rapport ? - My saved exports: Mes rapports enregistrés - Export is deleted: Le rapport est supprimé - Saved export is saved!: Le rapport est enregistré + Any saved export: Aucun export enregistré + New: Nouvel export enregistré + Edit: Modifier un export enregistré + Delete saved ?: Supprimer un export enregistré ? + Are you sure you want to delete this saved ?: Êtes-vous sûr·e de vouloir supprimer cet export ? + My saved exports: Mes exports enregistrés + Export is deleted: L'export est supprimé + Saved export is saved!: L'export est enregistré Created on %date%: Créé le %date% diff --git a/src/Bundle/ChillMainBundle/translations/validators.fr.yml b/src/Bundle/ChillMainBundle/translations/validators.fr.yml index da433ba0f..690629e44 100644 --- a/src/Bundle/ChillMainBundle/translations/validators.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/validators.fr.yml @@ -31,3 +31,6 @@ notification: workflow: You must add at least one dest user or email: Indiquez au moins un destinataire ou une adresse email + +rolling_date: + When fixed date is selected, you must provide a date: Indiquez la date fixe choisie \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php index 2dd9192bd..de86604e6 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByEndDateFilter.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\PersonBundle\Export\Declarations; -use DateTimeImmutable; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -59,7 +58,6 @@ class ByEndDateFilter implements FilterInterface ->add('start_date', PickRollingDateType::class, [ 'label' => 'start period date', 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), - 'input' => 'datetime_immutable', ]) ->add('end_date', PickRollingDateType::class, [ 'label' => 'end period date', diff --git a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php index 95314708f..27518599c 100644 --- a/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php +++ b/src/Bundle/ChillPersonBundle/Export/Filter/EvaluationFilters/ByStartDateFilter.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Form\Type\PickRollingDateType; use Chill\MainBundle\Service\RollingDate\RollingDate; use Chill\MainBundle\Service\RollingDate\RollingDateConverterInterface; use Chill\PersonBundle\Export\Declarations; -use DateTimeImmutable; use Doctrine\ORM\QueryBuilder; use Symfony\Component\Form\FormBuilderInterface; @@ -59,7 +58,6 @@ class ByStartDateFilter implements FilterInterface ->add('start_date', PickRollingDateType::class, [ 'label' => 'start period date', 'data' => new RollingDate(RollingDate::T_YEAR_PREVIOUS_START), - 'input' => 'datetime_immutable', ]) ->add('end_date', PickRollingDateType::class, [ 'label' => 'end period date',