Issue #2397495 by geertvd, jhedstrom: Disabling 'Display all values in the same row' shows all values in all rows
parent
8e52db72db
commit
38b742768a
|
@ -739,7 +739,7 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt
|
|||
if (!$original_entity) {
|
||||
return array();
|
||||
}
|
||||
$entity = $this->process_entity($original_entity);
|
||||
$entity = $this->process_entity($values, $original_entity);
|
||||
if (!$entity) {
|
||||
return array();
|
||||
}
|
||||
|
@ -781,13 +781,15 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt
|
|||
* Replaces values with aggregated values if aggregation is enabled.
|
||||
* Takes delta settings into account (@todo remove in #1758616).
|
||||
*
|
||||
* @param \Drupal\views\ResultRow $values
|
||||
* The result row object containing the values.
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity to be processed.
|
||||
*
|
||||
* @return
|
||||
* TRUE if the processing completed successfully, otherwise FALSE.
|
||||
*/
|
||||
function process_entity(EntityInterface $entity) {
|
||||
function process_entity(ResultRow $values, EntityInterface $entity) {
|
||||
$processed_entity = clone $entity;
|
||||
|
||||
$langcode = $this->field_langcode($processed_entity);
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains Drupal\views\Tests\Handler\FieldGroupRowsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\views\Tests\Handler;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests the "Display all values in the same row" setting.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\field\Field
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class FieldGroupRowsTest extends HandlerTestBase {
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_group_rows', 'test_ungroup_rows');
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node', 'field_test');
|
||||
|
||||
/**
|
||||
* Field that will be created to test the group/ungroup rows functionality
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $fieldName = 'field_group_rows';
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create content type with unlimited text field.
|
||||
$node_type = $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
|
||||
|
||||
// Create the unlimited text field.
|
||||
$field_storage = entity_create('field_storage_config', array(
|
||||
'field_name' => $this->fieldName,
|
||||
'entity_type' => 'node',
|
||||
'type' => 'text',
|
||||
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
|
||||
));
|
||||
$field_storage->save();
|
||||
|
||||
// Create an instance of the text field on the content type.
|
||||
$field = array(
|
||||
'field_storage' => $field_storage,
|
||||
'bundle' => $node_type->type,
|
||||
);
|
||||
entity_create('field_config', $field)->save();
|
||||
|
||||
$this->container->get('views.views_data')->clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing the "Grouped rows" functionality.
|
||||
*/
|
||||
public function testGroupRows() {
|
||||
$edit = array(
|
||||
'title' => $this->randomMachineName(),
|
||||
$this->fieldName => array('a', 'b', 'c'),
|
||||
);
|
||||
$this->drupalCreateNode($edit);
|
||||
|
||||
$view = Views::getView('test_group_rows');
|
||||
|
||||
// Test grouped rows.
|
||||
$this->executeView($view);
|
||||
$this->assertEqual($view->field[$this->fieldName]->advancedRender($view->result[0]), 'a, b, c');
|
||||
|
||||
// Change the group_rows checkbox to false.
|
||||
$view = Views::getView('test_group_rows');
|
||||
$view->setHandlerOption('default', 'field', $this->fieldName, 'group_rows', FALSE);
|
||||
|
||||
// Test ungrouped rows.
|
||||
$this->executeView($view);
|
||||
$this->assertEqual($view->field[$this->fieldName]->advancedRender($view->result[0]), 'a');
|
||||
$this->assertEqual($view->field[$this->fieldName]->advancedRender($view->result[1]), 'b');
|
||||
$this->assertEqual($view->field[$this->fieldName]->advancedRender($view->result[2]), 'c');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
langcode: und
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- field
|
||||
- node
|
||||
id: test_group_rows
|
||||
label: test_group_rows
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node
|
||||
base_field: nid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
cache:
|
||||
type: none
|
||||
query:
|
||||
type: views_query
|
||||
exposed_form:
|
||||
type: basic
|
||||
pager:
|
||||
options:
|
||||
items_per_page: 10
|
||||
type: full
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: fields
|
||||
fields:
|
||||
field_group_rows:
|
||||
id: field_group_rows
|
||||
table: node__field_group_rows
|
||||
field: field_group_rows
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: true
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: ''
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: true
|
||||
trim: true
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
click_sort_column: value
|
||||
type: string
|
||||
settings:
|
||||
link_to_entity: '0'
|
||||
group_column: value
|
||||
group_columns: { }
|
||||
group_rows: true
|
||||
delta_limit: all
|
||||
delta_offset: '0'
|
||||
delta_reversed: false
|
||||
delta_first_last: false
|
||||
multi_type: separator
|
||||
separator: ', '
|
||||
field_api_classes: false
|
||||
plugin_id: field
|
||||
field_langcode: '***LANGUAGE_language_content***'
|
||||
field_langcode_add_to_query: null
|
||||
display_extenders: { }
|
Loading…
Reference in New Issue