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

Order button persist even if Order display column is set to -- None -- #4930

Closed
SneakyGerald opened this issue May 11, 2020 · 8 comments · Fixed by #5003
Closed

Order button persist even if Order display column is set to -- None -- #4930

SneakyGerald opened this issue May 11, 2020 · 8 comments · Fixed by #5003

Comments

@SneakyGerald
Copy link

Version information

  • Laravel: v7.10.3
  • Voyager: v1.4.1
  • PHP: 7.2.29
  • Database: MySQL 15.1

Description

When I update Order display column in my bread settings and I set it to -- None -- then Order button still shows. Seems bread does update "order_display_column":"" and it excepts "order_display_column":null to not show Order button. If I change "" to null in MySQL then button disappears.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Go to any bread configuration
  2. Click on Order display column selection box
  3. Choose -- None -- option
  4. Go to bread browse view and then Order button still shows up, if you click it error is thrown.

Expected behavior

Order button should not be shown.

Screenshots

Bread browse view:
image

DB settings:
image

@MrCrayon
Copy link
Collaborator

You need to change Order column to None.

@SneakyGerald
Copy link
Author

SneakyGerald commented May 12, 2020

As far as I saw in browse view Order column is not the only column for the required condition:

@if(isset($dataType->order_column) && isset($dataType->order_display_column))
    <a href="{{ route('voyager.'.$dataType->slug.'.order') }}" class="btn btn-primary btn-add-new">
        <i class="voyager-list"></i> <span>{{ __('voyager::bread.order') }}</span>
    </a>
@endif

Both have to be set to show the button. In my case, only 1 is set to order the query result shown in the page.

@MrCrayon
Copy link
Collaborator

Yes, they are both used, should work with both and actually work for me.

This is what's saved in db if I change Display Column to None:

{"order_column":"title","order_display_column":null,"order_direction":"asc","default_search_key":null,"scope":null}

I see also scope is saved as empty string in your screenshot, did you disable ConvertEmptyStringsToNull Middleware?

P.S.
Thanks to your report I found a way to use automatic ordering and at the same time hide the order button for manual ordering 😀

@SneakyGerald
Copy link
Author

I see also scope is saved as empty string in your screenshot, did you disable ConvertEmptyStringsToNull Middleware?

Yeap, I think thats why it is saving "", but anyway is isset returning true when ""? Seem so, because the button shows. Is there any way to workaround it?

Thanks to your report I found a way to use automatic ordering and at the same time hide the order button for manual ordering

:) I'm using it in the same way.

@MrCrayon
Copy link
Collaborator

MrCrayon commented May 14, 2020

but anyway is isset returning true when ""? Seem so, because the button shows.

Empty string means variable is set as empty string.
For that check would probably be better to use !empty since an empty string would not be usable anyway and 0 is not a valid field name.

Is there any way to workaround it?

You could use ConvertEmptyStringsToNull only in that route.

@SneakyGerald
Copy link
Author

Ok, thank you I will try it.

@emptynick
Copy link
Collaborator

We could just use !empty() instead of isset()

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants