Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable link from sortableLink() when there aren't any entries #136

Open
danielbachhuber opened this issue Nov 1, 2019 · 3 comments
Open

Comments

@danielbachhuber
Copy link

danielbachhuber commented Nov 1, 2019

If the collection doesn't contain any entries, it would be nice if sortableLink() only displayed the title, and didn't render a link.

Happy to submit a pull request if you can provide some direction. My code has a bunch of ugly conditionals right now.

@Kyslik
Copy link
Owner

Kyslik commented Nov 2, 2019

Could you please elaborate a bit more and provide an example?

Yea all PRs are welcome. Most likely you want to take a look at https://github.com/Kyslik/column-sortable/blob/L6/src/ColumnSortable/SortableLink.php#L21 function and do some shenanigans there.

@danielbachhuber
Copy link
Author

Sorry for the late reply here.

Could you please elaborate a bit more and provide an example?

Sure. Here's my sortable table that has entries:

image

When there are no results on the table, I'd expect the table headings to render as, say, spans instead of links:

image

Most likely you want to take a look at https://github.com/Kyslik/column-sortable/blob/L6/src/ColumnSortable/SortableLink.php#L21 function and do some shenanigans there.

It looks like SortableLink doesn't have any knowledge of the result set it's sorting, which I suppose makes sense.

The simplest approach would be to add a new parameter, and make it the responsibility of the caller to determine whether the SortableLink should render. I don't love this though. Can you think of a more elegant approach?

@Healyhatman
Copy link
Collaborator

@if($collection->isNotEmpty()) @sortablelink() @else just text @endif

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants