Kyslik / column-sortable

Package for handling column sorting in Laravel 5/6/7/8
MIT License
644 stars 105 forks source link

Overriding the direction parameter #187

Open khamyl opened 2 years ago

khamyl commented 2 years ago

Is there a possibility to override the direction parameter? I needed to have two different buttons for ASC and DESC so the toggle did not work for me. I could not find the workaround, so I suggest the following edit to the code to support this by using the queryParameters['direction']:

Edits

determineDirection() function

render() function

Usage

View

<ul class="dropdown-menu pull-right">
    <li>@sortablelink('tag', 'Alphabetically [A-Z]', ['direction'=>'asc'])</li>
    <li>@sortablelink('tag', 'Reverse Alphabetically [Z-A]', ['direction'=>'desc'])</li>
    <li><a href="#">TBD: Most documents</a></li>
    <li><a href="#">TBD: Fewest documents</a></li>
    <li class="divider"></li>
    <li><a href="/tags">Reset (by Time Created)</a></li>
</ul>

Added pull request: https://github.com/Kyslik/column-sortable/pull/188