Reset button, to reset the weight all back to 0

Created on 20 September 2023, over 1 year ago

Problem/Motivation

I want to be able to reset a sorted view back to default, where all the weight values start at zero. This is an update of an existing issue ( https://www.drupal.org/project/draggableviews/issues/2420391 β†’ ) but for the latest version of the module. That other ticket is 5 years old and for the Drupal 7 version of the module.

Proposed resolution

Add another button to the view, next to the "Save Order" button that will "Reset Order".

✨ Feature request
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States aaronpinero

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

Comments & Activities

  • Issue created by @aaronpinero
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States aaronpinero

    I am adding a patch which seems to, at least in my limited manual testing, provide the solution. I updated the .module file to add a draggableviews_views_reset handler function. This function is a near exact copy of the draggableviews_views_submit function, except all the weight values are set to 0 when data is written to the database. I also updated the draggableviews_form_alter to add the reset button.

    It would be great if a maintainer could take a look at this. I think this is an easy and sensible addition to the module.

  • πŸ‡ΊπŸ‡ΈUnited States aaronpinero

    I realize I provided an incorrect solution. I will update the patch so, to reset, the table rows are not written to the database in the reset handler.

  • Status changed to Needs work over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States aaronpinero
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States aaronpinero

    Okay, I have provided an updated patch that, to reset a sort view, executes the deletion of rows from the db table but doesn't write any new data. I think this is more in keeping with the solution proposed in the original issue.

  • Status changed to RTBC 2 months ago
  • πŸ‡¨πŸ‡¦Canada iStryker

    We have been using it on all university sites for 11 months. I re-reviewed it. It works.

  • πŸ‡¨πŸ‡¦Canada iStryker

    Merged

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

Production build 0.71.5 2024