mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
[report list] fix "all fields are always shown"
This commit is contained in:
parent
6d8d99c572
commit
67d62e8d03
6
CHANGELOG.md
Normal file
6
CHANGELOG.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
Branch master
|
||||||
|
=============
|
||||||
|
|
||||||
|
- [list export] fix error "all custom fields are shown"
|
||||||
|
|
@ -447,11 +447,14 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
|||||||
|
|
||||||
$qb = $this->em->createQueryBuilder();
|
$qb = $this->em->createQueryBuilder();
|
||||||
|
|
||||||
|
// process fields which are not custom fields
|
||||||
foreach ($this->fields as $f) {
|
foreach ($this->fields as $f) {
|
||||||
|
// do not add fields which are not selected
|
||||||
if (!\in_array($f, $data['fields'])) {
|
if (!\in_array($f, $data['fields'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add a column to the query for each field
|
||||||
switch ($f) {
|
switch ($f) {
|
||||||
case 'person_countryOfBirth':
|
case 'person_countryOfBirth':
|
||||||
case 'person_nationality':
|
case 'person_nationality':
|
||||||
@ -500,10 +503,16 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// process fields which are custom fields
|
||||||
foreach ($this->getCustomFields() as $cf) {
|
foreach ($this->getCustomFields() as $cf) {
|
||||||
|
// do not add custom fields which are not selected
|
||||||
|
if (!\in_array($cf->getSlug(), $data['fields'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$cfType = $this->customFieldProvider->getCustomFieldByType($cf->getType());
|
$cfType = $this->customFieldProvider->getCustomFieldByType($cf->getType());
|
||||||
|
|
||||||
|
// if is multiple, split into multiple columns
|
||||||
if ($cfType instanceof CustomFieldChoice and $cfType->isMultiple($cf)) {
|
if ($cfType instanceof CustomFieldChoice and $cfType->isMultiple($cf)) {
|
||||||
foreach($cfType->getChoices($cf) as $choiceSlug => $label) {
|
foreach($cfType->getChoices($cf) as $choiceSlug => $label) {
|
||||||
$slug = $this->slugToDQL($cf->getSlug(), 'choice', [ 'choiceSlug' => $choiceSlug ]);
|
$slug = $this->slugToDQL($cf->getSlug(), 'choice', [ 'choiceSlug' => $choiceSlug ]);
|
||||||
@ -513,6 +522,7 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
|||||||
$qb->setParameter(sprintf('slug%s', $slug), $cf->getSlug());
|
$qb->setParameter(sprintf('slug%s', $slug), $cf->getSlug());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// not multiple, add a single column
|
||||||
$slug = $this->slugToDQL($cf->getSlug());
|
$slug = $this->slugToDQL($cf->getSlug());
|
||||||
$qb->addSelect(
|
$qb->addSelect(
|
||||||
sprintf('GET_JSON_FIELD_BY_KEY(report.cFData, :slug%s) AS %s',
|
sprintf('GET_JSON_FIELD_BY_KEY(report.cFData, :slug%s) AS %s',
|
||||||
@ -531,7 +541,6 @@ class ReportList implements ListInterface, ExportElementValidatedInterface
|
|||||||
->setParameter('authorized_centers', $centers);
|
->setParameter('authorized_centers', $centers);
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
return $qb;
|
return $qb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user