Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
225
Merge Requests
225
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
fcbf91be
Commit
fcbf91be
authored
Dec 21, 2015
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2621874
by czigor, Lendude, dawehner: "Hide empty column" only hides the header
parent
14cfbd4e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
core/modules/views/src/Tests/Plugin/StyleTableTest.php
core/modules/views/src/Tests/Plugin/StyleTableTest.php
+19
-0
core/modules/views/tests/modules/views_test_config/test_views/views.view.test_table.yml
...es/views_test_config/test_views/views.view.test_table.yml
+1
-1
core/modules/views/views.theme.inc
core/modules/views/views.theme.inc
+3
-3
No files found.
core/modules/views/src/Tests/Plugin/StyleTableTest.php
View file @
fcbf91be
...
...
@@ -136,4 +136,23 @@ public function testNumericFieldVisible() {
$this
->
assertTrue
(
count
(
$result
),
'Ensure that the baby\'s age is shown'
);
}
/**
* Test that empty columns are hidden when empty_column is set.
*/
public
function
testEmptyColumn
()
{
// Empty the 'job' data.
\
Drupal
::
database
()
->
update
(
'views_test_data'
)
->
fields
([
'job'
=>
''
])
->
execute
();
$this
->
drupalGet
(
'test-table'
);
// Test that only one of the job columns still shows.
$result
=
$this
->
xpath
(
'//thead/tr/th/a[text()="Job"]'
);
$this
->
assertEqual
(
count
(
$result
),
1
,
'Ensure that empty column header is hidden.'
);
$result
=
$this
->
xpath
(
'//tbody/tr/td[contains(concat(" ", @class, " "), " views-field-job-1 ")]'
);
$this
->
assertEqual
(
count
(
$result
),
0
,
'Ensure the empty table cells are hidden.'
);
}
}
core/modules/views/tests/modules/views_test_config/test_views/views.view.test_table.yml
View file @
fcbf91be
...
...
@@ -108,7 +108,7 @@ display:
default_sort_order
:
asc
align
:
'
'
separator
:
'
'
empty_column
:
fals
e
empty_column
:
tru
e
responsive
:
'
'
default
:
id
empty_table
:
true
...
...
core/modules/views/views.theme.inc
View file @
fcbf91be
...
...
@@ -552,13 +552,13 @@ function template_preprocess_views_view_table(&$variables) {
if
(
!
empty
(
$options
[
'info'
][
$field
][
'empty_column'
]))
{
$empty
=
TRUE
;
foreach
(
$variables
[
'rows'
]
as
$columns
)
{
$empty
&=
empty
(
$columns
[
$column
]);
$empty
&=
empty
(
$columns
[
'columns'
][
$column
][
'content'
]);
}
if
(
$empty
)
{
foreach
(
$variables
[
'rows'
]
as
&
$column_items
)
{
unset
(
$column_items
[
$column
]);
unset
(
$variables
[
'header'
][
$column
]);
unset
(
$column_items
[
'columns'
][
$column
]);
}
unset
(
$variables
[
'header'
][
$column
]);
}
}
}
...
...
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