Skip to content

Conversation

@emololftw
Copy link
Contributor

Refactor dataSource filtering for NextrasDataSource to use Collection function

Refactored the filtering logic in NextrasDataSource to utilize the Collection function within filterCondition. This change improves code consistency and leverages existing Collection utilities.

Changes:

  1. Updated filtering implementation to use Collection function inside filterCondition
  2. Maintained full backward compatibility - both existing and new approaches work seamlessly

Working cases:

$grid->addFilterText('params', 'Parameters:', 'params')
	->setCondition(function (DbalCollection $dbalCollection, $value) {
		return $dbalCollection->findBy([
			'parametersValues->parameterListValue->id' => (array) $value
		]);
	});
$grid->addFilterText('params', 'Parameters:', 'params')
	->setCondition(function (DbalCollection $dbalCollection, $value) {
		$dbalCollection
			->getQueryBuilder()
			->joinLeft('[parameters_values_x_scrap_data] as [pvxsd]', '[scrap_data.id] = [pvxsd.scrap_data_id]')
			->joinLeft('[parameters_values] as [pv]', '[pvxsd.parameters_values_id] = [pv.id]')
			->andWhere('[pv.parameter_list_value] IN %i[]', (array) $value);
		})
	});

PS: sorry, I accidentally deleted my last personal repository

@emololftw
Copy link
Contributor Author

related to: #298

@radimvaculik
Copy link
Member

@paveljanda 👀

@emololftw
Copy link
Contributor Author

👉👈

@paveljanda
Copy link
Member

This really imho does not make any sense. When there is some spetial behaviour in Nextras, in should be handled in Nextras ano not in the parent abstract class.

@radimvaculik
Copy link
Member

@emololftw Ping.

@emololftw
Copy link
Contributor Author

@radimvaculik @paveljanda I'm so sorry for my late response. Of course, you're right - this specific behavior is useless to keep in the general class. Would you be open to accepting it if I implement it in the Nextras class case instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants