From 773069af9ca7f5f6792d29f7704e2e3634a0ce9d Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Thu, 16 May 2024 17:57:51 +0200 Subject: [PATCH 01/38] feat: remove dropdown when only one action is set and show icon with link and tooltip https://dev.whatwedo.ch/araise/araise-meta/-/issues/58 --- .../views/tailwind_2/_table.html.twig | 77 ++++++++++++------- 1 file changed, 48 insertions(+), 29 deletions(-) diff --git a/src/Resources/views/tailwind_2/_table.html.twig b/src/Resources/views/tailwind_2/_table.html.twig index 7c9465a..888d885 100644 --- a/src/Resources/views/tailwind_2/_table.html.twig +++ b/src/Resources/views/tailwind_2/_table.html.twig @@ -214,38 +214,57 @@ %} {% if tableActionsVisible|length %} -
- - + {% if tableActionsVisible|length > 1 %} + {% else %} + {% set action = tableActionsVisible|first %} + "#{attr}=\"#{value}\"")|join(' ')|raw }} + > + + {% if action.option('icon') %} + {{ bootstrap_icon(action.icon, { class: 'h-4 w-4' }) }} + {% else %} + {{ bootstrap_icon('link-45deg', { class: 'h-4 w-4' }) }} + {% endif %} + {{ action.label|trans }} + + + {% endif %} + {% endif %} {% endif %} From 8c2914d35b6856bab8d317cade6c2b756ce0b7a5 Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Thu, 16 May 2024 15:54:57 +0200 Subject: [PATCH 02/38] fix: check if target exists before trying to update it https://dev.whatwedo.ch/araise/araise-meta/-/issues/79 --- .../assets/controllers/table_select_controller.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Resources/assets/controllers/table_select_controller.js b/src/Resources/assets/controllers/table_select_controller.js index d9e6e5e..2df7976 100644 --- a/src/Resources/assets/controllers/table_select_controller.js +++ b/src/Resources/assets/controllers/table_select_controller.js @@ -87,13 +87,15 @@ export default class extends Controller { updateSelectedCount() { const count = this.getIds().length; - if (count === 0) { - this.selectedCountTarget.classList.add('hidden'); - return; - } + if(this.hasSelectedCountTarget) { + if (count === 0) { + this.selectedCountTarget.classList.add('hidden'); + return; + } - this.selectedCountTarget.classList.remove('hidden'); - this.selectedCountTarget.innerHTML = this.footSelectedTemplateValue.replace('{count}', count); + this.selectedCountTarget.classList.remove('hidden'); + this.selectedCountTarget.innerHTML = this.footSelectedTemplateValue.replace('{count}', count); + } } syncSelectedIds() { From 369985ebe8de02f8181b68590e7e1066c760ed75 Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Wed, 22 May 2024 15:13:42 +0200 Subject: [PATCH 03/38] refactor: introduce Stimulus Class API for Table Select Controller and improve code quality --- .../controllers/table_select_controller.js | 31 +++++++++++++------ .../views/tailwind_2_layout.html.twig | 17 ++++++---- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/src/Resources/assets/controllers/table_select_controller.js b/src/Resources/assets/controllers/table_select_controller.js index 2df7976..c372f66 100644 --- a/src/Resources/assets/controllers/table_select_controller.js +++ b/src/Resources/assets/controllers/table_select_controller.js @@ -3,10 +3,11 @@ import 'regenerator-runtime/runtime' export default class extends Controller { - static targets = ["ids", "selector", "checkAll", "unCheckAll", "selectedCount"] + static targets = ['ids', 'selector', 'checkAll', 'unCheckAll', 'selectedCount'] static values = { footSelectedTemplate: String } + static classes = ['hideCount'] connect() { if (!this.hasIdsTarget) { @@ -18,6 +19,9 @@ export default class extends Controller { }); } + /** + * @param {Event} event + */ selectId(event) { if (!event.target.dataset.entityId) { return; @@ -46,8 +50,8 @@ export default class extends Controller { this.addId(selector.dataset.entityId); selector.checked = true; }); - this.checkAllTarget.classList.add('hidden'); - this.unCheckAllTarget.classList.remove('hidden'); + this.checkAllTarget.classList.add(this.hideCountClasses); + this.unCheckAllTarget.classList.remove(this.hideCountClasses); } unCheckAll() { @@ -55,15 +59,21 @@ export default class extends Controller { this.removeId(selector.dataset.entityId); selector.checked = false; }); - this.checkAllTarget.classList.remove('hidden'); - this.unCheckAllTarget.classList.add('hidden'); + this.checkAllTarget.classList.remove(this.hideCountClasses); + this.unCheckAllTarget.classList.add(this.hideCountClasses); } + /** + * @param {string} id + */ hasId(id) { let ids = this.getIds(); return ids.includes(id) } + /** + * @param {string} id + */ addId(id) { let ids = this.getIds(); ids.push(id); @@ -71,6 +81,9 @@ export default class extends Controller { this.updateSelectedCount(); } + /** + * @param {string} id + */ removeId(id) { let ids = this.getIds(); ids = ids.filter(function (value, index, arr) { @@ -79,8 +92,8 @@ export default class extends Controller { this.idsTarget.value = JSON.stringify(ids); this.updateSelectedCount(); if (ids.length == 0) { - this.checkAllTarget.classList.remove('hidden'); - this.unCheckAllTarget.classList.add('hidden'); + this.checkAllTarget.classList.remove(this.hideCountClasses); + this.unCheckAllTarget.classList.add(this.hideCountClasses); } } @@ -89,11 +102,11 @@ export default class extends Controller { if(this.hasSelectedCountTarget) { if (count === 0) { - this.selectedCountTarget.classList.add('hidden'); + this.selectedCountTarget.classList.add(this.hideCountClasses); return; } - this.selectedCountTarget.classList.remove('hidden'); + this.selectedCountTarget.classList.remove(this.hideCountClasses); this.selectedCountTarget.innerHTML = this.footSelectedTemplateValue.replace('{count}', count); } } diff --git a/src/Resources/views/tailwind_2_layout.html.twig b/src/Resources/views/tailwind_2_layout.html.twig index 1b8e1c7..68d3263 100644 --- a/src/Resources/views/tailwind_2_layout.html.twig +++ b/src/Resources/views/tailwind_2_layout.html.twig @@ -4,12 +4,17 @@ {% include "@araiseTable/tailwind_2/_filter.html.twig" %} {% endblock %} -
' ~ ('araise_table.foot.selected'|trans({ - '{count}': '{count}', - })) - }) }} +
' ~ ('araise_table.foot.selected'|trans({ + '{count}': '{count}', + })) + }, + { + 'hideCount': 'hidden' + } + ) }} > {% block table_header %} From 20f9b620a6a367e7a6eb0eaa7339325aca38acfe Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Wed, 15 May 2024 11:07:14 +0200 Subject: [PATCH 04/38] feat: listens for global event to close dropdown when another is opened https://dev.whatwedo.ch/araise/araise-meta/-/issues/59 --- src/Resources/views/tailwind_2/_table.html.twig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Resources/views/tailwind_2/_table.html.twig b/src/Resources/views/tailwind_2/_table.html.twig index 888d885..a631f21 100644 --- a/src/Resources/views/tailwind_2/_table.html.twig +++ b/src/Resources/views/tailwind_2/_table.html.twig @@ -62,8 +62,9 @@ + + +
+ {% endif %} +{% endmacro %} + From 19d3acc86fa649c4fb4fc01ce9a93e2ca496e8a3 Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Sat, 20 Jul 2024 21:42:37 +0200 Subject: [PATCH 26/38] fix: adjust styling in header and add tooltips to buttons in table header --- src/Resources/translations/messages.de.yaml | 2 ++ src/Resources/translations/messages.en.yaml | 1 + src/Resources/views/tailwind_2/_header.html.twig | 13 +++++++------ 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Resources/translations/messages.de.yaml b/src/Resources/translations/messages.de.yaml index 640f5a3..4ec2ab1 100644 --- a/src/Resources/translations/messages.de.yaml +++ b/src/Resources/translations/messages.de.yaml @@ -1,5 +1,6 @@ araise_table: download: + tooltip: Export info: Was möchten Sie herunterladen? choices: Export wählen all: Alle Seiten @@ -41,6 +42,7 @@ araise_table: next_page: nächste Seite last_page: letzte Seite filter: + tooltip: Filter show_element_when: Zeige Elemente wenn or: oder and: und diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index 8c7661b..04be29f 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -1,5 +1,6 @@ araise_table: download: + tooltop: Export info: What would you like to download? choices: Choose Export all: All pages diff --git a/src/Resources/views/tailwind_2/_header.html.twig b/src/Resources/views/tailwind_2/_header.html.twig index 432e94b..e502838 100644 --- a/src/Resources/views/tailwind_2/_header.html.twig +++ b/src/Resources/views/tailwind_2/_header.html.twig @@ -1,6 +1,6 @@ {# Table Header #} {% if table.option('title') or (view is defined and table.option('definition').hasCapability(constant('araise\\CrudBundle\\Enums\\Page::EXPORT'))) or (table.filterExtension and table.filterExtension.filters|length > 0) or (table.searchExtension and table.option('searchable')) %} -
+
{% if table.option('title') %}

@@ -8,14 +8,15 @@

{% endif %}
-
+
{% if table.exporters|length > 0 and table.option('definition') and table.option('definition').hasCapability(constant('araise\\CrudBundle\\Enums\\Page::EXPORT')) %}
@@ -84,6 +85,7 @@ type="button" {{ stimulus_action('araise/table-bundle/filter', 'open') }} {{ stimulus_target('araise/table-bundle/filter', 'triggerButton') }} + {{ stimulus_controller('araise/crud-bundle/tooltip', { 'title': 'araise_table.filter.tooltip'|trans } ) }} > {{ bootstrap_icon('funnel-fill', { class: 'w-4 h-4' }) }} @@ -106,15 +108,14 @@ value="{{ table.searchExtension.query }}" >
-
{% endif %}
- {% endif %} {% macro add_button(content, view, isOnShow) %} From 965e20dc50056cf4c3eac0f3e18bf5f0f31213b0 Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Mon, 22 Jul 2024 15:23:06 +0200 Subject: [PATCH 27/38] fix: translate strings and make buttons/dropdown more accessible --- src/Resources/translations/messages.en.yaml | 2 +- src/Resources/views/tailwind_2/_header.html.twig | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index 04be29f..4eee469 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -1,6 +1,5 @@ araise_table: download: - tooltop: Export info: What would you like to download? choices: Choose Export all: All pages @@ -24,6 +23,7 @@ araise_table: options: Options no_elements: No elements available search: + title: Search filter: Filter remove_search: Remove search placeholder: Search term... diff --git a/src/Resources/views/tailwind_2/_header.html.twig b/src/Resources/views/tailwind_2/_header.html.twig index e502838..21c6283 100644 --- a/src/Resources/views/tailwind_2/_header.html.twig +++ b/src/Resources/views/tailwind_2/_header.html.twig @@ -16,7 +16,7 @@ @@ -104,12 +104,13 @@
-
From cd1fc15faf6023aa6b66c3f5309c43c600f9c3d8 Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Mon, 22 Jul 2024 15:41:54 +0200 Subject: [PATCH 28/38] refactor(subtables): use proper if-condition instead of JSX style check --- src/Resources/assets/controllers/accordion_controller.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Resources/assets/controllers/accordion_controller.js b/src/Resources/assets/controllers/accordion_controller.js index 0e91697..eabe006 100644 --- a/src/Resources/assets/controllers/accordion_controller.js +++ b/src/Resources/assets/controllers/accordion_controller.js @@ -56,7 +56,9 @@ export default class extends Controller { /** @type {string[]} */ const contentHiddenClasses = this.contentHiddenClasses; - header && header.setAttribute('aria-expanded', 'true'); + if(header) { + header.setAttribute('aria-expanded', 'true'); + } arrow.classList.add(...arrowRotateClasses); contents.forEach((item) => { item.classList.remove(...contentHiddenClasses); @@ -75,7 +77,9 @@ export default class extends Controller { /** @type {string[]} */ const contentHiddenClasses = this.contentHiddenClasses; - header && header.setAttribute('aria-expanded', 'false'); + if(header) { + header.setAttribute('aria-expanded', 'false'); + } arrow.classList.remove(...arrowRotateClasses); contents.forEach((item) => { item.classList.add(...contentHiddenClasses); From 8bc17c241b2714f59c556b826e94fd12d1268656 Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Mon, 22 Jul 2024 16:11:17 +0200 Subject: [PATCH 29/38] refactor: simplify conditionals inside element Strip conditional classes and attributes out of element declaration --- src/Resources/views/tailwind_2/_header.html.twig | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Resources/views/tailwind_2/_header.html.twig b/src/Resources/views/tailwind_2/_header.html.twig index 21c6283..b3bf95d 100644 --- a/src/Resources/views/tailwind_2/_header.html.twig +++ b/src/Resources/views/tailwind_2/_header.html.twig @@ -123,11 +123,15 @@ {% set createUrl = content.createUrl(view.data) %} {% if createUrl and (content.addVoterAttribute is null or is_granted(content.addVoterAttribute, view.data)) %} -
"#{attr}=\"#{value}\"")|join(' ')|raw }}{% endif %} - {{ stimulus_controller('araise/core-bundle/modal-form', { formUrl: createUrl }) }} - > + + {% set additionalClass = (not isOnShow) ? (content.option('attr')['class'] ?? '') : '' %} + {% set additionalAttributes = (not isOnShow) ? attr|map((value, attr) => "#{attr}=\"#{value}\"")|join(' ') : '' %} + +
+
- {# This element is to trick the browser into centering the modal contents. #} + {# This element is to trick the browser into centering the modal contents. Code is coming from Tailwind UI #}
From f48a1fcd90611665ae0fc979d350eccea0c695ba Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Tue, 23 Jul 2024 16:43:38 +0200 Subject: [PATCH 31/38] refactor: simplify if/else statement for attributes This is a temporar fix. Could be improved with a proper helper to turn an array into attributes like the `html_classes` do --- src/Resources/views/tailwind_2/_header.html.twig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Resources/views/tailwind_2/_header.html.twig b/src/Resources/views/tailwind_2/_header.html.twig index 382f195..8eb0c5f 100644 --- a/src/Resources/views/tailwind_2/_header.html.twig +++ b/src/Resources/views/tailwind_2/_header.html.twig @@ -28,19 +28,21 @@ data-transition-leave-to="opacity-0 scale-95" tabindex="-1" > -
1 %} {{ stimulus_controller('araise/table-bundle/exporter') }} {% endif %}> + {% set stimulusController = (table.exporters|length > 1) ? stimulus_controller('araise/table-bundle/exporter') : '' %} +
{% if table.exporters|length > 1 %}

{{ 'araise_table.download.choices' | trans }}

    {% for acronym,exporter in table.exporters %}
  • + {% set stimulusAction = (table.exporters|length > 1) ? stimulus_action('araise/table-bundle/exporter', 'select') : '' %} 1 %} {{ stimulus_action('araise/table-bundle/exporter', 'select')}} {% endif %} + {{ stimulusAction }} >
  • From 81b3dd0229b770b2d2dd2eed3b5eab001600fbdc Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Thu, 18 Jul 2024 17:20:39 +0200 Subject: [PATCH 32/38] fix: add datepicker to filters with `datetime` & `date` input fields --- src/Filter/Type/DateFilterType.php | 5 +++-- src/Filter/Type/DatetimeFilterType.php | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Filter/Type/DateFilterType.php b/src/Filter/Type/DateFilterType.php index 1f9f319..3ed4c52 100644 --- a/src/Filter/Type/DateFilterType.php +++ b/src/Filter/Type/DateFilterType.php @@ -14,8 +14,9 @@ public function getValueField(?string $value = null, ?string $operator = null): $value = $date->format(static::getDateFormat()); return sprintf( - '', - $operator !== static::CRITERIA_IS_EMPTY ? $value : '' + '', + $operator !== static::CRITERIA_IS_EMPTY ? $value : '', + 'de' ); } diff --git a/src/Filter/Type/DatetimeFilterType.php b/src/Filter/Type/DatetimeFilterType.php index c1f6c31..617590e 100644 --- a/src/Filter/Type/DatetimeFilterType.php +++ b/src/Filter/Type/DatetimeFilterType.php @@ -40,8 +40,9 @@ public function getValueField(?string $value = null, ?string $operator = null): $value = $date->format(static::getDateFormat()); return sprintf( - '', - $operator !== static::CRITERIA_IS_EMPTY ? $value : '' + '', + $operator !== static::CRITERIA_IS_EMPTY ? $value : '', + 'de' ); } From 72b3966660dbcbcaa18176e7e64ecf6113e4ec35 Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Fri, 19 Jul 2024 12:16:28 +0200 Subject: [PATCH 33/38] feat: add dynamic locale to Filter Date Type I had to handle the requestStack retrieval differently between those two classes. Don't know why this is the case. --- src/Filter/Type/DateFilterType.php | 11 ++++++++++- src/Filter/Type/DatetimeFilterType.php | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Filter/Type/DateFilterType.php b/src/Filter/Type/DateFilterType.php index 3ed4c52..be735d5 100644 --- a/src/Filter/Type/DateFilterType.php +++ b/src/Filter/Type/DateFilterType.php @@ -5,9 +5,18 @@ namespace araise\TableBundle\Filter\Type; use Doctrine\ORM\QueryBuilder; +use Symfony\Component\HttpFoundation\RequestStack; class DateFilterType extends DatetimeFilterType { + protected $locale; + + public function __construct(?string $column = null, array $joins = [], protected ?RequestStack $requestStack = null) + { + parent::__construct($column, $joins); + $this->locale = $requestStack->getMainRequest()?->getLocale() ?? 'en'; + } + public function getValueField(?string $value = null, ?string $operator = null): string { $date = \DateTime::createFromFormat(static::getQueryDataFormat(), (string) $value) ?: new \DateTime(); @@ -16,7 +25,7 @@ public function getValueField(?string $value = null, ?string $operator = null): return sprintf( '', $operator !== static::CRITERIA_IS_EMPTY ? $value : '', - 'de' + $this->locale ); } diff --git a/src/Filter/Type/DatetimeFilterType.php b/src/Filter/Type/DatetimeFilterType.php index 617590e..4018b5c 100644 --- a/src/Filter/Type/DatetimeFilterType.php +++ b/src/Filter/Type/DatetimeFilterType.php @@ -5,6 +5,7 @@ namespace araise\TableBundle\Filter\Type; use Doctrine\ORM\QueryBuilder; +use Symfony\Component\HttpFoundation\RequestStack; class DatetimeFilterType extends FilterType { @@ -20,6 +21,11 @@ class DatetimeFilterType extends FilterType public const CRITERIA_IS_EMPTY = 'is_empty'; + public function __construct(?string $column = null, array $joins = [], protected ?RequestStack $requestStack = null) + { + parent::__construct($column, $joins); + } + public function getOperators(): array { return [ @@ -38,11 +44,12 @@ public function getValueField(?string $value = null, ?string $operator = null): { $date = \DateTime::createFromFormat(static::getQueryDataFormat(), (string) $value) ?: new \DateTime(); $value = $date->format(static::getDateFormat()); + $locale = $this->requestStack->getMainRequest()?->getLocale(); return sprintf( '', $operator !== static::CRITERIA_IS_EMPTY ? $value : '', - 'de' + $locale ?? 'en' ); } From b4046bbd812d90b98f96110d0470971989fc89f3 Mon Sep 17 00:00:00 2001 From: tuxes3 Date: Tue, 23 Jul 2024 19:44:12 +0200 Subject: [PATCH 34/38] chore: code style --- src/Filter/Type/DateFilterType.php | 7 +++++-- src/Filter/Type/DatetimeFilterType.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Filter/Type/DateFilterType.php b/src/Filter/Type/DateFilterType.php index be735d5..b036b28 100644 --- a/src/Filter/Type/DateFilterType.php +++ b/src/Filter/Type/DateFilterType.php @@ -11,8 +11,11 @@ class DateFilterType extends DatetimeFilterType { protected $locale; - public function __construct(?string $column = null, array $joins = [], protected ?RequestStack $requestStack = null) - { + public function __construct( + ?string $column = null, + array $joins = [], + protected ?RequestStack $requestStack = null + ) { parent::__construct($column, $joins); $this->locale = $requestStack->getMainRequest()?->getLocale() ?? 'en'; } diff --git a/src/Filter/Type/DatetimeFilterType.php b/src/Filter/Type/DatetimeFilterType.php index 4018b5c..5f87b70 100644 --- a/src/Filter/Type/DatetimeFilterType.php +++ b/src/Filter/Type/DatetimeFilterType.php @@ -21,8 +21,11 @@ class DatetimeFilterType extends FilterType public const CRITERIA_IS_EMPTY = 'is_empty'; - public function __construct(?string $column = null, array $joins = [], protected ?RequestStack $requestStack = null) - { + public function __construct( + ?string $column = null, + array $joins = [], + protected ?RequestStack $requestStack = null + ) { parent::__construct($column, $joins); } From 5a3eb42cf3f6070e9bbd18571081b4cb747cef40 Mon Sep 17 00:00:00 2001 From: tuxes3 Date: Wed, 24 Jul 2024 09:36:03 +0200 Subject: [PATCH 35/38] refactor: use StimulusHelper to generate Stimulus Attributes --- src/Filter/Type/DateFilterType.php | 12 +++++++++--- src/Filter/Type/DatetimeFilterType.php | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Filter/Type/DateFilterType.php b/src/Filter/Type/DateFilterType.php index b036b28..5600eb4 100644 --- a/src/Filter/Type/DateFilterType.php +++ b/src/Filter/Type/DateFilterType.php @@ -6,6 +6,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\UX\StimulusBundle\Helper\StimulusHelper; class DateFilterType extends DatetimeFilterType { @@ -24,11 +25,16 @@ public function getValueField(?string $value = null, ?string $operator = null): { $date = \DateTime::createFromFormat(static::getQueryDataFormat(), (string) $value) ?: new \DateTime(); $value = $date->format(static::getDateFormat()); - + $stimulusAttrs = (new StimulusHelper(null))->createStimulusAttributes(); + $stimulusAttrs + ->addController('araise/core-bundle/datetime', [ + 'lang' => $this->locale, + ]) + ; return sprintf( - '', + '', $operator !== static::CRITERIA_IS_EMPTY ? $value : '', - $this->locale + $stimulusAttrs ); } diff --git a/src/Filter/Type/DatetimeFilterType.php b/src/Filter/Type/DatetimeFilterType.php index 5f87b70..bb5872e 100644 --- a/src/Filter/Type/DatetimeFilterType.php +++ b/src/Filter/Type/DatetimeFilterType.php @@ -6,6 +6,7 @@ use Doctrine\ORM\QueryBuilder; use Symfony\Component\HttpFoundation\RequestStack; +use Symfony\UX\StimulusBundle\Helper\StimulusHelper; class DatetimeFilterType extends FilterType { @@ -48,11 +49,16 @@ public function getValueField(?string $value = null, ?string $operator = null): $date = \DateTime::createFromFormat(static::getQueryDataFormat(), (string) $value) ?: new \DateTime(); $value = $date->format(static::getDateFormat()); $locale = $this->requestStack->getMainRequest()?->getLocale(); - + $stimulusAttrs = (new StimulusHelper(null))->createStimulusAttributes(); + $stimulusAttrs + ->addController('araise/core-bundle/datetime', [ + 'lang' => $locale ?? 'en', + ]) + ; return sprintf( - '', + '', $operator !== static::CRITERIA_IS_EMPTY ? $value : '', - $locale ?? 'en' + $stimulusAttrs ); } From 808517d70d93066cf9497ad96f195531c46fe1c3 Mon Sep 17 00:00:00 2001 From: Marc Wieland Date: Wed, 18 Sep 2024 15:08:14 +0800 Subject: [PATCH 36/38] fix: style on mobile, add spacing on the left #119 --- src/Resources/views/tailwind_2/_header.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Resources/views/tailwind_2/_header.html.twig b/src/Resources/views/tailwind_2/_header.html.twig index 4f57d0f..ca8cca7 100644 --- a/src/Resources/views/tailwind_2/_header.html.twig +++ b/src/Resources/views/tailwind_2/_header.html.twig @@ -8,7 +8,7 @@ {% endif %}
-
+
{% if table.exporters|length > 0 and table.option('definition') and table.option('definition').hasCapability(constant('araise\\CrudBundle\\Enums\\Page::EXPORT')) %}
Date: Mon, 7 Oct 2024 12:26:41 +0200 Subject: [PATCH 37/38] feat(table): check view.route and add button visibilty --- src/Resources/views/tailwind_2/_header.html.twig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Resources/views/tailwind_2/_header.html.twig b/src/Resources/views/tailwind_2/_header.html.twig index ca8cca7..0b20c29 100644 --- a/src/Resources/views/tailwind_2/_header.html.twig +++ b/src/Resources/views/tailwind_2/_header.html.twig @@ -122,7 +122,10 @@ {% macro add_button(content, view, isOnShow) %} {% set createUrl = content.createUrl(view.data) %} - {% if createUrl and (content.addVoterAttribute is null or is_granted(content.addVoterAttribute, view.data)) %} + {% if createUrl + and (content.addVoterAttribute is null or is_granted(content.addVoterAttribute, view.data)) + and view.route in content.option(constant('araise\\CrudBundle\\Content\\RelationContent::OPT_ADD_VISIBILITY')) + %} {% set additionalClass = (not isOnShow) ? (content.option('attr')['class'] ?? '') : '' %} From 2c3786e843dea854035f760f70168bcfafb2f437 Mon Sep 17 00:00:00 2001 From: tuxes3 Date: Tue, 8 Oct 2024 13:29:39 +0200 Subject: [PATCH 38/38] chore: added Changelog for v1.2.0 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40ff2a2..53b4aec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # CHANGELOG +## v1.2.0 + - Removed symfony ^5.4 support + - Added Table option `OPT_SUB_TABLE_COLLAPSED`. This will collapse the sub table by default, you can also pass a callable to determine if the sub table should be collapsed or not + - Added footer columns to the table. This can be used to display totals or other information + - Fixed a bug where the table count would be of when using group by in the default query builder + - Date filters now use the `datetime_controller.js` provided by the core-bundle + - UX improvements + ## v1.0.7 - More documentation and better styling of the documentation - Added a new optional parameter to the `FilterTypeInterface::getValueField()` method to allow for more complex value fields.