It was a great idea to include a comment field for views displays. Any sitebuilder should use it!
One reason why only few sitebuilders do use it might be that you would hardly recognize that it has been used.

Anyone interested: try now
* Located the field "Comment" under Advanced > Other
* Click on "No comment" and enter what this display is used for (this only applies to the current display)

Once applied, the comment is visible in the UI but trimmed to 10 characters. Easy to miss.

Before + after

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hexabinaer created an issue. See original summary.

hexabinaer’s picture

Issue summary: View changes
hexabinaer’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 7.x-3.x-dev » 8.0.x-dev
Component: User interface » views_ui.module
Assigned: Unassigned » hexabinaer
Priority: Normal » Minor
Issue summary: View changes
hexabinaer’s picture

Assigned: hexabinaer » Unassigned
Status: Active » Needs review
FileSize
716 bytes
cilefen’s picture

Priority: Minor » Normal
Issue tags: +Needs backport to D7
cilefen’s picture

Why not also add an ellipsis, …, so the views administrator knows the string was truncated?

dawehner’s picture

Why not also add an ellipsis, …, so the views administrator knows the string was truncated?

+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -1130,7 +1130,7 @@ public function optionsSummary(&$categories, &$options) {
-    $display_comment = Unicode::substr($this->getOption('display_comment'), 0, 10);
+    $display_comment = Unicode::substr($this->getOption('display_comment'), 0, 80);

Good idea!
So let's use \views_ui_truncate() .., which does the ellipsis thing

cilefen’s picture

I tacked a regression test onto another test or we could make another one, or rename the test I modified.

cilefen’s picture

In the next patch, DisplayPluginBase may have this removed now:

use Drupal\Component\Utility\Unicode;

dawehner’s picture

+++ b/core/modules/views_ui/src/Tests/ViewEditTest.php
@@ -57,6 +57,11 @@ public function testMachineNameOption() {
+    $edit = array('display_comment' => 'one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen');
+    $this->drupalPostForm('admin/structure/views/nojs/display/test_view/attachment_1/display_comment', $edit, 'Apply');
+    $this->assertText('one two three four five six seven eight nine ten eleven twelve thirteen fourteen...');

Nice ...

cilefen’s picture

legolasbo’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
109.52 KB
120.81 KB

I've reviewed the code, which looks good to me. And manually reviewed the patch, which seems like an improvement to me.

Before:

before

After:

after

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Why are we truncating at all? The description is 'This description will only be seen within the administrative interface and can be used to document this display.'

I guess it is okay and definitely an improvement. Committed 28088f3 and pushed to 8.0.x. Thanks!

Someone can move this to the Views queue for the D7 backport.

  • alexpott committed 28088f3 on 8.0.x
    Issue #2550287 by cilefen, hexabinaer, legolasbo, dawehner: Expand...
cilefen’s picture

Project: Drupal core » Views (for Drupal 7)
Version: 8.0.x-dev » 7.x-3.x-dev
Component: views_ui.module » Code
Status: Fixed » Patch (to be ported)
cilefen’s picture

Why are we truncating at all?

That is the question.

serundeputy’s picture

The comment field is set to 80 for me in D7 views 7.x-3.x.

In the file views_plugin_dispaly.inc line: 1153

$display_comment = check_plain(views_ui_truncate($this->get_option('display_comment'), 80));

Here is a view:
views comment allows for 80

I believe there is no action required for 7.x-3.x

thanks,
Geoff

serundeputy’s picture

Status: Patch (to be ported) » Needs review
hexabinaer’s picture

Backport has been taken care of via seperate issue: https://www.drupal.org/node/2559839

So I guess this issue may be closed?

cilefen’s picture

Project: Views (for Drupal 7) » Drupal core
Version: 7.x-3.x-dev » 8.0.x-dev
Component: Code » views_ui.module
Status: Needs review » Closed (fixed)
Issue tags: -Needs backport to D7