filament icon indicating copy to clipboard operation
filament copied to clipboard

Reordering records when default order direction should be descending

Open naturalGroove opened this issue 1 year ago • 3 comments

Package

filament/filament

Package Version

v3.2.117

Laravel Version

v11.29.0

Livewire Version

v3.5.12

PHP Version

PHP 8.2.22

Problem description

Problem related to using Spatie's SortableTrait in the project

When we set the reorderable() parameter for the table and when we need the records on the page to appear in descending order, we cannot correctly set the order for the items in the reorder view. I hope it sounds somewhat understandable ;)

Unfortunately, I did not find a solution to this problem in the table configuration options in the resource class. I have a certain solution to this problem, here is a link to the repository:

https://github.com/naturalGroove/filament/tree/add-more-reorderable-configuration

Expected behavior

Ability to display records in descending order in the reorder view and correctly save the order in the database.

Steps to reproduce

Install the repository below and try to reorder Posts.

Make sure to:

migrate + seed database login using email - pw: [email protected] - test

Reproduction repository (issue will be closed if this is not valid)

https://github.com/naturalGroove/filament-reorderable-when-order-is-desc

Relevant log output

No response

naturalGroove avatar Oct 28 '24 20:10 naturalGroove

I like this suggestion because we've just experienced a similar problem.

Our scenario:

  • We have dozens/hundreds of records that have not been explicitly ordered. (Their 'sort' column is null.)
  • The default sort is by the record's name column, ascending.
  • We would like to reorder.
  • When we enter "reorder mode", we get a very different ordering from what we were viewing.
  • Now the user has to do a significant amount of work to make some relatively insignificant changes.

It would be nice to be able to do something like what was suggested here, but to hook into (or provide) the query that is used to generate the list of records for the "reorder mode" view. 🤔

telkins avatar Jun 06 '25 13:06 telkins

@telkins that sounds like a different issue from what I can tell, this is about reordering in descending order.

danharrin avatar Jun 06 '25 15:06 danharrin

@telkins that sounds like a different issue from what I can tell, this is about reordering in descending order.

Perhaps I misunderstood. I thought there was a similarity in that @naturalGroove wanted to affect the sorting when in "reorder mode" by modifying the query and we want to do the same. In his case, he simply changes from ascending to descending, but we want to have greater/broader control.

Not sure if that makes sense. Also not sure I'm correct in the similarities. It's Friday and it's been a long week. 😅

In any case, does the scenario I'm talking about make sense? Is it something that would be a nice addition to Filament, in your opinion? 🤔

telkins avatar Jun 06 '25 17:06 telkins