Problem/Motivation

The current implementation of the webform overview has a declaration for the 'operations' column that makes it incompatible with tablesorting: https://api.drupal.org/api/drupal/core%21includes%21tablesort.inc/8.5.x

Proposed resolution

  1. Update the 'operation' header to be compatible with tablesorting
  2. Optional: implement tablesort

Remaining tasks

  1. Write a patch
  2. Review
  3. Commit

User interface changes

None.

API changes

The Webform overview is compatible with tablesort.

Data model changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

idebr created an issue. See original summary.

idebr’s picture

Status: Active » Needs review
FileSize
1.5 KB

Solution based on https://drupal.stackexchange.com/questions/192757/how-to-make-entitylist...

The changes in WebformEntityListBuilder::buildHeader() are the only changes required for tablesort compatibility.

jrockowitz’s picture

@idebr Your patch makes sense to me but for some reason table sorting is still not working. Maybe someone else can also review/test the patch.

idebr’s picture

Re #3:
In my particular implementation the list builder is extended and includes several custom fields that are sortable. To make a field sortable the header needs an additional array key for 'field' that will be used in the entity query. The default field that should be sorted needs a 'sort' key (asc/desc).

For demonstration purposes I have made the title sortable in this patch. I don't really have an opinion on what fields in the UI should be sortable.

jrockowitz’s picture

Anything that can be sorted should be storable. This is one of those features where someone will get inspired, help implement it, and earn some commit credits.

idebr’s picture

Title: Make webform overview compatible with tablesorting » Implement tablesorting in webform overview for title, description, category, status, owner
FileSize
1.06 KB
2.28 KB

Implemented tablesorting in webform overview for title, description, category, status, owner.

Sorting by total results is a bit of an exception, since 'results_total' is not something that can be automatically sorted by tablesort. There are several options on how this feature can be implemented, so I have filed a follow-up at #2944091: Implement tablesorting in webform overview for 'Total results' so this issue can move forward. Could you take a look at the related issue and see which proposed resolution has your preference?

jrockowitz’s picture

@idebr The patch works great. I just made one minor change and I will commit this patch once all the tests pass.

+++ b/src/WebformEntityListBuilder.php
@@ -145,22 +145,33 @@ class WebformEntityListBuilder extends ConfigEntityListBuilder {
+      'sort' => 'desc',

This should be set to 'asc' so that the webforms titles are sorted alphabetically.

jrockowitz’s picture

Status: Needs review » Fixed

I committed that patch. Please download the latest dev release to review.

  • jrockowitz committed 087a11a on 8.x-5.x
    Issue #2943237 by idebr, jrockowitz: Implement tablesorting in webform...

Status: Fixed » Closed (fixed)

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