Problem/Motivation

The empty paragraph message is long, even wraps, and is duplicating the self-explaining button to add a paragraph.

Also it is limited to the select + button case that was from D7. It is misleading for Drupal 8 with dropbuttons or buttons.

Proposed resolution

Drop the second part completely. Just the single empty message: "No Paragraphs added yet."

User interface changes

Reduced empty message.

CommentFileSizeAuthor
#43 wrong_text_when_we_have-2717359-43.patch1.61 KBBambell
#43 interdiff-41-43.txt2.27 KBBambell
#41 interdiff-30-41.txt2.29 KBBambell
#41 wrong_text_when_we_have-2717359-41.patch2.37 KBBambell
#30 interdiff-25-30.txt1.62 KBBambell
#30 wrong_text_when_we_have-2717359-30.patch2.51 KBBambell
#25 interdiff-22-25.txt829 bytesBambell
#25 wrong_text_when_we_have-2717359-25.patch2.45 KBBambell
#22 interdiff-18-22.txt2.41 KBBambell
#22 wrong_text_when_we_have-2717359-22.patch2.44 KBBambell
#18 interdiff-15-18.txt1.36 KBBambell
#18 wrong_text_when_we_have-2717359-18.patch2.45 KBBambell
#15 interdiff-2717359-11-15.txt2.59 KBBambell
#15 wrong_text_when_we_have-2717359-15.patch2.56 KBBambell
#11 interdiff-2717359-6-11.txt1.35 KBBambell
#11 wrong_text_when_we_have-2717359-11.patch2.29 KBBambell
#6 interdiff-2717359-2-5.txt1.88 KBBambell
#6 wrong_text_when_we_have-2717359-6.patch2.26 KBBambell
#2 wrong_text_when_we_have-2717359-2.patch2.08 KBBambell
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yongt9412 created an issue. See original summary.

johnchque’s picture

Status: Active » Needs review

Always set to 'Needs review' when upload a patch so testbot can take action. :)

johnchque’s picture

