36 if ($currentPresetId && isset($presets[$currentPresetId]))
38 $preset[$currentPresetId][
'default'] =
true;
44 return $this->buildUi($filterId, $currentPresetId, $presets, $filter);
58 if ($currentPresetId && isset($presets[$currentPresetId]))
60 $preset[$currentPresetId][
'default'] =
true;
67 return $this->buildUi($filterId, $currentPresetId, $presets, $filter);
70 private function buildUi($filterId, $currentPresetId, $presets, $filter)
242 $filterFields = static::getFilterFields();
243 $filterOptions =
new FilterOptions($filterId, static::getUiFilterPresets());
244 $filterRequest = $filterOptions->getFilter($filterFields);
246 $filterData = array();
247 foreach ($filterFields as $field)
249 $fieldId = $field[
'id'];
250 if ($field[
'type'] ===
'dest_selector')
252 $destSelectorData = Filter\DestSelectorField::create($field)->fetchFieldValue($filterRequest);
253 if ($destSelectorData)
255 $filterData[$fieldId] = $destSelectorData;
258 elseif (isset($filterRequest[$fieldId]))
260 $filterData[$fieldId] = $filterRequest[$fieldId];
262 elseif ($field[
'type'] ===
'date')
264 $dateData = Filter\DateField::create($field)->fetchFieldValue($filterRequest);
265 if (is_array($dateData) && count($dateData))
267 $filterData[$fieldId] = $dateData;
270 elseif ($field[
'type'] ===
'number')
273 $fieldId .
'_numsel',
276 if (is_array($numberData) && count($numberData))
278 if (count($numberData) > 1 || $numberData[$fieldId .
'_numsel'] !==
null)
280 $filterData[$fieldId] = $numberData;
286 if (isset($filterRequest[
'PRESET_ID']) && array_key_exists($filterRequest[
'PRESET_ID'], static::getUiFilterPresets()))
329 $filterOptions =
new FilterOptions($filterId, static::getUiFilterPresets());
330 $settings = $filterOptions->getOptions();
332 if ($settings && ($settings[
'filter'] ??
false))
334 $filterPresetIds = [
'tmp_filter', $settings[
'filter']];
335 foreach ($filterPresetIds as $filterPresetId)
337 $presetSettings = $filterOptions->getFilterSettings($filterPresetId);
338 if ($presetSettings && ($presetSettings[
'fields'] ??
false))
340 $filterOptions->setFilterSettings($filterPresetId, [
'clear_filter' =>
'Y']);
347 $filterOptions->save();