Skip to content

Commit

Permalink
fix: adding multiple listeners to the same element (#1153)
Browse files Browse the repository at this point in the history
* fix: adding multiple listeners to the same element

* replace deprecated dibi::IDENTIFIER with Fluent::Identifier
  • Loading branch information
to23mas authored Nov 1, 2024
1 parent 0105ca3 commit 04f0e4b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions assets/plugins/features/autosubmit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions src/DataSource/DibiFluentDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/DataSource/DibiFluentMssqlDataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 04f0e4b

Please sign in to comment.