ObjectSuggestions: Implement method shouldShowRelationFor()

This commit is contained in:
Johannes Meyer 2022-07-13 15:13:30 +02:00
parent 10577631b3
commit 87b66b11f0

View file

@ -91,6 +91,29 @@ class ObjectSuggestions extends Suggestions
return $this->model;
}
protected function shouldShowRelationFor(string $column): bool
{
if (strpos($column, '.vars.') !== false) {
return false;
}
$tableName = $this->getModel()->getTableName();
$columnPath = explode('.', $column);
switch (count($columnPath)) {
case 3:
if ($columnPath[1] !== 'state' || ! in_array($tableName, ['host', 'service'])) {
return true;
}
// For host/service state relation columns apply the same rules
case 2:
return $columnPath[0] !== $tableName;
default:
return true;
}
}
protected function createQuickSearchFilter($searchTerm)
{
$model = $this->getModel();