Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize native filter meta data instead of properties #12

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Control/SearchBar/Suggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function filterToTerms(Filter\Chain $filter)

$terms[] = [
'search' => $child->getColumn(),
'label' => $child->columnLabel,
'label' => $child->metaData()->get('columnLabel'),
'type' => 'column'
];
$terms[] = [
Expand Down
6 changes: 1 addition & 5 deletions src/Control/SearchBar/Terms.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ protected function assembleCondition(Filter\Condition $filter, BaseHtmlElement $
$column = $filter->getColumn();
$operator = QueryString::getRuleSymbol($filter);
$value = $filter->getValue();

$columnLabel = $column;
if (isset($filter->columnLabel)) {
$columnLabel = $filter->columnLabel;
}
$columnLabel = $filter->metaData()->get('columnLabel', $column);

$group = new HtmlElement(
'div',
Expand Down
15 changes: 7 additions & 8 deletions src/Control/SearchEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected function applyChanges(Filter\Rule $rule, array &$values, array $path =
$newColumn = $this->popKey($values, $identifier . '-column');
} else {
// Make sure we don't forget to present the column labels again
$rule->columnLabel = $this->popKey($values, $identifier . '-column');
$rule->metaData()->set('columnLabel', $this->popKey($values, $identifier . '-column'));
}

if ($newColumn !== null && $rule->getColumn() !== $newColumn) {
Expand Down Expand Up @@ -414,11 +414,12 @@ protected function createButtons(Filter\Rule $for, $identifier)
protected function createCondition(Filter\Condition $condition, $identifier)
{
$columnInput = $this->createElement('text', $identifier . '-column', [
'value' => isset($condition->columnLabel)
? $condition->columnLabel
: ($condition->getColumn() !== static::FAKE_COLUMN
'value' => $condition->metaData()->get(
'columnLabel',
$condition->getColumn() !== static::FAKE_COLUMN
? $condition->getColumn()
: null),
: null
),
'required' => true,
'autocomplete' => 'off',
'data-type' => 'column',
Expand Down Expand Up @@ -471,9 +472,7 @@ protected function createCondition(Filter\Condition $condition, $identifier)
}

$columnSearchInput->setValue($condition->getColumn());
$columnInput->setValue(isset($condition->columnLabel)
? $condition->columnLabel
: $condition->getColumn());
$columnInput->setValue($condition->metaData()->get('columnLabel', $condition->getColumn()));

return true;
}]
Expand Down