1515 show_details : false
1616 } %}
1717 {% endif %}
18-
18+
1919 <div class =" row mb-3" >
2020 <div class =" col-12" >
2121 <div class =" alert alert-info" >
3030 </div >
3131
3232 {{ form_start(form ) }}
33-
33+
3434 <div class =" row mb-3" >
3535 <div class =" col-md-6" >
3636 {{ form_row(form .delimiter ) }}
8383 {% endif %}
8484 </td >
8585 <td >
86- <input type =" number"
87- class =" form-control form-control-sm priority-input"
88- min =" 1"
89- value =" 10"
86+ <input type =" number"
87+ class =" form-control form-control-sm priority-input"
88+ min =" 1"
89+ value =" 10"
9090 style =" width: 80px;"
9191 data-field =" {{ field }}"
9292 title =" {% trans %}project.bom_import.field_mapping.priority_help{% endtrans %}" >
9696 </tbody >
9797 </table >
9898 </div >
99-
99+
100100 <div class =" mt-3" >
101101 <h6 >{% trans %}project.bom_import.field_mapping.summary{% endtrans %}:</h6 >
102102 <div id =" mapping-summary" class =" alert alert-info" >
121121
122122 {{ form_end(form ) }}
123123
124- <script >
124+ <script nonce = " {{ csp_nonce( ' script ' ) }} " >
125125 // Function to initialize the field mapping page
126126 function initializeFieldMapping () {
127127 const suggestions = {{ suggested_mapping| json_encode| raw }};
128128 const fieldNameMapping = {{ field_name_mapping| json_encode| raw }};
129-
129+
130130 Object .keys (suggestions).forEach (function (field ) {
131131 // Use the sanitized field name from the server-side mapping
132132 const sanitizedField = fieldNameMapping[field];
135135 select .value = suggestions[field];
136136 }
137137 });
138-
138+
139139 // Update mapping summary
140140 updateMappingSummary ();
141-
141+
142142 // Add event listeners for dynamic updates
143143 document .querySelectorAll (' .field-mapping-select' ).forEach (function (select ) {
144144 select .addEventListener (' change' , updateMappingSummary);
145145 });
146-
146+
147147 document .querySelectorAll (' .priority-input' ).forEach (function (input ) {
148148 input .addEventListener (' change' , updateMappingSummary);
149149 });
158158 initializeFieldMapping ();
159159 }
160160 });
161-
161+
162162 function updateMappingSummary () {
163163 const summary = document .getElementById (' mapping-summary' );
164164 const mappings = {};
165165 const priorities = {};
166-
166+
167167 // Collect all mappings and priorities
168168 document .querySelectorAll (' .field-mapping-select' ).forEach (function (select ) {
169169 const field = select .getAttribute (' data-field' );
170170 const target = select .value ;
171171 const priorityInput = document .querySelector (' .priority-input[data-field="' + field + ' "]' );
172172 const priority = priorityInput ? parseInt (priorityInput .value ) || 10 : 10 ;
173-
173+
174174 if (target && target !== ' ' ) {
175175 if (! mappings[target]) {
176176 mappings[target] = [];
181181 });
182182 }
183183 });
184-
184+
185185 // Sort by priority and build summary
186186 let summaryHtml = ' <div class="row">' ;
187187 Object .keys (mappings).forEach (function (target ) {
188188 const fieldMappings = mappings[target].sort ((a , b ) => a .priority - b .priority );
189189 const fieldList = fieldMappings .map (m => m .field + ' (' + ' {{ "project.bom_import.field_mapping.priority_short"|trans }}' + m .priority + ' )' ).join (' , ' );
190-
190+
191191 summaryHtml += ' <div class="col-md-6 mb-2">' ;
192192 summaryHtml += ' <strong>' + target + ' :</strong> ' + fieldList;
193193 summaryHtml += ' </div>' ;
194194 });
195195 summaryHtml += ' </div>' ;
196-
196+
197197 if (Object .keys (mappings).length === 0 ) {
198198 summary .innerHTML = ' <i class="fa-solid fa-info-circle fa-fw"></i> {{ "project.bom_import.field_mapping.select_to_see_summary"|trans }}' ;
199199 } else {
200200 summary .innerHTML = summaryHtml;
201201 }
202202 }
203203 </script >
204- {% endblock %}
204+ {% endblock %}
0 commit comments