Task

Convert the following theme functions to use the new table #type:

Module Theme function name Where in Code What is it really?
book theme_book_admin_table function table

Steps to Reproduce

  1. drush en book -y
  2. Add a book page at /node/add/book, and select "- Create a new book -" from the "Book Outline" tab
  3. Create another book page and assign it to the newly created book
  4. Visit /admin/structure/book/1

Related issues

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Task because it does not introduce any new features or removes any bugs
Issue priority Normal because the functionality is unchanged
Unfrozen changes Unfrozen because it only converts the '#type' in the renderable array
Prioritized changes The main goal of this issue is removing previously deprecated code.
Disruption Not disruptive
CommentFileSizeAuthor
#70 interdiff.txt8.41 KBjoelpittet
#70 convert_book_theme-1968982-70.patch11.16 KBjoelpittet
#63 interdiff.txt684 byteslauriii
#63 convert_book_theme-1968982-63.patch13.03 KBlauriii
#61 interdiff.txt1.13 KBlauriii
#61 convert_book_theme-1968982-61.patch12.82 KBlauriii
#60 interdiff.txt2.68 KBlauriii
#58 convert_book_theme-1968982-58.patch12.86 KBlauriii
#55 1968982-52-after.png72.14 KBidebr
#53 book-table-after-52.txt5.37 KBa-fro
#53 book-table-before.txt5.03 KBa-fro
#53 Cursor_and_Kaleidoscope_–_book-table-before_txt___book-table-after-52_txt.png70.9 KBa-fro
#52 interdiff-1968982-46-52.txt1.44 KBlauriii
#52 convert_book_theme-1968982-52.patch11.71 KBlauriii
#48 book-admin-after-46.txt5.26 KBa-fro
#48 book-admin-before-46.txt5.03 KBa-fro
#47 Cursor_and_Kaleidoscope_–_book-admin-before_txt___book-admin-after_txt.png63.03 KBa-fro
#47 Cursor_and_Kaleidoscope_–_book-admin-before_txt___book-admin-after_txt.png110.67 KBa-fro
#46 1968982-46.patch11.55 KBlauriii
#46 interdiff.txt1.46 KBlauriii
#43 1968982-43.patch10.23 KBkgoel
#36 interdiff.txt1.23 KBstar-szr
#36 1968982-36.patch11.18 KBstar-szr
#33 book_module-convert-table-theme-1968982-33.patch11.13 KBTemoor
#31 book_module-convert-table-theme-1968982-31.patch9.14 KBTemoor
#28 1968982.patch7.4 KBmiraj9093
#24 1968982-24.patch10.82 KBlokapujya
#19 interdiff.txt3.21 KBlongwave
#19 1968982-book-admin-table-19.patch11.01 KBlongwave
#17 1968982-book-admin-table-17.patch11.35 KBlongwave
#14 1968982-14-book-table.patch10.57 KBHydra
#11 1968982-11-book-table.patch8.72 KBBrandonian
#3 1968982-3-book-table.patch8.97 KBduellj
#3 interdiff.txt1 KBduellj
#1 1968982-1-book-table.patch7.97 KBduellj
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

duellj’s picture

Status: Active » Needs review
FileSize
7.97 KB

Status: Needs review » Needs work

The last submitted patch, 1968982-1-book-table.patch, failed testing.

duellj’s picture

Status: Needs work » Needs review
FileSize
1 KB
8.97 KB

Forgot to move tests over from #1898050: book.module - Convert PHPTemplate templates to Twig. Tests should pass now

catch’s picture

#3: 1968982-3-book-table.patch queued for re-testing.

catch’s picture

duellj’s picture

Not sure this needs a re-roll, since #1938296: Convert book_admin_overview and book_render to a new-style Controller didn't touch book_admin_edit(). Are you talking about rolling that form into BookController?

duellj’s picture

#3: 1968982-3-book-table.patch queued for re-testing.

jibran’s picture

#3: 1968982-3-book-table.patch queued for re-testing.

jibran’s picture

#3: 1968982-3-book-table.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 1968982-3-book-table.patch, failed testing.

Brandonian’s picture

