Select forms in administration panel buttons don't work#632
Merged
Conversation
…d list options like production version
Reviewer's GuideRestore form selection button functionality and preserve user selections across submissions by refining the JSP form structure, leveraging JSTL functions for option state, and enhancing JavaScript to save and restore selections. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
There was a problem hiding this comment.
Hey there - I've reviewed your changes - here's some feedback:
- Using fn:contains on a comma-delimited string for matching selections is brittle and may yield false positives; consider splitting the saved selections into a list or using multiple hidden inputs for exact matches.
- Extract the inline JavaScript for saving/restoring selections into a separate JS file or utility function to improve maintainability and keep the JSP cleaner.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Using fn:contains on a comma-delimited string for matching selections is brittle and may yield false positives; consider splitting the saved selections into a list or using multiple hidden inputs for exact matches.
- Extract the inline JavaScript for saving/restoring selections into a separate JS file or utility function to improve maintainability and keep the JSP cleaner.
## Individual Comments
### Comment 1
<location> `src/main/webapp/form/formselect.jsp:65` </location>
<code_context>
size="10" style="width:150">
<c:forEach var="f" items="${formHiddenVector}">
- <option value="${f.formName}">
+ <option value="${f.formName}" <c:if test="${fn:contains(param.savedAddSelection, f.formName)}">selected</c:if>>
${f.formName}
</option>
</code_context>
<issue_to_address>
**issue (bug_risk):** Using 'fn:contains' for selection may cause issues if form names are substrings of each other.
This can lead to incorrect selection when form names overlap. Use exact matching or a delimiter to avoid this issue.
</issue_to_address>
### Comment 2
<location> `src/main/webapp/form/formselect.jsp:90` </location>
<code_context>
name="selectedDeleteTypes" size="10" style="width:150">
<c:forEach var="f" items="${formShownVector}">
- <option value="${f.formName}">
+ <option value="${f.formName}" <c:if test="${fn:contains(param.savedDeleteSelection, f.formName)}">selected</c:if>>
${f.formName}
</option>
</code_context>
<issue_to_address>
**issue (bug_risk):** Same substring matching issue applies to delete selection options.
Consider updating the matching logic for 'savedDeleteSelection' to prevent unintended selection of multiple options.
</issue_to_address>
### Comment 3
<location> `src/main/webapp/form/formselect.jsp:124-131` </location>
<code_context>
registerFormSubmit('selectForm', 'dynamic-content');
$(document).ready(function () {
+ // Restore selections on page load
+ var savedAdd = $("#savedAddSelection").val();
+ var savedDelete = $("#savedDeleteSelection").val();
+
+ if (savedAdd) {
+ $("select[name='selectedAddTypes']").val(savedAdd);
+ }
+ if (savedDelete) {
+ $("select[name='selectedDeleteTypes']").val(savedDelete);
+ }
</code_context>
<issue_to_address>
**issue (bug_risk):** Restoring selections with .val() may not work as expected for multiple selects if values are comma-separated strings.
If 'savedAdd' or 'savedDelete' are comma-separated, convert them to arrays before using .val() to ensure correct selection restoration.
</issue_to_address>
### Comment 4
<location> `src/main/webapp/form/formselect.jsp:136-138` </location>
<code_context>
$(".function").click(function () {
- $("#forward").val($(this).attr("id"));
-
+ // Save current selections to hidden fields
+ $("#savedAddSelection").val($("select[name='selectedAddTypes']").val() || '');
+ $("#savedDeleteSelection").val($("select[name='selectedDeleteTypes']").val() || '');
+ $("#forward").val($(this).attr("id"));
</code_context>
<issue_to_address>
**issue:** Saving selections as strings may not handle multiple selections correctly.
When multiple options are selected, .val() returns an array. Serialize the array before saving, and update the restoration logic to handle this format.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
yingbull
approved these changes
Sep 24, 2025
yingbull
approved these changes
Sep 24, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Options to Add/Delete/Move Up/Move Down don't work at all, this was fixed in this PR and I also went and fixed a form reset issue where selected options would reset and not have the correct selections when using any of the buttons. Now it is the same as production
Summary by Sourcery
Fix non-functional select form buttons in the administration panel and retain chosen options across Add/Delete/Move actions
Bug Fixes:
Enhancements: