mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Fix text filter scope (#4445)
Credit to @alxy. Fixes https://github.com/octobercms/october/pull/4241#issuecomment-510140574
This commit is contained in:
parent
22847e7892
commit
7557173df4
@ -116,7 +116,7 @@ class Filter extends WidgetBase
|
||||
$after = $scope->value[0]->format('Y-m-d H:i:s');
|
||||
$before = $scope->value[1]->format('Y-m-d H:i:s');
|
||||
|
||||
if(strcasecmp($after, '0000-00-00 00:00:00') > 0) {
|
||||
if (strcasecmp($after, '0000-00-00 00:00:00') > 0) {
|
||||
$params['afterStr'] = Backend::dateTime($scope->value[0], ['formatAlias' => 'dateMin']);
|
||||
$params['after'] = $after;
|
||||
}
|
||||
@ -125,7 +125,7 @@ class Filter extends WidgetBase
|
||||
$params['after'] = null;
|
||||
}
|
||||
|
||||
if(strcasecmp($before, '2999-12-31 23:59:59') < 0) {
|
||||
if (strcasecmp($before, '2999-12-31 23:59:59') < 0) {
|
||||
$params['beforeStr'] = Backend::dateTime($scope->value[1], ['formatAlias' => 'dateMin']);
|
||||
$params['before'] = $before;
|
||||
}
|
||||
@ -261,15 +261,7 @@ class Filter extends WidgetBase
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
$values = post('options.value');
|
||||
|
||||
if ($values !== null && $values !== '') {
|
||||
list($value) = $values;
|
||||
}
|
||||
else {
|
||||
$value = null;
|
||||
}
|
||||
|
||||
$value = post('options.value.' . $scope->scopeName) ?: null;
|
||||
$this->setScopeValue($scope, $value);
|
||||
break;
|
||||
}
|
||||
@ -567,7 +559,6 @@ class Filter extends WidgetBase
|
||||
public function addScopes(array $scopes)
|
||||
{
|
||||
foreach ($scopes as $name => $config) {
|
||||
|
||||
$scopeObj = $this->makeFilterScope($name, $config);
|
||||
|
||||
/*
|
||||
@ -715,7 +706,6 @@ class Filter extends WidgetBase
|
||||
list($after, $before) = array_values($scope->value);
|
||||
|
||||
if ($after && $after instanceof Carbon && $before && $before instanceof Carbon) {
|
||||
|
||||
/*
|
||||
* Condition
|
||||
*/
|
||||
@ -763,7 +753,6 @@ class Filter extends WidgetBase
|
||||
list($min, $max) = array_values($scope->value);
|
||||
|
||||
if ($min && $max) {
|
||||
|
||||
/*
|
||||
* Condition
|
||||
*
|
||||
@ -811,7 +800,6 @@ class Filter extends WidgetBase
|
||||
* Condition
|
||||
*/
|
||||
if ($scopeConditions = $scope->conditions) {
|
||||
|
||||
/*
|
||||
* Switch scope: multiple conditions, value either 1 or 2
|
||||
*/
|
||||
@ -976,7 +964,7 @@ class Filter extends WidgetBase
|
||||
|
||||
if (null !== $ajaxDates) {
|
||||
if (!is_array($ajaxDates)) {
|
||||
if(preg_match($dateRegex, $ajaxDates)) {
|
||||
if (preg_match($dateRegex, $ajaxDates)) {
|
||||
$dates = [$ajaxDates];
|
||||
}
|
||||
} else {
|
||||
@ -984,7 +972,7 @@ class Filter extends WidgetBase
|
||||
if (preg_match($dateRegex, $date)) {
|
||||
$dates[] = Carbon::createFromFormat('Y-m-d H:i:s', $date);
|
||||
} elseif (empty($date)) {
|
||||
if($i == 0) {
|
||||
if ($i == 0) {
|
||||
$dates[] = Carbon::createFromFormat('Y-m-d H:i:s', '0000-00-00 00:00:00');
|
||||
} else {
|
||||
$dates[] = Carbon::createFromFormat('Y-m-d H:i:s', '2999-12-31 23:59:59');
|
||||
|
@ -2,7 +2,7 @@
|
||||
<label class="filter-label">
|
||||
<?= e(trans($scope->label)) ?>:
|
||||
<input type="text"
|
||||
name="options[value][]"
|
||||
name="options[value][<?= $scope->scopeName ?>]"
|
||||
data-request="<?= $this->getEventHandler('onFilterUpdate') ?>"
|
||||
data-request-data="'scopeName':'<?= $scope->scopeName ?>'"
|
||||
data-track-input
|
||||
|
Loading…
x
Reference in New Issue
Block a user