Status: Needs work » Needs review
FileSize
8.72 KB

Patch rerolled.

jibran’s picture

#11: 1968982-11-book-table.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 1968982-11-book-table.patch, failed testing.

Hydra’s picture

Status: Needs work » Needs review
FileSize
10.57 KB

Rerolled the patch and fixed some bugs.

lokapujya’s picture

Looks pretty good. Maybe we should set the table ID? Previously, it was 'book-outline'.

+++ /dev/null
@@ -1,101 +0,0 @@
-    '#attributes' => array('id' => 'book-outline'),
lokapujya’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll
longwave’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
11.35 KB

Rerolled.

joelpittet’s picture

Thanks for the re-roll @longwave and it's green nice! There a couple of things and after those I'll give a manual test:

  1. +++ b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php
    @@ -117,22 +117,23 @@ public function submitForm(array &$form, array &$form_state) {
    +          $node->log = $this->t('Title changed from %original to %current.', array('%original' => $node->label, '%current' => $values['title']));
    

    I think that is supposed to still be $node->label()

  2. +++ b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php
    @@ -117,22 +117,23 @@ public function submitForm(array &$form, array &$form_state) {
    +          $updated = TRUE;
    

    Not sure why this is needed?

  3. +++ b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php
    @@ -159,8 +160,25 @@ public function submitForm(array &$form, array &$form_state) {
    +      '#header' => array(t('Title'), t('Weight'), t('Parent'), t('Operations')),
    

    All the t() can be $this->t to use the injected translations.

longwave’s picture

Assigned: duellj » Unassigned
FileSize
11.01 KB
3.21 KB

Fixed all points raised in #18.

lokapujya’s picture

Any thoughts on whether we still want the table ID?

longwave’s picture

If the table ID is not referenced anywhere in CSS or JavaScript, I don't see why we need it.

longwave’s picture

I think the ID was previously needed only for tabledrag, but not sure we need that any more, since #732022: drupal_add_tabledrag() still using drupal_add_(js|library)(), should return array for #attached was committed.

lokapujya’s picture

Assigned: Unassigned » lokapujya
Status: Needs review » Needs work
Issue tags: +Needs reroll
lokapujya’s picture

Assigned: lokapujya » Unassigned
Status: Needs work » Needs review
FileSize
10.82 KB
lokapujya’s picture

+++ b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php
@@ -197,33 +214,76 @@ protected function bookAdminTableTree(array $tree, array &$form) {
+      $form[$id]['operations'] = array(
+        '#type' => 'operations',
+      );
+      $form[$id]['operations']['#links']['view'] = array(

['operations'] conflicted, because the other patch had removed the ['href']. I am not sure if adding this back in breaks what they were trying to do in the other patch.

Status: Needs review » Needs work

The last submitted patch, 24: 1968982-24.patch, failed testing.

lokapujya’s picture

  1. +++ b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php
    @@ -159,8 +159,25 @@ public function submitForm(array &$form, array &$form_state) {
    +          'relationship' => 'parent',
    
    @@ -197,33 +214,76 @@ protected function bookAdminTableTree(array $tree, array &$form) {
    +        '#prefix' => theme('indentation', array('size' => $data['link']['depth'] - 2)),
    

    Change to a render array.

  2. +++ b/core/modules/book/lib/Drupal/book/Form/BookAdminEditForm.php
    @@ -197,33 +214,76 @@ protected function bookAdminTableTree(array $tree, array &$form) {
    +        'href' => $data['link']['href'],
    

    Change to route_name?

miraj9093’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
7.4 KB

rerolled ..

Status: Needs review » Needs work

The last submitted patch, 28: 1968982.patch, failed testing.

Jon Pugh’s picture

Assigned: Unassigned » Jon Pugh
Status: Needs work » Active

On it.

Temoor’s picture

Status: Active » Needs review
FileSize
9.14 KB

Patch rerolled.

Status: Needs review » Needs work

The last submitted patch, 31: book_module-convert-table-theme-1968982-31.patch, failed testing.

Temoor’s picture

Status: Needs work » Needs review
FileSize
11.13 KB

Updated tests, corrected errors from previous patch.

m1r1k’s picture

Issue tags: +#ams2014contest
joelpittet’s picture

Assigned: Jon Pugh » Unassigned
Issue tags: +Needs reroll

No longer applies, sorry I didn't get to review earlier, will after re-roll.

star-szr’s picture

Issue tags: -, -Needs reroll
FileSize
11.18 KB
1.23 KB

Rerolled, some route names changed in the theme function in #2278567: Standardize node route names by relationship. Somewhat of an interdiff attached.

joelpittet’s picture

I've got a feeling the book module is broken... create one book, no sub pages and save this edit form page:
http://d8.dev/admin/structure/book/1

And it borks up good before and after the patch (slightly different error though, regarding array flipping or missing table index... recoverable fatal). Will need to write a webtest or something, though I think that may need to go into a different issue if one doesn't exist.

lauriii’s picture

Yeah, tried to test this patch but the book module is broken so the book page cannot be viewed.

joelpittet queued 36: 1968982-36.patch for re-testing.

cilefen’s picture

Assigned: Unassigned » cilefen
Issue tags: +Needs reroll
cilefen’s picture

Status: Needs review » Needs work
cilefen’s picture

Assigned: cilefen » Unassigned
kgoel’s picture

Status: Needs work » Needs review
FileSize
10.23 KB
kgoel’s picture

Issue tags: -Needs reroll

Status: Needs review » Needs work

The last submitted patch, 43: 1968982-43.patch, failed testing.

lauriii’s picture

Status: Needs work » Needs review
FileSize
1.46 KB
11.55 KB

I was working on this reroll also so we did a bit double work.. But here's the differences from my patch

a-fro’s picture

During manual testing, the operations links were missing, though the text was there. I'm not sure if the other difference is relevant, but I've included a screenshot. @joelpittet, do you happen to know if the [parent] key matters? ie: name="table[book-admin-2][parent][pid]", vs. name="table[book-admin-2][pid]"

a-fro’s picture

Attaching the before and after txt files from patch 46.

a-fro’s picture

Issue summary: View changes
a-fro’s picture

Issue summary: View changes
a-fro’s picture

After looking at the code, I had these questions:

  1. +++ b/core/modules/book/src/Form/BookAdminEditForm.php
    @@ -181,32 +199,91 @@ protected function bookAdminTableTree(array $tree, array &$form) {
    +        'href' => $href = \Drupal::url('entity.node.canonical', array('node' => $nid)),
    

    The $href here is funky.

  2. +++ b/core/modules/book/src/Form/BookAdminEditForm.php
    @@ -181,32 +199,91 @@ protected function bookAdminTableTree(array $tree, array &$form) {
    +        $form[$id]['operations']['#links']['edit'] = array(
    +          'title' => $this->t('Edit'),
    +          'route_name' => 'entity.node.edit_form',
    +          'route_parameters' => array('node' => $nid),
    +          'query' => $destination,
    +        );
    +        $form[$id]['operations']['#links']['delete'] = array(
    +          'title' => $this->t('Delete'),
    +          'route_name' => 'entity.node.delete_form',
    +          'route_parameters' => array('node' => $nid),
    +          'query' => $destination,
    +        );
    

    These links no longer work. They are missing the a tags and hrefs when rendered to the page.

lauriii’s picture

a-fro’s picture

Manual test results below. Looks good to me! RTBC, @joelpittet?

idebr’s picture

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

Did a manual test as well, looks clean.

Screenshot after:

/files/issues/1968982-52-after.png

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

#51 shows that we are missing test coverage here.

lauriii’s picture

Assigned: Unassigned » lauriii
lauriii’s picture

Status: Needs work » Needs review
FileSize
12.86 KB

Added test coverage for the View link. It is currently not possible very easily to test Edit link because it requires 'administer nodes' permission which breaks some other stuff because of changed Save button on nodes. I think this should be fixed on a follow-up.

lauriii’s picture

Assigned: lauriii » Unassigned
Issue tags: -Needs tests
lauriii’s picture

FileSize
2.68 KB

Interdiff for my patch :)

lauriii’s picture

FileSize
12.82 KB
1.13 KB

Little clean up for docs & stuff

idebr’s picture

Status: Needs review » Needs work
+++ /dev/null
@@ -1,100 +0,0 @@
-    '#tabledrag' => array(
-      array(
-        'action' => 'match',
-        'relationship' => 'parent',
-        'group' => 'book-pid',
-        'subgroup' => 'book-pid',
-        'source' => 'book-nid',
-        'hidden' => TRUE,
-        'limit' => BookManager::BOOK_MAX_DEPTH - 2,
-      ),

+++ b/core/modules/book/src/Form/BookAdminEditForm.php
@@ -143,8 +145,25 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
+      '#tabledrag' => array(
+        array(
+          'action' => 'match',
+          'relationship' => 'parent',
+          'group' => 'book-pid',
+          'subgroup' => 'book-pid',
+          'source' => 'book-nid',
+          'hidden' => TRUE,
+          'limit' => 7,
+        ),

The 'limited' key is now hardcoded to 7. This should still use the BookManager::BOOK_MAX_DEPTH constant.

lauriii’s picture

Status: Needs work » Needs review
FileSize
13.03 KB
684 bytes

fixed #62

idebr’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

The feedback by alexpott in #56 was addressed, setting this back to RTBC and added a beta evalutation.

pwolanin’s picture

lauriii asked me about the requirement for 'administer nodes' to use the operations. I suspect that was just done for speed and simplicity rather than checking each nodes. I don't think it should be changed in this patch, but could be examined in a follow-up.

joelpittet’s picture

Status: Reviewed & tested by the community » Needs work

I didn't see this discussed earlier but wanted to point it out as it looks like it's not needed:

+++ b/core/modules/book/src/Form/BookAdminEditForm.php
@@ -107,16 +109,16 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
-            $node = $this->nodeStorage->load($values['nid']);
+            $node = $this->nodeStorage->load($row['#nid']);

Is this change needed, it looks suspicious because we aren't using the row's values anywhere else.

Other than that, I'd leave it as RTBC, though if you want to throw in some short array syntax for good measure that'd be cool too;)

robmc’s picture

Assigned: Unassigned » robmc
lauriii’s picture

@robmc: did you find find any other solution to fix that? I checked but the 'nid' item doesn't exist in $values array anymore.

joelpittet’s picture

@lauriii robmc was working it, he may have a patch to get most of the way there. Essentially the 'nid' was moved onto the 'parent' in the values, and it shouldn't get moved there, which may constitute an API change. So we just need to move that back.

joelpittet’s picture

Assigned: robmc » Unassigned
Status: Needs work » Needs review
FileSize
11.16 KB
8.41 KB

@lauriii here's an attempt, I left the ['parent'] key in the form because those form elements need to be in a column and that one makes sense, just removed the parent key from the #parents within FAPI which preserves the $form_state values and leaves the tests and submit handler mostly alone.

Also did all the array short syntax changes that didn't affect the patch size.

Local tests aren't working well for me on the command line or the UI, but manual testing was fine and the values were the way they should be on the submit handler, so here's hoping testbot agrees;)

lokapujya’s picture

Issue summary: View changes
lokapujya’s picture

While manual testing, noticed that the weights for new pages are negative numbers, whereas in Drupal 7 they are 0. Noticed that when "show weights" is selected, we show the parent column (with nothing in it) but that's the same as Drupal 7. Both are unrelated to this issue, I think.
RTBC+1.

lauriii’s picture

Status: Needs review » Reviewed & tested by the community

After manually testing this I don't see any regressions. Also code looks good. I also like the fancy array syntax used in the patch ;)

lokapujya’s picture

array() is sooooo php5.4.

joelpittet’s picture

5.3 but yeah... agreed:P

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 0f2348c and pushed to 8.0.x. Thanks!

Thanks for adding the beta evaluation to the issue summary.

  • alexpott committed 0f2348c on 8.0.x
    Issue #1968982 by lauriii, a-fro, duellj, longwave, joelpittet, Temoor,...

Status: Fixed » Closed (fixed)

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