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

Fixed: Blank select on custom reports causing empty exports #14110

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

akemidx
Copy link
Collaborator

@akemidx akemidx commented Jan 8, 2024

Description

Custom reports have some fields that are multi select. It was originally possible to select an option, and then x out that option, but leave a "blank" choice in that field. Generating the report would end up passing that blank option as a search parameter, and returning an empty report.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

created and ran tests to confirm payload is as expected
practical testing for visual confirmation

Checklist:

Copy link

what-the-diff bot commented Jan 8, 2024

PR Summary

  • Enhanced Company Selections Functionality
    Updated the 'company-select.blade.php' file. Now it can handle multiple company selections more effectively due to the added conditional logic.

  • Improved Location Selections Process
    A modification in the 'location-select.blade.php' file has led to a better management of multiple location selections, thanks to the newly implemented conditional logic.

  • Upgraded Model Selections Capability
    The changes in the 'model-select.blade.php' file now allow for more streamlined handling of multiple model selections by incorporating conditional logic.

  • Better Status Selections Management
    Integration of additional conditional logic in the 'status-select.blade.php' file enhances functionality when dealing with multiple status selections.

  • Optimized Supplier Selections Method
    The 'supplier-select.blade.php' file was improved and can now efficiently handle multiple supplier selections due to the newly added conditional logic.

@snipe snipe changed the title BUG FIX: Blank select on custom reports causing empty exports Fixed: Blank select on custom reports causing empty exports Jan 9, 2024
@akemidx akemidx requested a review from uberbrady January 9, 2024 20:05
Copy link
Owner

@snipe snipe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions/fixes requested.

@else
<option value="" role="option">{{ trans('general.select_location') }}</option>
@endif
{{ ((isset($multiple)) && ($multiple=='true')) ? " multiple='multiple'" : '' }}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this check does?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, what we want to do is check that there is a multiple value set, so ignore anything that does NOT ever deal with multiple values. and then also that that value is true.

The original way I wrote it (the in red bits) was how I figured out how to get rid of the bug. It took some trial and error and that's how I came up with the fix, tho it was a bit dupilcative with how it was written.

Addmittedly I am still a bit new with ternary syntax, so I might have oopsed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That line ends up writing multiple=multiple onto the page without any effect:
extra text added to page

Did you mean to make that an @isset blade directive to match the one added below on line 12?

@endif
{{ ((isset($multiple)) && ($multiple=='true')) ? " multiple='multiple'" : '' }}
@if($location_id = old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
<option value="{{ $location_id }}" selected="selected" role="option" aria-selected="true" role="option">
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

role="option" is in here twice

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove that, but that is actually in the selects a LOT. including blades I never touched.
for example: resources/views/partials/forms/edit/asset-select.blade.php or resources/views/partials/forms/edit/user-select.blade.php

I'll update those too.

@marcusmoore
Copy link
Collaborator

Ah! It took me a minute to realize what the issue is. Here's a video and screenshot demonstrating the problem:

CleanShot.2024-01-30.at.11.24.42.mp4

showing blank entry in multiselect

Copy link
Collaborator

@marcusmoore marcusmoore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR actually fixes the bug but there are some changes that should be made before merging.

@else
<option value="" role="option">{{ trans('general.select_location') }}</option>
@endif
{{ ((isset($multiple)) && ($multiple=='true')) ? " multiple='multiple'" : '' }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That line ends up writing multiple=multiple onto the page without any effect:
extra text added to page

Did you mean to make that an @isset blade directive to match the one added below on line 12?

<option value="" role="option">{{ trans('general.select_location') }}</option>
@endif
{{ ((isset($multiple)) && ($multiple=='true')) ? " multiple='multiple'" : '' }}
@if($location_id = old($fieldname, (isset($item)) ? $item->{$fieldname} : ''))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This @if isn't closed properly. I'm not sure if it's working because @endisset is closing it but it should have a matching @endif added.

(the other selects in this PR should be updated as well)

Copy link
Collaborator

@marcusmoore marcusmoore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for the fix 😄

@InsidePlay

This comment was marked as spam.

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

Successfully merging this pull request may close these issues.

None yet

4 participants