|
261 | 261 | const filterWithReviewsSelect = document.querySelector('#filter-with-n-reviews'); |
262 | 262 | const filterByStatusInputs = [...document.querySelectorAll('input[name="filter-by-status"]')]; |
263 | 263 | const filterByTypeInputs = [...document.querySelectorAll('input[name="filter-by-type"]')]; |
| 264 | + const filterBySpeakerInput = document.querySelector('#filter-by-speaker'); |
264 | 265 |
|
265 | 266 | const applyFilters = () => { |
266 | 267 | const reviewFilterValue = filterWithReviewsSelect.value; |
267 | 268 | const visibleStatuses = filterByStatusInputs.filter(input => input.checked).map(input => input.value); |
268 | 269 | const visibleTypes = filterByTypeInputs.filter(input => input.checked).map(input => input.value); |
| 270 | + const speakerFilter = filterBySpeakerInput.value.toLowerCase().trim(); |
269 | 271 |
|
270 | 272 | document.querySelectorAll('.proposal-item').forEach(proposalRow => { |
271 | 273 | const proposalId = parseInt(proposalRow.id.split('-')[1], 10); |
|
274 | 276 | const matchesReviews = reviewFilterValue === 'all' || proposalData.numOfVotes === parseInt(reviewFilterValue, 10); |
275 | 277 | const matchesStatus = visibleStatuses.includes(proposalData.originalStatus); |
276 | 278 | const matchesType = visibleTypes.includes(proposalData.submissionType); |
| 279 | + const matchesSpeaker = !speakerFilter || proposalData.speakerName.toLowerCase().includes(speakerFilter); |
277 | 280 |
|
278 | | - if (matchesReviews && matchesStatus && matchesType) { |
| 281 | + if (matchesReviews && matchesStatus && matchesType && matchesSpeaker) { |
279 | 282 | proposalRow.classList.remove('hidden'); |
280 | 283 | } else { |
281 | 284 | proposalRow.classList.add('hidden'); |
|
286 | 289 | filterWithReviewsSelect.addEventListener('change', applyFilters); |
287 | 290 | filterByStatusInputs.forEach(input => input.addEventListener('change', applyFilters)); |
288 | 291 | filterByTypeInputs.forEach(input => input.addEventListener('change', applyFilters)); |
| 292 | + filterBySpeakerInput.addEventListener('input', applyFilters); |
289 | 293 | }); |
290 | 294 |
|
291 | 295 | const updateBottomBarUI = () => { |
@@ -405,6 +409,10 @@ <h3>Show proposals with pending status:</h3> |
405 | 409 | {% endfor %} |
406 | 410 | </div> |
407 | 411 | </div> |
| 412 | + <div class="opt-filter"> |
| 413 | + <h3>Filter by speaker name:</h3> |
| 414 | + <input type="text" id="filter-by-speaker" placeholder="Type speaker name..." /> |
| 415 | + </div> |
408 | 416 | <div class="opt-filter"> |
409 | 417 | <h3>Show proposals of type:</h3> |
410 | 418 | <div> |
@@ -464,6 +472,7 @@ <h3>Show proposals of type:</h3> |
464 | 472 | languages: [{% for language in item.languages.all %}"{{language.code}}",{% endfor %}], |
465 | 473 | numOfVotes: {{item.userreview_set.count}}, |
466 | 474 | submissionType: "{{ item.type.name }}", |
| 475 | + speakerName: "{{ item.speaker.fullname|escapejs }}", |
467 | 476 | }; |
468 | 477 | </script> |
469 | 478 | <tr class="proposal-item" id="submission-{{item.id}}" data-original-status="{{ item.current_or_pending_status }}"> |
|
0 commit comments