Views sort WorkflowState field by Weight/Label

Created on 2 February 2023, almost 2 years ago
Updated 22 February 2024, 11 months ago

Provide in an easy way to sort workflow fields in views.

I have a bundle on which a workflow field is defined. I make a view on that "Content type" (as filter criteria in the view). I add the workflow field to the view, I configure sorting the workflow state field using Table/Settings. The result is that I can click in the header of the workflow field to activate sorting, but nothing happens when I click on the sorting icon (besides the icon changing).

The Workflow State should be sortable using either Weight or Label.
These are defined in the state configuration management like this:
/admin/config/workflow/workflow/name_your_wf/states

Feature request
Status

Active

Version

1.0

Component

Views

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @sboden
  • 🇳🇱Netherlands johnv

    I tested your problem, and could not reproduce it.
    Please check attached file with screendumps.
    - Top row is the view settings.
    - Second row are the sorting results in the view.
    - Second row, right, I added also a relationshihp to the Workflow. There, Sorting also works fine.

    Remark: the sorting is now on the Description of the Workflow State, not on the (logical) sort order in the Workflow Settings.

  • My situation is a bit more complex.

    - I retested a simple case: a view (page based) including a workflow status. Everything works as expected.

    - My situation: I have 4 views as blocks on a single page. Each view is on a different bundle and each view contains a (different) workflow status. I activate sorting on the headers in all of the views.

    The result for me on Drupal 9.4: The workflow status seems to be fixed in 1 order. I sort on another field and that sorting works, when such other order shifted the order of the workflow states, and I press the order on the workflow status header the original sort order of workflow status is applied, but when I click multiple times on the header to sort differently it doesn't budge anymore. So it seems stuck in 1 order.

    What does work but has other side effects:
    - I put in a relation in each block to "workflow transition". Then sorting up and down on workflow status works properly.
    - However, then I get multiple rows (which is warned for). So I used "Table Aggregate" mode, "compress and enumerate without duplicates", but then the "show field as link" does not work anymore on the title field (this is not workflow related): you get the html on screen instead of the proper link it should create.
    - The order of workflow status also seems to be on the system name of the workflow status and not the description of it, rewriting the result with the value itself also does not help.

  • 🇳🇱Netherlands johnv

    Hmm, I checked the code.
    There are no provisions for sorting, so the field should behave as any other 'list' field with value and name.
    What happens if you show only 1 block on a page? (or was that your first test? )
    Perhaps something is broken if +1 Workflow State fields are on the page?

  • Sorting while having multiple workflow states on 1 page is not working.

    1 workflow state field works better, but not yet completely correct to me.

    I added 3 screenshots... test with a single block view on a page:
    - ws_default_order is the order on the title (the first column).
    - ws_order_down is the order after pressing once on the header of the workflow state (the second column): not that the workflow state order remains, while alphabetically they should change.
    - ws_order_up is the order after pressing once more on the header of the workflow state: now they are in the proper order according to the workflow state (first letters V, G, F in descending order)

    I only see 2 orders of workflow states no matter how many times I click on the workflow state header: the order according to title and the descending order by workflow state, the ascending order does not show.

Production build 0.71.5 2024