Skip to content

OBPIH-6993 fix. Wrap text within select2 options and fix product avai…#5565

Merged
alannadolny merged 1 commit intodevelopfrom
bug/OBPIH-6993-2-text-wrap
Oct 24, 2025
Merged

OBPIH-6993 fix. Wrap text within select2 options and fix product avai…#5565
alannadolny merged 1 commit intodevelopfrom
bug/OBPIH-6993-2-text-wrap

Conversation

@ewaterman
Copy link
Member

…lability query

✨ Description of Change

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-6993

Description: Three changes:

  1. Remove the 'X' that clears the field of all selected values
  2. Text wrap selected products so they don't overflow the element
  3. Fix a query on product availability to handle no products being given

📷 Screenshots & Recordings (optional)

Screenshot from 2025-10-23 10-36-31

@ewaterman ewaterman self-assigned this Oct 23, 2025
@github-actions github-actions bot added type: bug Addresses unintended behaviours of the app domain: frontend Changes or discussions relating to the frontend UI domain: backend Changes or discussions relating to the backend server labels Oct 23, 2025
@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

❌ Patch coverage is 22.22222% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.52%. Comparing base (1bb7314) to head (ab08eb1).
⚠️ Report is 153 commits behind head on develop.

Files with missing lines Patch % Lines
...ehouse/inventory/ProductAvailabilityService.groovy 0.00% 12 Missing ⚠️
...n/groovy/org/pih/warehouse/core/db/GormUtil.groovy 66.66% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             develop   #5565      +/-   ##
============================================
- Coverage       9.12%   8.52%   -0.61%     
+ Complexity      1170    1113      -57     
============================================
  Files            701     703       +2     
  Lines          45281   45343      +62     
  Branches       10851   10868      +17     
============================================
- Hits            4131    3864     -267     
- Misses         40497   40905     +408     
+ Partials         653     574      -79     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

}

var \$state = \$(
"<span><span></span></span>"
Copy link
Member Author

Choose a reason for hiding this comment

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

fix 2: This formatSelectedOptions is what allows the selected products to text wrap

I don't know why it needs two spans to work 🤷. This is how it works in their example: https://select2.org/selections#templating. I tried playing around with it and couldn't get it to work otherwise

minimumInputLength: "${minSearchValueLength ?: "3"}",
width: "100%",
allowClear: true,
allowClear: false,
Copy link
Member Author

Choose a reason for hiding this comment

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

fix 1: this is what removes the 'X' that clears the whole element

WHERE
pa.location = :location
${quantityCondition}
${productsIds ? "AND pa.product.id IN (:products)" : ""}
Copy link
Member Author

Choose a reason for hiding this comment

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

fix 3: this is what fixes the broken query. On the reporting tab it's not required to pass in products so we only want to filter by them if given a non-empty list

Note: the reason I didn't catch this error initially is because it only happens when you set the end date == today. This is because this flow is only entered when fetching the current QoH, which allows us to rely on product availability. When end date < today, we need to calculate QoH at the time manually, and so don't query product availability

return args.findAll { paramName, paramValue ->
sql.contains("${PARAM_IDENTIFIER}${paramName}")
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Hurray Evan has an over the top solution again!

We're now only conditionally including a where product_id in (:products) clause to the SQL query (it is excluded if products is empty), and so need to only include a value for the :products param if the "where" is in the SQL.

Instead of adding an if (products) check when generating the list of params, I decided to create this util which will do it for us. That way we can always pass in all the params, and this util will filter out the ones that should be excluded.

@ewaterman ewaterman changed the title OBPIG-6993 fix. Wrap text within select2 options and fix product avai… OBPIH-6993 fix. Wrap text within select2 options and fix product avai… Oct 23, 2025
@alannadolny alannadolny merged commit 01c79b4 into develop Oct 24, 2025
7 checks passed
@alannadolny alannadolny deleted the bug/OBPIH-6993-2-text-wrap branch October 24, 2025 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server domain: frontend Changes or discussions relating to the frontend UI type: bug Addresses unintended behaviours of the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants