From 8a81efb150eb623f1d2cf308f24f83ed4f3890d6 Mon Sep 17 00:00:00 2001 From: mhbailly Date: Sat, 28 Jun 2025 15:28:00 -0400 Subject: [PATCH 1/6] IN comparison for NumericFilter --- assets/js/app.js | 17 +++++++--- doc/filters.rst | 3 +- src/Filter/NumericFilter.php | 36 +++++++++++++++++----- src/Form/Filter/Type/NumericFilterType.php | 19 ++++++++++++ src/Form/Type/ComparisonType.php | 2 ++ templates/crud/form_theme.html.twig | 2 +- translations/EasyAdminBundle.ar.php | 1 + translations/EasyAdminBundle.bg.php | 1 + translations/EasyAdminBundle.ca.php | 1 + translations/EasyAdminBundle.cs.php | 1 + translations/EasyAdminBundle.da.php | 1 + translations/EasyAdminBundle.de.php | 1 + translations/EasyAdminBundle.el.php | 1 + translations/EasyAdminBundle.en.php | 1 + translations/EasyAdminBundle.es.php | 1 + translations/EasyAdminBundle.eu.php | 1 + translations/EasyAdminBundle.fa.php | 1 + translations/EasyAdminBundle.fi.php | 1 + translations/EasyAdminBundle.fr.php | 1 + translations/EasyAdminBundle.gl.php | 1 + translations/EasyAdminBundle.he.php | 1 + translations/EasyAdminBundle.hr.php | 1 + translations/EasyAdminBundle.hu.php | 1 + translations/EasyAdminBundle.hy.php | 1 + translations/EasyAdminBundle.id.php | 1 + translations/EasyAdminBundle.it.php | 1 + translations/EasyAdminBundle.lb.php | 1 + translations/EasyAdminBundle.lt.php | 1 + translations/EasyAdminBundle.mk.php | 1 + translations/EasyAdminBundle.nl.php | 1 + translations/EasyAdminBundle.no.php | 1 + translations/EasyAdminBundle.pl.php | 1 + translations/EasyAdminBundle.pt.php | 1 + translations/EasyAdminBundle.pt_BR.php | 1 + translations/EasyAdminBundle.ro.php | 1 + translations/EasyAdminBundle.ru.php | 1 + translations/EasyAdminBundle.sk.php | 1 + translations/EasyAdminBundle.sl.php | 1 + translations/EasyAdminBundle.sr_RS.php | 1 + translations/EasyAdminBundle.sv.php | 1 + translations/EasyAdminBundle.tr.php | 1 + translations/EasyAdminBundle.uk.php | 1 + translations/EasyAdminBundle.zh_CN.php | 1 + translations/EasyAdminBundle.zh_TW.php | 1 + 44 files changed, 103 insertions(+), 14 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 92a5c1b940..ed23d4f7ca 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -452,14 +452,21 @@ class App { if (comparisonId === undefined) { return; } - const secondValue = document.querySelector(`[data-ea-value2-of-comparison-id="${comparisonId}"]`); + const firstValue = document.querySelector(`[data-ea-value-of-comparison-id="${comparisonId}"]`); - if (secondValue === null) { - return; + if (secondValue !== null) { + toggleVisibilityClasses(secondValue, comparisonWidget.value !== 'between'); + } + if (firstValue !== null) { + if (comparisonWidget.value === 'IN') { + firstValue.type = 'text'; + firstValue.placeholder = 'xxx; yyy; zzz'; + } else { + firstValue.type = 'number'; + firstValue.placeholder = ''; + } } - - toggleVisibilityClasses(secondValue, comparisonWidget.value !== 'between'); }); }); } diff --git a/doc/filters.rst b/doc/filters.rst index dbf05333be..ccabdc5b29 100644 --- a/doc/filters.rst +++ b/doc/filters.rst @@ -75,7 +75,8 @@ These are the built-in filters provided by EasyAdmin: It's rendered as two radio buttons for the null and not null options. * ``NumericFilter``: applied by default to numeric fields. It's rendered as a ```` to define the comparison value. + ```` to define the comparison value. When using the ``IN`` comparator, the value + input becomes a text field where you can enter a semicolon-separated list of numbers. * ``TextFilter``: applied by default to string/text fields. It's rendered as a ```` or ``