Issue #2509722 by NickWilde, dawehner, Lendude, rakesh.gectcr, Nitesh Pawar, xjm, tstoeckler: "Error: missing help" in Views for Node fields without descriptions
parent
ada4e570d6
commit
b51c12a911
|
@ -54,9 +54,11 @@ class NodeViewsData extends EntityViewsData {
|
|||
),
|
||||
);
|
||||
|
||||
$data['node_field_data']['promote']['help'] = t('A boolean indicating whether the node is visible on the front page.');
|
||||
$data['node_field_data']['promote']['filter']['label'] = t('Promoted to front page status');
|
||||
$data['node_field_data']['promote']['filter']['type'] = 'yes-no';
|
||||
|
||||
$data['node_field_data']['sticky']['help'] = t('A boolean indicating whether the node should sort to the top of content lists.');
|
||||
$data['node_field_data']['sticky']['filter']['label'] = t('Sticky status');
|
||||
$data['node_field_data']['sticky']['filter']['type'] = 'yes-no';
|
||||
$data['node_field_data']['sticky']['sort']['help'] = t('Whether or not the content is sticky. To list sticky content first, set this to descending.');
|
||||
|
@ -256,6 +258,10 @@ class NodeViewsData extends EntityViewsData {
|
|||
$data['node_field_revision']['status']['filter']['type'] = 'yes-no';
|
||||
$data['node_field_revision']['status']['filter']['use_equal'] = TRUE;
|
||||
|
||||
$data['node_field_revision']['promote']['help'] = t('A boolean indicating whether the node is visible on the front page.');
|
||||
|
||||
$data['node_field_revision']['sticky']['help'] = t('A boolean indicating whether the node should sort to the top of content lists.');
|
||||
|
||||
$data['node_field_revision']['langcode']['help'] = t('The language of the content or translation.');
|
||||
|
||||
$data['node_field_revision']['link_to_revision'] = array(
|
||||
|
|
|
@ -114,8 +114,17 @@ class ViewsDataHelper {
|
|||
elseif (!empty($table_data['table'][$string])) {
|
||||
$strings[$field][$key][$string] = $table_data['table'][$string];
|
||||
}
|
||||
// We don't have any help provided for this field. If a better
|
||||
// description should be used for the Views UI you use
|
||||
// hook_views_data_alter() in module.views.inc or implement a
|
||||
// custom entity views_data handler.
|
||||
// @see hook_views_data_alter()
|
||||
// @see \Drupal\node\NodeViewsData
|
||||
elseif ($string == 'help') {
|
||||
$strings[$field][$key][$string] = '';
|
||||
}
|
||||
else {
|
||||
if ($string != 'base' && $string != 'base') {
|
||||
if ($string != 'base') {
|
||||
$strings[$field][$key][$string] = SafeMarkup::format("Error: missing @component", array('@component' => $string));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,9 @@ class HandlerTest extends UITestBase {
|
|||
/**
|
||||
* Overrides \Drupal\views\Tests\ViewTestBase::viewsData().
|
||||
*
|
||||
* Adds a relationship for the uid column.
|
||||
* Adds:
|
||||
* - a relationship for the uid column.
|
||||
* - a dummy field with no help text.
|
||||
*/
|
||||
protected function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
|
@ -79,6 +81,12 @@ class HandlerTest extends UITestBase {
|
|||
)
|
||||
);
|
||||
|
||||
// Create a dummy field with no help text.
|
||||
$data['views_test_data']['no_help'] = $data['views_test_data']['name'];
|
||||
$data['views_test_data']['no_help']['field']['title'] = t('No help');
|
||||
$data['views_test_data']['no_help']['field']['real field'] = 'name';
|
||||
unset($data['views_test_data']['no_help']['help']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -246,6 +254,23 @@ class HandlerTest extends UITestBase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that no missing help text is shown.
|
||||
*
|
||||
* @see \Drupal\views\EntityViewsData
|
||||
*/
|
||||
public function testErrorMissingHelp() {
|
||||
// Test that the error message is not shown for entity fields but an empty
|
||||
// description field is shown instead.
|
||||
$this->drupalGet('admin/structure/views/nojs/add-handler/test_node_view/default/field');
|
||||
$this->assertNoText('Error: missing help');
|
||||
$this->assertRaw('<td class="description"></td>', 'Empty description found');
|
||||
|
||||
// Test that no error message is shown for other fields.
|
||||
$this->drupalGet('admin/structure/views/nojs/add-handler/test_view_empty/default/field');
|
||||
$this->assertNoText('Error: missing help');
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that fields only appear once.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue