Problem/Motivation

When viewing the sortable view, and clicking the "show row weights" link, it adds the column but the column is just empty text fields and the row weights can't be changed. This is also the same view you see if you don't have permission to sort draggable views.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bsufan17 created an issue. See original summary.

mimran’s picture

Specifically now you need to select the view handler as showed on the image this is a fix added to 2.x version
fix

bsufan17’s picture

@mimran this does not solve the problem. I'd like to be able to manually type the row weight I want to apply to an item but the text field for the row weight is empty and won't allow me to type anything.

voleger’s picture

Don`t set the draggable sort plugin in the fields as the first column in the table.
And yes, the table display plugin is the one that works properly with the module for weight source view.

bsufan17’s picture

I don't have it set as the first column. It's the last column actually. I can drag and drop the order, but if I use the "show row heights" link to be able to edit the row weights by typing the number I want, the text fields are empty and disabled.

voleger’s picture

According to #5 description of the behavior looks like it could be the client-side issue. Did you check the browser dev console? Maybe there are some JS error messages?

bsufan17’s picture

StatusFileSize
new27.91 KB

Checked the console and there are no js errors, or any warnings for that matter. I also tried disabling js aggregation. The attached screenshot shows what I'm seeing.

jasminewu’s picture

I got the same issue with Seven theme. And I found that's because the draggableviews th has a class: select-all. And [width: 1px;] apply on th .select-all.
My solution: hook_preprocess_views_view_table() remove the class: select-all

bsufan17’s picture

@jasmineWu Thank you! That solved it for me as well. I am using the Claro theme on other sites, but the solution was the same there as well.

anagomes’s picture

@JasmineWu Thanks, I was having the same issue using the Gin theme, and your suggestion solved it for me. I'll leave an example of code if anyone needs it:

function module_preprocess_views_view_table(array &$variables) {
  if (!isset($variables['view']->field['draggableviews'])) {
    return;
  }

  $variables['header']['draggableviews']['attributes']->removeClass('select-all');
}
altcom_neil’s picture

StatusFileSize
new420 bytes

Is there any reason that this shouldn't be done in the module itself - does removing this class cause any problems.
Attaching a patch to remove.

j_s’s picture

StatusFileSize
new498 bytes

#11 breaks the page if there are no table headers. This case can happen if fields are added and their labels are removed. I had this happen when I had another view display that has fields but no labels. I cloned the display and re-arranged the new page so that it could act as a reordering page using the same fields as the original display. But since it had no labels to make into table headers, it white-screened the reordering page and gave an error.

Notice: Undefined index: draggableviews in draggableviews_preprocess_views_view_table() (line 90 of /drupal/web/modules/contrib/draggableviews/draggableviews.module)

Attached is an updated patch to check if $variables['header']['draggableviews']['attributes'] is set.

thanksneco’s picture

#12 patch works perfectly in Drupal 10 as of Jan 2024.

Also, if you don't want to patch the module, you can use #10 example in your site's admin theme and that will fix the issue as well.

Thank you everyone for your fixes with this issue!

joegraduate’s picture

Status: Active » Needs review
joegraduate’s picture

Status: Needs review » Reviewed & tested by the community

We've been using the patch from #11 #12 on a large number of sites successfully since September 2023.

devad’s picture

Patch #12 fixed the issue for me.

DraggableViews 2.1.4
D10.3.1
PHP 8.1

voleger’s picture

Version: 2.0.1 » 2.1.x-dev

Created MR based on #12 patch

istryker’s picture

I was able to reproduce it on a fresh Drupal 11 installation with draggableviews demo submodule installed. Viewing the demo table order table, I did not see any problems as described. I did see it broken on the view edit "preview". MR fixed it. Merged.

istryker’s picture

Status: Reviewed & tested by the community » Fixed
voleger’s picture

Status: Fixed » Reviewed & tested by the community

It not merged yet

istryker’s picture

Looks like you are correct. I click the merge button, but it fails. I will take a look at why.

  • istryker committed 7d1bec78 on 2.1.x
    Issue #3252365 by voleger: Row weights not displaying on sort view
    
istryker’s picture

Problems with merge requests. Fixed the coding standards but still had problems with PHPUnit. Pushing manually

istryker’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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