From 277ca60d35753de0b4f133b0b26ecdf3a5d816d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20M=C3=AD=C4=8Dka?= Date: Wed, 23 Oct 2024 14:54:43 +0200 Subject: [PATCH 1/2] fix: adding multiple listeners to the same element --- assets/plugins/features/autosubmit.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/assets/plugins/features/autosubmit.ts b/assets/plugins/features/autosubmit.ts index 2a9dfacd..96aa4310 100644 --- a/assets/plugins/features/autosubmit.ts +++ b/assets/plugins/features/autosubmit.ts @@ -46,6 +46,11 @@ export class AutosubmitPlugin implements DatagridPlugin { const form = submitEl.closest("form"); if (!form) return; + if (submitEl.dataset.listenersAttached === "true") { + return; // Skip if listeners are already attached + } + submitEl.dataset.listenersAttached = "true"; + // Select auto-submit if (submitEl instanceof HTMLSelectElement) { submitEl.addEventListener("change", () => datagrid.ajax.submitForm(form)); From 6f44dbf500f60239f129f1ad68d3dc8d7cc47a0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20M=C3=AD=C4=8Dka?= Date: Fri, 1 Nov 2024 14:47:27 +0100 Subject: [PATCH 2/2] replace deprecated dibi::IDENTIFIER with Fluent::Identifier --- src/DataSource/DibiFluentDataSource.php | 3 +-- src/DataSource/DibiFluentMssqlDataSource.php | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/DataSource/DibiFluentDataSource.php b/src/DataSource/DibiFluentDataSource.php index ecce4212..d2fdea4d 100755 --- a/src/DataSource/DibiFluentDataSource.php +++ b/src/DataSource/DibiFluentDataSource.php @@ -13,7 +13,6 @@ use Contributte\Datagrid\Filter\FilterText; use Contributte\Datagrid\Utils\DateTimeHelper; use Contributte\Datagrid\Utils\Sorting; -use dibi; use Dibi\Fluent; use Dibi\Helpers; use ReflectionClass; @@ -167,7 +166,7 @@ protected function applyFilterText(FilterText $filter): void $or = []; foreach ($condition as $column => $value) { - $column = Helpers::escape($driver, $column, dibi::IDENTIFIER); + $column = Helpers::escape($driver, $column, Fluent::Identifier); if ($filter->isExactSearch()) { $this->dataSource->where(sprintf('%s = %%s', $column), $value); diff --git a/src/DataSource/DibiFluentMssqlDataSource.php b/src/DataSource/DibiFluentMssqlDataSource.php index 641ddb71..c4ff7942 100755 --- a/src/DataSource/DibiFluentMssqlDataSource.php +++ b/src/DataSource/DibiFluentMssqlDataSource.php @@ -7,7 +7,6 @@ use Contributte\Datagrid\Filter\FilterDateRange; use Contributte\Datagrid\Filter\FilterText; use Contributte\Datagrid\Utils\DateTimeHelper; -use dibi; use Dibi\Fluent; use Dibi\Helpers; use Dibi\Result; @@ -108,7 +107,7 @@ protected function applyFilterText(FilterText $filter): void $or = []; foreach ($condition as $column => $value) { - $column = Helpers::escape($driver, $column, dibi::IDENTIFIER); + $column = Helpers::escape($driver, $column, Fluent::Identifier); if ($filter->isExactSearch()) { $this->dataSource->where(sprintf('%s = %%s', $column), $value);