+++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
@@ -730,7 +730,12 @@ class InlineParagraphsWidget extends WidgetBase {
+        $add_text = 'No Paragraphs added yet. Press the button below to add one.';

I think this should be something like: 'No @title has been added yet. Press the button below to add one.'

+++ b/src/Tests/ParagraphsAdministrationTest.php
@@ -440,6 +440,18 @@ class ParagraphsAdministrationTest extends WebTestBase {
+
+    $this->drupalGet('node/add/article');
+    $this->assertRaw('No Paragraphs have been added yet. Select a Paragraph type and press the button below to add one.');
...
+
+    $this->drupalGet('node/add/article');
+    $this->assertRaw('No Paragraphs added yet. Press the button below to add one.');

Also a comment here would be good. Maybe: // Check that the text displayed is different when we have more than one Paragraph type.

johnchque’s picture

Status: Needs review » Needs work
Bambell’s picture

Assigned: Unassigned » Bambell
Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 6: wrong_text_when_we_have-2717359-6.patch, failed testing.

The last submitted patch, 6: wrong_text_when_we_have-2717359-6.patch, failed testing.

The last submitted patch, 6: wrong_text_when_we_have-2717359-6.patch, failed testing.

Bambell’s picture

Status: Needs work » Needs review
johnchque’s picture

Status: Needs review » Reviewed & tested by the community

Looks good. :)

miro_dietiker’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
    @@ -730,7 +730,12 @@ class InlineParagraphsWidget extends WidgetBase {
    +        $add_text = 'No @title_multiple have been added yet. Press the button below to add one.';
    ...
    +        $add_text = 'No @title_multiple have been added yet. Select a @title type and press the button below to add one.';
    ...
           $element_text = '<p><em>' . t($add_text, array('@title_multiple' => $this->getSetting('title_plural'), '@title' => $this->getSetting('title'))) . '</em></p>';
    

    We want to avoid this. Static text should be on the same line like t() to allow parsing / extraction of translatables.

  2. +++ b/src/Tests/ParagraphsAdministrationTest.php
    @@ -440,6 +440,21 @@ class ParagraphsAdministrationTest extends WebTestBase {
    +    $this->assertRaw('No Paragraphs have been added yet. Select a Paragraph type and press the button below to add one.');
    

    Also you assume that the multiple title is used here while IMHO english currently even wrong twice (should be "No Paragraph has been...").
    Not sure about proper single / multiple handling, but for instance Drupal also offers a language specific plural formula for translatables.

Bambell’s picture

Status: Needs work » Needs review
johnchque’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
@@ -730,8 +730,12 @@ class InlineParagraphsWidget extends WidgetBase {
+        $element_text = '<p><em>' . t('No @title has been added yet. Press the button below to add one.', array('@title_multiple' => $this->getSetting('title_plural'), '@title' => $this->getSetting('title'))) . '</em></p>';
...
+        $element_text = '<p><em>' . t('No @title has been added yet. Select a @title type and press the button below to add one.', array('@title_multiple' => $this->getSetting('title_plural'), '@title' => $this->getSetting('title'))) . '</em></p>';

It seems we are not using @title_multiple here anymore, you can just drop it.

Bambell’s picture

Status: Needs work » Needs review
tduong’s picture

Status: Needs review » Needs work
+++ b/src/Tests/ParagraphsAdministrationTest.php
@@ -440,6 +440,21 @@ class ParagraphsAdministrationTest extends WebTestBase {
+    $this->assertRaw('No Paragraph has been added yet. Select a Paragraph type and press the button below to add one.');
...
+    $this->assertRaw('No Paragraph has been added yet. Press the button below to add one.');

You can use assertText() instead of assertRaw() (use this when you want to assert HTML).

And would be nice if you write a comment about what you did in the uploading patch ;)

tduong’s picture

+++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
@@ -730,8 +730,12 @@ class InlineParagraphsWidget extends WidgetBase {
+        $element_text = '<p><em>' . t('No @title has been added yet. Press the button below to add one.', array('@title' => $this->getSetting('title'))) . '</em></p>';
...
+        $element_text = '<p><em>' . t('No @title has been added yet. Select a @title type and press the button below to add one.', array('@title' => $this->getSetting('title'))) . '</em></p>';

and try to use [] instead of array() whenever you can/provide a patch (see array standard coding). Sorry for being annoying with these standard coding stuff ^^'

Bambell’s picture

Status: Needs work » Needs review
johnchque’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/Field/FieldWidget/InlineParagraphsWidget.php
@@ -730,8 +730,12 @@ class InlineParagraphsWidget extends WidgetBase {
+      } else {

Really close. But this should be:

}
else {
Bambell’s picture

Status: Needs work » Needs review
tduong’s picture

Status: Needs review » Reviewed & tested by the community

Nice! Looks good to me! :)

miro_dietiker’s picture

Not so sure about dropping this _multiple thing although it was unused...

What direction is core heading here? Berdir recently mentioned that Core tries to add multiple support for type labels.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Needs work

Following the concept of empty messages like views, we want to keep them, but short.

The current text is long, duplicate to the button that is self explaining, and adds more confusion, because it's even wront (referring to the select + button case, not considering the button type setting).

Thus, we want to drop the second part of the text completely making it much reduced and clean.

Bambell’s picture

FileSize
2.51 KB
1.62 KB

Patch also needed to be re-rolled. Tests are currently failing, so leaving to "Needs Work" for now.

Bambell’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 30: wrong_text_when_we_have-2717359-30.patch, failed testing.

The last submitted patch, 30: wrong_text_when_we_have-2717359-30.patch, failed testing.

The last submitted patch, 30: wrong_text_when_we_have-2717359-30.patch, failed testing.

The last submitted patch, 30: wrong_text_when_we_have-2717359-30.patch, failed testing.

The last submitted patch, 30: wrong_text_when_we_have-2717359-30.patch, failed testing.

The last submitted patch, 30: wrong_text_when_we_have-2717359-30.patch, failed testing.

The last submitted patch, 30: wrong_text_when_we_have-2717359-30.patch, failed testing.

The last submitted patch, 30: wrong_text_when_we_have-2717359-30.patch, failed testing.

The last submitted patch, 30: wrong_text_when_we_have-2717359-30.patch, failed testing.

Bambell’s picture

The test is deleting paragraph types which newly added tests were using, so I moved the test at the end of the test function. Should pass now.

miro_dietiker’s picture

Title: Wrong text when we have just one paragraph type » Long duplicate text if no paragraph present
Issue summary: View changes
Status: Needs review » Needs work

Rescoping the issue summary.

Bambell’s picture

miro_dietiker’s picture

Status: Needs review » Fixed

Committed! :-)

Status: Fixed » Needs review
  • miro_dietiker committed 0adf2c4 on 8.x-1.x authored by Bambell
    Issue #2717359 by Bambell: Long duplicate text if no paragraph present
    
johnchque’s picture

Status: Needs review » Fixed

Fixed right?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.