Skip to content
Snippets Groups Projects
Commit 726b3d13 authored by John Gustavo Choque Condori's avatar John Gustavo Choque Condori Committed by Miro Dietiker
Browse files

Issue #2734303 by arpad.rozsa, yongt9412, capellic, miro_dietiker, Berdir: Add...

Issue #2734303 by arpad.rozsa, yongt9412, capellic, miro_dietiker, Berdir: Add class to TR element that wraps around a paragraph bundle on node edit form
parent e03d7e83
No related branches found
Tags 8.x-1.4
No related merge requests found
......@@ -355,6 +355,15 @@ function paragraphs_preprocess_field_multiple_value_form(&$variables) {
];
unset($variables['table']['#rows'][0]);
}
// Add the paragraph type as a class to every row.
if (isset($variables['element'][0]['#paragraph_type'])) {
foreach ($variables['table']['#rows'] as $key => $row) {
if (isset($row['data'][1]['data']['#paragraph_type'])) {
$variables['table']['#rows'][$key]['class'][] = 'paragraph-type--' . str_replace('_', '-', $row['data'][1]['data']['#paragraph_type']);
}
}
}
}
// Remove the drag handler if we are translating, if the field's cardinality
......
<?php
namespace Drupal\Tests\paragraphs\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\paragraphs\FunctionalJavascript\LoginAdminTrait;
use Drupal\Tests\paragraphs\FunctionalJavascript\ParagraphsTestBaseTrait;
/**
* Tests the Paragraphs user interface.
*
* @group paragraphs
*/
class ParagraphsExperimentalUiTest extends BrowserTestBase {
use LoginAdminTrait;
use ParagraphsTestBaseTrait;
/**
* Modules to enable.
*
* @var string[]
*/
public static $modules = [
'node',
'paragraphs',
'field',
'field_ui',
'block',
];
/**
* Tests if the paragraph type class is present when added.
*/
public function testParagraphTypeClass() {
$this->loginAsAdmin();
// Add a Paragraphed test content.
$this->addParagraphedContentType('paragraphed_test', 'paragraphs');
$this->addParagraphsType('test_paragraph');
$this->addParagraphsType('text');
// Add paragraphs to a node and check if their type is present as a class.
$this->drupalGet('node/add/paragraphed_test');
$this->getSession()->getPage()->findButton('paragraphs_test_paragraph_add_more')->press();
$this->assertSession()->responseContains('paragraph-type--test-paragraph');
$this->getSession()->getPage()->findButton('paragraphs_text_add_more')->press();
$this->assertSession()->responseContains('paragraph-type--text');
}
}
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