Skip to content

Commit

Permalink
Flex admin: added default search options for flex objects
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Apr 30, 2019
1 parent c5b3792 commit fea9e53
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Added `Route::withoutParams()` methods
* Added `Pages::setCheckMethod()` method to override page configuration in Admin Plugin
* Added `Cache::clearCache('invalidate')` parameter for just invalidating the cache without deleting any cached files
1. [](#improved)
* Flex admin: added default search options for flex objects
1. [](#bugfix)
* Fixed `$grav['route']` from being modified when the route instance gets modified
* Fixed Assets options array mixed with standalone priority [#2477](https://github.com/getgrav/grav/issues/2477)
Expand Down
9 changes: 8 additions & 1 deletion system/src/Grav/Framework/Flex/FlexObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ public function search(string $search, $properties = null, array $options = null
{
$options = $options ?? $this->getFlexDirectory()->getConfig('data.search.options', []);
$properties = $properties ?? $this->getFlexDirectory()->getConfig('data.search.fields', []);
if (!$properties) {
foreach ($this->getFlexDirectory()->getConfig('admin.list.fields', []) as $property => $value) {
if (!empty($value['link'])) {
$properties[] = $property;
}
}
}

$weight = 0;
foreach ((array)$properties as $property) {
Expand Down Expand Up @@ -273,7 +280,7 @@ protected function searchValue(string $name, $value, string $search, array $opti
return (float)$options['ends_with'];
}
if ((!$tested || !empty($options['contains'])) && Utils::contains($value, $search, $options['case_sensitive'] ?? false)) {
return (float)$options['contains'];
return (float)($options['contains'] ?? 1);
}

return 0;
Expand Down

0 comments on commit fea9e53

Please sign in to comment.