mirror of
https://github.com/Icinga/icingadb-web.git
synced 2026-05-28 04:36:06 -04:00
Merge pull request #173 from Icinga/utilize-native-filter-meta-data-instead-of-properties
Utilize native filter meta data instead of properties
This commit is contained in:
commit
3e2222cd7e
5 changed files with 11 additions and 23 deletions
|
|
@ -55,12 +55,7 @@ class Bitmask extends PropertyBehavior implements RewriteFilterBehavior
|
|||
|
||||
public function rewriteCondition(Condition $condition, $relation = null)
|
||||
{
|
||||
if (! isset($condition->relationCol)) {
|
||||
// TODO: Shouldn't be necessary. Solve this intelligently or do it elsewhere.
|
||||
return;
|
||||
}
|
||||
|
||||
$column = $condition->relationCol;
|
||||
$column = $condition->metaData()->get('columnName');
|
||||
if (! isset($this->properties[$column])) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,8 @@ class FlattenedObjectVars implements RewriteFilterBehavior
|
|||
{
|
||||
public function rewriteCondition(Filter\Condition $condition, $relation = null)
|
||||
{
|
||||
if (! isset($condition->relationCol)) {
|
||||
// TODO: Shouldn't be necessary. Solve this intelligently or do it elsewhere.
|
||||
return;
|
||||
}
|
||||
|
||||
$column = $condition->relationCol;
|
||||
if ($column !== 'flatname' && $column !== 'flatvalue') {
|
||||
$column = $condition->metaData()->get('columnName');
|
||||
if ($column !== null && $column !== 'flatname' && $column !== 'flatvalue') {
|
||||
$nameFilter = Filter::equal($relation . 'flatname', $column);
|
||||
$class = get_class($condition);
|
||||
$valueFilter = new $class($relation . 'flatvalue', $condition->getValue());
|
||||
|
|
|
|||
|
|
@ -23,12 +23,7 @@ class ReRoute implements RewriteFilterBehavior
|
|||
|
||||
public function rewriteCondition(Filter\Condition $condition, $relation = null)
|
||||
{
|
||||
if (! isset($condition->relationCol)) {
|
||||
// TODO: Shouldn't be necessary. Solve this intelligently or do it elsewhere.
|
||||
return;
|
||||
}
|
||||
|
||||
$column = $condition->relationCol;
|
||||
$column = $condition->metaData()->get('columnName', '');
|
||||
$dot = strpos($column, '.');
|
||||
if ($dot === false) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class ObjectSuggestions extends Suggestions
|
|||
$quickFilter = Filter::any();
|
||||
foreach ($model->getSearchColumns() as $column) {
|
||||
$where = Filter::equal($model->getTableName() . '.' . $column, $searchTerm);
|
||||
$where->columnLabel = $model->getMetaData()[$column];
|
||||
$where->metaData()->set('columnLabel', $model->getMetaData()[$column]);
|
||||
$quickFilter->add($where);
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +102,7 @@ class ObjectSuggestions extends Suggestions
|
|||
foreach ($query->getResolver()->getBehaviors($model) as $behavior) {
|
||||
if ($behavior instanceof ReRoute) {
|
||||
$expr = Filter::equal('', '');
|
||||
$expr->relationCol = $column;
|
||||
$expr->metaData()->set('columnName', $column);
|
||||
$expr = $behavior->rewriteCondition($expr, '');
|
||||
if ($expr !== null) {
|
||||
$column = $expr->getColumn();
|
||||
|
|
|
|||
|
|
@ -146,14 +146,17 @@ class Controller extends CompatController
|
|||
list($target, $varName) = explode('.vars.', $path);
|
||||
if (strpos($target, '.') === false) {
|
||||
// Programmatically translated since the full definition is available in class ObjectSuggestions
|
||||
$condition->columnLabel = sprintf(t(ucfirst($target) . ' %s', '..<customvar-name>'), $varName);
|
||||
$condition->metaData()->set(
|
||||
'columnLabel',
|
||||
sprintf(t(ucfirst($target) . ' %s', '..<customvar-name>'), $varName)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$metaData = iterator_to_array(
|
||||
ObjectSuggestions::collectFilterColumns($query->getModel(), $query->getResolver())
|
||||
);
|
||||
if (isset($metaData[$path])) {
|
||||
$condition->columnLabel = $metaData[$path];
|
||||
$condition->metaData()->set('columnLabel', $metaData[$path]);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue