|
1 | | -{{!-- This is a form that will submit data using POST method to the URL specified in the top-level 'action' property coming from the SQL query--}} |
| 1 | +{{!-- This is a form that will post data to the URL specified in the top-level 'action' property coming from the SQL query --}} |
2 | 2 | <form method="POST" action="{{action}}"> |
3 | 3 | {{!-- Create a row with centered content and spacing between items --}} |
4 | 4 | <div class="row justify-content-center align-items-center g-4"> |
5 | | - {{!-- Left List Box (5 columns wide) --}} |
| 5 | + {{!-- Left List Box: 5 columns wide (out of the 12 made available by bootstrap) --}} |
6 | 6 | <div class="col-5"> |
7 | 7 | {{!-- Card with no border and subtle shadow --}} |
8 | 8 | <div class="card border-0 shadow-sm"> |
| 9 | + {{!-- Card header with white background, no border, semibold font, and secondary text color --}} |
9 | 10 | <div class="card-header bg-white border-bottom fw-semibold text-secondary py-3"> |
10 | 11 | Available Items |
11 | 12 | </div> |
|
66 | 67 | {{!-- JavaScript code with CSP (Content Security Policy) nonce for security --}} |
67 | 68 | <script nonce="{{@csp_nonce}}"> |
68 | 69 | // Get references to both list elements |
| 70 | + // If we wanted to be able to include this component multiple times on the same page, |
| 71 | + // we would need to generate IDs like "rightList1", "leftList1", etc. using a template string.like "rightList{{@component_index}}" |
69 | 72 | const rightList = document.getElementById('rightList'); |
70 | 73 | const leftList = document.getElementById('leftList'); |
71 | 74 |
|
|
85 | 88 | newOptions.sort((a, b) => a.text.localeCompare(b.text)); |
86 | 89 | |
87 | 90 | // Add all options to the destination list |
| 91 | + // Since an element can only exist once in the page, |
| 92 | + // this will automatically remove the options from the source list |
88 | 93 | toList.append(...newOptions); |
89 | 94 |
|
90 | 95 | // Focus the destination list and update submit button state |
|
103 | 108 | * Ensure all items in right list are selected before form submission |
104 | 109 | * This is necessary because unselected options aren't included in form data |
105 | 110 | */ |
106 | | - function handleSubmit(e) { |
| 111 | + function handleSubmit() { |
107 | 112 | for (const option of rightList.options) option.selected = true; |
108 | 113 | } |
109 | 114 |
|
|
0 commit comments