Skip to content

Commit

Permalink
43305 refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
yeneastgate committed Jan 16, 2024
1 parent cb96348 commit 51669e5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions plugin/Field/OutputFields.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ public function getVisibleFilterableFields(

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

$resultDefault = array_combine($allFields, $valuesDefault);
Expand Down
2 changes: 1 addition & 1 deletion templates.dist/fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function renderFormField(string $fieldName, onOffice\WPlugin\Form $pForm, bool $
} elseif ($typeCurrentInput === FieldTypes::FIELD_TYPE_DATATYPE_TINYINT) {
$output = '<fieldset>
<input type="radio" id="' . esc_attr($fieldName) . '_u" name="' . esc_attr($fieldName) . '" value=""
' . ($selectedValue === "" ? ' checked' : '') . '>
' . ($selectedValue === null ? ' checked' : '') . '>
<label for="' . esc_attr($fieldName) . '_u">' . esc_html__('Not Specified', 'onoffice-for-wp-websites') . '</label>
<input type="radio" id="' . esc_attr($fieldName) . '_y" name="' . esc_attr($fieldName) . '" value="1"
' . ($selectedValue == 2 ? 'checked' : '') . '>
Expand Down
5 changes: 4 additions & 1 deletion tests/TestClassFieldsCollectionBuilderShort.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use onOffice\WPlugin\Region\RegionController;
use onOffice\WPlugin\SDKWrapper;
use onOffice\WPlugin\Types\FieldsCollection;
use onOffice\WPlugin\Types\Field;
use WP_UnitTestCase;
use function json_decode;

Expand Down Expand Up @@ -252,7 +253,9 @@ public function testCombination()
public function testAddFieldSupervisorForSearchCriteria()
{
$pFieldsCollection = new FieldsCollection();
$field = new Field('benutzer', onOfficeSDK::MODULE_SEARCHCRITERIA, 'testLabel');
$pFieldsCollection->addField($field);
$this->assertSame($this->_pSubject, $this->_pSubject->addFieldSupervisorForSearchCriteria($pFieldsCollection));
$this->assertCount(1, $pFieldsCollection->getAllFields());
$this->assertCount(2, $pFieldsCollection->getAllFields());
}
}

0 comments on commit 51669e5

Please sign in to comment.