When Grid was re-implemented in #1903746: Replace the views grid table template with one using divs, custom row classes were specially implemented to handle vertical or horizontal alignments. This broke token replacement for custom row classes.

Comments

les lim’s picture

Looks like token replacement isn't working on custom column classes, either.

markhalliwell’s picture

Hmm, indeed. That's unfortunate. Sigh... ok we'll probably need to implement something like: StylePluginBase::getRowClass

markhalliwell’s picture

Issue tags: +VDC, +VDC-cleanup
markhalliwell’s picture

Issue tags: +Needs tests

We need to extend the grid test to include this so we don't miss this again.

les lim’s picture

Assigned: Unassigned » les lim
Status: Active » Needs review
StatusFileSize
new4.3 KB
new1.94 KB

Here's a stab at it.

markhalliwell’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

This is an AMAZING "stab"!! Great patch! Test only patch fails like it should, complete passes!

@Les Lim++

One tiny code standards nitpick:

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/style/Grid.php
@@ -104,4 +104,22 @@ public function buildOptionsForm(&$form, &$form_state) {
+  /**
+   * Return the token-replaced row or column classes for the specified
+   * result item.
+   */

This should be a single summary line. @see: https://drupal.org/node/1354#drupal

No need to upload a new "test" only patch. Just the revised complete patch will do. After that new patch turns green, this is RTBC!

markhalliwell’s picture

Also, afterthought:

+++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/StyleGridTest.php
@@ -102,6 +102,11 @@ protected function assertGrid(ViewExecutable $view, $alignment, $columns) {
+    // Ensure tokens are being replaced in custom row/column classes.
+    $result = $this->xpath('//div[contains(@class, "views-col") and contains(@class, "name-John")]');
+    $this->assertTrue(count($result), 'Token replacement verified in custom column classes.');
+    $result = $this->xpath('//div[contains(@class, "views-row") and contains(@class, "age-25")]');
+    $this->assertTrue(count($result), 'Token replacement verified in custom row classes.');

I would keep the same assertion label prefix so it's easier to read in the tests if they fail (ie: look at the test only results).

I would do something like:
ucfirst($alignment) . " $columns column grid: Custom column class token replaced."
and
ucfirst($alignment) . " $columns column grid: Custom row class token replaced."

les lim’s picture

Status: Needs work » Needs review
StatusFileSize
new1.95 KB

Nice! New patch attached.

les lim’s picture

StatusFileSize
new4.37 KB

doh, that was the interdiff. This is the patch.

markhalliwell’s picture

Status: Needs review » Needs work
+++ b/core/modules/views/lib/Drupal/views/Plugin/views/style/Grid.php
@@ -104,4 +104,20 @@ public function buildOptionsForm(&$form, &$form_state) {
+  /**
+   * Return the token-replaced row or column classes for the specified result.
+   */

The summary line still needs to be less than 80 characters long.

  /**
   * Returns token-replaced custom row or column classes.
   */
dawehner’s picture

It is great that this also extends the test coverage of checking for the col and row classes. Here is some additional nickpicking.

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/style/Grid.phpundefined
@@ -104,4 +104,20 @@ public function buildOptionsForm(&$form, &$form_state) {
+  /**
+   * Return the token-replaced row or column classes for the specified result.
+   */
+  public function getCustomClass($result_index, $type) {

The parameters and the return value should be documented.

les lim’s picture

Status: Needs work » Needs review
StatusFileSize
new871 bytes
new4.64 KB
+  /**
+   * Return the token-replaced row or column classes for the specified result.
+   */

This summary line is already under 80 characters (78), including indentation.

New patch, now with @params/@return documented.

markhalliwell’s picture

This summary line is already under 80 characters (78), including indentation.

My bad, guess my Dreditor styling is off.

Changes look good, will RTBC once patch comes back green.

les lim’s picture

Yeah, that line in dreditor isn't 80 characters wide, it's 50.7em wide. For me, that's about 84 chararcters. :( YMMV.

Status: Needs review » Needs work
Issue tags: -VDC, -VDC-cleanup

The last submitted patch, core-2048897-12-complete.patch, failed testing.

markhalliwell’s picture

Status: Needs work » Needs review
Issue tags: +VDC, +VDC-cleanup

#12: core-2048897-12-complete.patch queued for re-testing.

joelpittet’s picture

Assigned: les lim » Unassigned
Status: Needs review » Reviewed & tested by the community

Nice work guys.

  • Fixes regression
  • Has new test coverage to prevent future regression.
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 0932270 and pushed to 8.x. Thanks!

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