Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
ff4d10b7
Commit
ff4d10b7
authored
Dec 01, 2014
by
Dries
Browse files
Issue
#2357145
by alexpott, olli, YesCT: Views can not be saved with a numeric (grouped) filter
parent
8839de5c
Changes
5
Hide whitespace changes
Inline
Side-by-side
core/modules/config/src/Tests/SchemaCheckTestTrait.php
View file @
ff4d10b7
...
...
@@ -49,4 +49,16 @@ public function assertConfigSchema(TypedConfigManagerInterface $typed_config, $c
}
}
}
/**
* Asserts configuration, specified by name, has a valid schema.
*
* @param string $config_name
* The configuration name.
*/
public
function
assertConfigSchemaByName
(
$config_name
)
{
$config
=
\
Drupal
::
config
(
$config_name
);
$this
->
assertConfigSchema
(
\
Drupal
::
service
(
'config.typed'
),
$config
->
getName
(),
$config
->
get
());
}
}
core/modules/views/config/schema/views.data_types.schema.yml
View file @
ff4d10b7
...
...
@@ -748,27 +748,28 @@ views_filter:
-
type
:
integer
label
:
'
Default'
group_items
:
type
:
views.filter.group_items.[plugin_id]
type
:
sequence
label
:
'
Group
items'
sequence
:
-
type
:
views.filter.group_item.[%parent.%parent.%parent.plugin_id]
label
:
'
Group
item'
plugin_id
:
type
:
string
label
:
'
Plugin
ID'
views_filter_group_items
:
type
:
sequence
sequence
:
-
type
:
mapping
label
:
'
Group
item'
mapping
:
title
:
type
:
label
label
:
'
Label'
operator
:
type
:
string
label
:
'
Operator'
value
:
type
:
label
label
:
'
Value'
views_filter_group_item
:
type
:
mapping
label
:
'
Group
item'
mapping
:
title
:
type
:
label
label
:
'
Label'
operator
:
type
:
string
label
:
'
Operator'
value
:
type
:
label
label
:
'
Value'
views_relationship
:
type
:
mapping
...
...
core/modules/views/config/schema/views.filter.schema.yml
View file @
ff4d10b7
...
...
@@ -31,12 +31,16 @@ views.filter.combine:
-
type
:
string
label
:
'
Field'
views.filter.date
:
type
:
views.filter.numeric
views.filter
_value
.date
:
type
:
views.filter
_value
.numeric
label
:
'
Date'
mapping
:
type
:
type
:
string
label
:
'
Type'
views.filter.groupby_numeric
:
type
:
views.filter.numeric
views.filter
_value
.groupby_numeric
:
type
:
views.filter
_value
.numeric
label
:
'
Group
by
numeric'
views.filter.in_operator
:
...
...
@@ -75,29 +79,22 @@ views.filter.string:
type
:
string
label
:
'
Value'
views.filter.numeric
:
type
:
views_filter
views.filter
_value
.numeric
:
type
:
mapping
label
:
'
Numeric'
mapping
:
min
:
type
:
string
label
:
'
Min'
max
:
type
:
string
label
:
'
And
max'
value
:
type
:
mapping
label
:
'
Operator'
mapping
:
min
:
type
:
string
label
:
'
Min'
max
:
type
:
string
label
:
'
And
max'
value
:
type
:
string
label
:
'
Value'
type
:
type
:
string
label
:
'
Value
type'
type
:
string
label
:
'
Value'
views.filter.equality
:
type
:
views.filter.numeric
views.filter
_value
.equality
:
type
:
views.filter
_value
.numeric
label
:
'
Equality'
views.filter.many_to_one
:
...
...
@@ -121,17 +118,16 @@ views.filter.standard:
type
:
views_filter
label
:
'
Standard'
views.filter.group_item
s
.*
:
type
:
views_filter_group_item
s
views.filter.group_item.*
:
type
:
views_filter_group_item
label
:
'
Default'
views.filter.group_items.string
:
type
:
views_filter_group_items
label
:
'
String
group
items'
views.filter.group_items.boolean
:
type
:
views_filter_group_items
views.filter.group_item.numeric
:
type
:
views_filter_group_item
label
:
'
Group
items'
mapping
:
value
:
type
:
views.filter_value.numeric
# Schema for the views filter value.
...
...
core/modules/views/tests/modules/views_test_config/test_views/views.view.test_view.yml
View file @
ff4d10b7
...
...
@@ -42,7 +42,6 @@ display:
options
:
offset
:
0
type
:
none
pager_options
:
{
}
sorts
:
id
:
field
:
id
...
...
core/modules/views_ui/src/Tests/FilterNumericWebTest.php
0 → 100644
View file @
ff4d10b7
<?php
/**
* @file
* Contains \Drupal\views_ui\Tests\FilterNumericWebTest.
*/
namespace
Drupal\views_ui\Tests
;
use
Drupal\config\Tests\SchemaCheckTestTrait
;
/**
* Tests the numeric filter UI.
*
* @group views_ui
* @see \Drupal\views\Plugin\views\filter\Numeric
*/
class
FilterNumericWebTest
extends
UITestBase
{
use
SchemaCheckTestTrait
;
/**
* Views used by this test.
*
* @var array
*/
public
static
$testViews
=
array
(
'test_view'
);
/**
* Tests the filter numeric UI.
*/
public
function
testFilterNumericUI
()
{
$this
->
drupalPostForm
(
'admin/structure/views/nojs/add-handler/test_view/default/filter'
,
array
(
'name[views_test_data.age]'
=>
TRUE
),
t
(
'Add and configure @handler'
,
array
(
'@handler'
=>
t
(
'filter criteria'
))));
$this
->
drupalPostForm
(
NULL
,
array
(),
t
(
'Expose filter'
));
$this
->
drupalPostForm
(
NULL
,
array
(),
t
(
'Grouped filters'
));
$edit
=
array
();
$edit
[
'options[group_info][group_items][1][title]'
]
=
'Old'
;
$edit
[
'options[group_info][group_items][1][operator]'
]
=
'>'
;
$edit
[
'options[group_info][group_items][1][value][value]'
]
=
27
;
$edit
[
'options[group_info][group_items][2][title]'
]
=
'Young'
;
$edit
[
'options[group_info][group_items][2][operator]'
]
=
'<='
;
$edit
[
'options[group_info][group_items][2][value][value]'
]
=
27
;
$edit
[
'options[group_info][group_items][3][title]'
]
=
'From 26 to 28'
;
$edit
[
'options[group_info][group_items][3][operator]'
]
=
'between'
;
$edit
[
'options[group_info][group_items][3][value][min]'
]
=
26
;
$edit
[
'options[group_info][group_items][3][value][max]'
]
=
28
;
$this
->
drupalPostForm
(
NULL
,
$edit
,
t
(
'Apply'
));
$this
->
drupalGet
(
'admin/structure/views/nojs/handler/test_view/default/filter/age'
);
foreach
(
$edit
as
$name
=>
$value
)
{
$this
->
assertFieldByName
(
$name
,
$value
);
}
$this
->
drupalPostForm
(
'admin/structure/views/view/test_view'
,
array
(),
t
(
'Save'
));
$this
->
assertConfigSchemaByName
(
'views.view.test_view'
);
// Test that the exposed filter works as expected.
$this
->
drupalPostForm
(
NULL
,
array
(),
t
(
'Update preview'
));
$this
->
assertText
(
'John'
);
$this
->
assertText
(
'Paul'
);
$this
->
assertText
(
'Ringo'
);
$this
->
assertText
(
'George'
);
$this
->
assertText
(
'Meredith'
);
$this
->
drupalPostForm
(
NULL
,
array
(
'age'
=>
'2'
),
t
(
'Update preview'
));
$this
->
assertText
(
'John'
);
$this
->
assertText
(
'Paul'
);
$this
->
assertNoText
(
'Ringo'
);
$this
->
assertText
(
'George'
);
$this
->
assertNoText
(
'Meredith'
);
// Change the filter to a single filter to test the schema when the operator
// is not exposed.
$this
->
drupalPostForm
(
'admin/structure/views/nojs/handler/test_view/default/filter/age'
,
array
(),
t
(
'Single filter'
));
$edit
=
array
();
$edit
[
'options[value][value]'
]
=
25
;
$this
->
drupalPostForm
(
NULL
,
$edit
,
t
(
'Apply'
));
$this
->
drupalPostForm
(
'admin/structure/views/view/test_view'
,
array
(),
t
(
'Save'
));
$this
->
assertConfigSchemaByName
(
'views.view.test_view'
);
// Test that the filter works as expected.
$this
->
drupalPostForm
(
NULL
,
array
(),
t
(
'Update preview'
));
$this
->
assertText
(
'John'
);
$this
->
assertNoText
(
'Paul'
);
$this
->
assertNoText
(
'Ringo'
);
$this
->
assertNoText
(
'George'
);
$this
->
assertNoText
(
'Meredith'
);
$this
->
drupalPostForm
(
NULL
,
array
(
'age'
=>
'26'
),
t
(
'Update preview'
));
$this
->
assertNoText
(
'John'
);
$this
->
assertText
(
'Paul'
);
$this
->
assertNoText
(
'Ringo'
);
$this
->
assertNoText
(
'George'
);
$this
->
assertNoText
(
'Meredith'
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment