Skip to content

OBPIH-6991 Add multi-select product filter to consumption report#5560

Merged
alannadolny merged 5 commits intodevelopfrom
ft/OBPIH-6991
Oct 22, 2025
Merged

OBPIH-6991 Add multi-select product filter to consumption report#5560
alannadolny merged 5 commits intodevelopfrom
ft/OBPIH-6991

Conversation

@alannadolny
Copy link
Collaborator

This PR is created based on OBPIH-6933, so I set it as a base branch for easier review.

@alannadolny alannadolny self-assigned this Oct 20, 2025
@alannadolny alannadolny added the warn: do not merge Marks a pull request that is not yet ready to be merged label Oct 20, 2025
@github-actions github-actions bot added type: feature A new piece of functionality for the app domain: frontend Changes or discussions relating to the frontend UI domain: backend Changes or discussions relating to the backend server domain: l10n Changes or discussions relating to localization & Internationalization labels Oct 20, 2025
@codecov
Copy link

codecov bot commented Oct 20, 2025

Codecov Report

❌ Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 8.53%. Comparing base (1bb7314) to head (a0f9a0a).
⚠️ Report is 152 commits behind head on develop.

Files with missing lines Patch % Lines
...s-app/taglib/org/pih/warehouse/SelectTagLib.groovy 0.00% 6 Missing ⚠️
...h/warehouse/reporting/ConsumptionController.groovy 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             develop   #5560      +/-   ##
============================================
- Coverage       9.12%   8.53%   -0.59%     
+ Complexity      1170    1112      -58     
============================================
  Files            701     702       +1     
  Lines          45281   45335      +54     
  Branches       10851   10867      +16     
============================================
- Hits            4131    3869     -262     
- Misses         40497   40887     +390     
+ Partials         653     579      -74     

☔ 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.

if (command.selectedProducts) {
List<String> selectedIds = command.selectedProducts*.id
command.rows.keySet().removeAll { row -> !(row.id in selectedIds) }
}
Copy link
Member

@ewaterman ewaterman Oct 20, 2025

Choose a reason for hiding this comment

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

if you're just using the ids, not the whole product itself, why not have the command take a List<String> selectedProductIds so that you don't need to bind them to the real objects?

EDIT: on second thought, I think the way you have it is fine. I doubt it's a huge performance difference to look up a handful of domains by ids.

</div>
<div class="filter-list-item">
<label>
<warehouse:message code="consumption.products.label" default="Products"/>
Copy link
Member

Choose a reason for hiding this comment

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

should be g:message right?

data-testid="product-select"
multiple="true"
/>
</div>
Copy link
Member

Choose a reason for hiding this comment

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

heads up that I modified this slightly in my PR. You should only need to do:

<g:selectProductAjax
    id="..."
    value="${command?.selectedProducts}"
    multiple="true"
/>

String text = val.name ?: val.toString()
"<option value='${id}' selected='true'>${text.encodeAsHTML()}</option>"
}.join("\n")
}
Copy link
Member

Choose a reason for hiding this comment

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

why do you need to build the options yourself? For me it auto-generates them:

Image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Those options that I added are used for pushing params to the URL:
image
it looks like those options generated by jquery are not appended to the URL (?)

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if instead of adding new elements, you could modify the existing options. From my screenshot, it already has the options elements with a value attribute correctly set to the id. It looks like the only difference in your code is that you add a selected='true' attribute. Is that what's required for you to get it in the url?

Base automatically changed from ft/OBPIH-6993-filter-transaction-report-by-product to develop October 21, 2025 23:18
Boolean isCsvReport = params.format == "text/csv"
List<Object> data = reportService.getTransactionReport(location, categories, tagList, catalogList, startDate, endDate, isCsvReport)
List<Object> data = reportService.getTransactionReport(
location,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we move the location and categories fallback to the service (or data binding in command) and just pass the command instead location, categories, producs, start, and end date? Additionally are we able to move params into the command too?

@alannadolny alannadolny merged commit 951b623 into develop Oct 22, 2025
7 checks passed
@alannadolny alannadolny deleted the ft/OBPIH-6991 branch October 22, 2025 10:36
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 domain: l10n Changes or discussions relating to localization & Internationalization type: feature A new piece of functionality for the app warn: do not merge Marks a pull request that is not yet ready to be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants