Skip to content
Snippets Groups Projects
Unverified Commit 4bbebca9 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2695207 by Lendude, finne, biguzis, dawehner, xjm: Text (plain, long)...

Issue #2695207 by Lendude, finne, biguzis, dawehner, xjm: Text (plain, long) field is not click sortable and does not appear in combine fields filter
parent c67d4cfe
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
use Drupal\Component\Render\MarkupInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\node\Entity\Node;
......@@ -39,6 +40,12 @@ protected function setUp($import_test_views = TRUE) {
parent::setUp($import_test_views);
$field_names = $this->setUpFieldStorages(4);
$this->fieldStorages['string_long'] = FieldStorageConfig::create([
'field_name' => 'string_long',
'entity_type' => 'node',
'type' => 'string_long',
]);
$this->fieldStorages['string_long']->save();
// Attach the field to nodes only.
$field = [
......@@ -49,6 +56,14 @@ protected function setUp($import_test_views = TRUE) {
];
FieldConfig::create($field)->save();
// Attach the string_long field to the page node type.
FieldConfig::create([
'field_name' => 'string_long',
'entity_type' => 'node',
'bundle' => 'page',
'label' => 'string_long label',
])->save();
// Attach the same field to a different bundle with a different label.
$this->drupalCreateContentType(['type' => 'article']);
FieldConfig::create([
......@@ -209,10 +224,15 @@ public function testViewsData() {
];
$this->assertEqual($expected_join, $data[$revision_table]['table']['join']['node_field_revision']);
// Test click sortable.
// Test click sortable for string field.
$this->assertTrue($data[$current_table][$field_storage->getName()]['field']['click sortable'], 'String field is click sortable.');
// Click sort should only be on the primary field.
$this->assertTrue(empty($data[$revision_table][$field_storage->getName()]['field']['click sortable']), 'Non-primary fields are not click sortable');
// Test click sortable for long text field.
$data_long = $this->getViewsData('string_long');
$field_storage_long = $this->fieldStorages['string_long'];
$current_table_long = $table_mapping->getDedicatedDataTableName($field_storage_long);
$this->assertTrue($data_long[$current_table_long][$field_storage_long->getName()]['field']['click sortable'], 'Long text field is click sortable.');
$this->assertTrue($data[$current_table][$field_storage->getName()]['help'] instanceof MarkupInterface);
$this->assertEqual($data[$current_table][$field_storage->getName()]['help'], 'Appears in: page, article. Also known as: Content: GiraffeB" label');
......@@ -247,7 +267,7 @@ public function testViewsData() {
*
* @return array
*/
protected function getViewsData() {
protected function getViewsData($field_storage_key = 0) {
$views_data = $this->container->get('views.views_data');
$data = [];
......@@ -255,8 +275,8 @@ protected function getViewsData() {
// Attached to node only.
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = \Drupal::entityManager()->getStorage('node')->getTableMapping();
$current_table = $table_mapping->getDedicatedDataTableName($this->fieldStorages[0]);
$revision_table = $table_mapping->getDedicatedRevisionTableName($this->fieldStorages[0]);
$current_table = $table_mapping->getDedicatedDataTableName($this->fieldStorages[$field_storage_key]);
$revision_table = $table_mapping->getDedicatedRevisionTableName($this->fieldStorages[$field_storage_key]);
$data[$current_table] = $views_data->get($current_table);
$data[$revision_table] = $views_data->get($revision_table);
return $data;
......
......@@ -595,9 +595,8 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
$filter = 'boolean';
}
break;
case 'text':
case 'blob':
// It does not make sense to sort by blob or text.
// It does not make sense to sort by blob.
$allow_sort = FALSE;
default:
$filter = 'string';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment