Skip to content

Commit

Permalink
45582 geo-position field in interest forms (#779)
Browse files Browse the repository at this point in the history
* 45582 geo-position field in interest forms

* 45582 refactor code

* 45582 fix bug array splice

---------

Co-authored-by: Frederic Alpers <88546396+fredericalpers@users.noreply.github.com>
  • Loading branch information
yeneastgate and fredericalpers authored Jul 25, 2024
1 parent 94ef65d commit 862162f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ private function configureGeoFields(array $result): array
$geoPositionSettings = $this->_pGeoPositionFieldHandler->getActiveFields();
$fieldMapping = (new GeoPosition)->getSearchCriteriaFields();

$geoPositionFields = [];
foreach ($geoPositionSettings as $field) {
if ($this->_type === Form::TYPE_APPLICANT_SEARCH && $field === GeoPosition::ESTATE_LIST_SEARCH_RADIUS) {
continue;
Expand All @@ -253,9 +254,11 @@ private function configureGeoFields(array $result): array
'individual_fieldname' => 0,
];

$result []= $geoPositionField;
$geoPositionFields []= $geoPositionField;
}

array_splice($result, $arrayPosition, 0, $geoPositionFields);

return $result;
}

Expand Down
6 changes: 3 additions & 3 deletions plugin/Field/OutputFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ public function getVisibleFilterableFields(
unset($fieldsArray[$posGeo]);
$pGeoPositionFieldHandler->readValues($pDataView);
$geoFields = $pGeoPositionFieldHandler->getActiveFieldsWithValue();
array_splice($fieldsArray, $posGeo, 0, array_keys($geoFields));
}

$allFields = array_merge($fieldsArray, array_keys($geoFields));
$valuesDefault = array_map(function($field) use ($geoFields, $pInputVariableReader) {
$fieldValue = $pInputVariableReader->getFieldValueFormatted($field);
if ($fieldValue === false) {
return false;
}
return $fieldValue ?: $geoFields[$field] ?? null;
}, $allFields);
}, $fieldsArray);

$resultDefault = array_combine($allFields, $valuesDefault);
$resultDefault = array_combine($fieldsArray, $valuesDefault);

if ($posGeo !== false &&
empty($resultDefault[GeoPosition::ESTATE_LIST_SEARCH_CITY]) &&
Expand Down

0 comments on commit 862162f

Please sign in to comment.