Include active filters in navigation for review-next and skip actions
This commit is contained in:
@@ -141,16 +141,26 @@
|
||||
skipBtn.disabled = true;
|
||||
});
|
||||
|
||||
// Navigate to the review-next endpoint without query parameters
|
||||
// Build base URL for navigation
|
||||
const base = "{% url app_name|add:':question_review_next' %}";
|
||||
|
||||
// Active filters passed from server-side context
|
||||
const activeCategory = "{{ filters.category|default:'' }}";
|
||||
const activeStatus = "{{ filters.status|default:'' }}";
|
||||
|
||||
// Navigate to the review-next endpoint including current filters
|
||||
nextBtn.addEventListener('click', function(){
|
||||
const base = "{% url app_name|add:':question_review_next' %}";
|
||||
window.location.href = base;
|
||||
const params = new URLSearchParams();
|
||||
if (activeCategory) params.set('category', activeCategory);
|
||||
if (activeStatus) params.set('status', activeStatus);
|
||||
// Next navigates to the next matching item (no skip)
|
||||
const qs = params.toString();
|
||||
window.location.href = qs ? (base + '?' + qs) : base;
|
||||
});
|
||||
|
||||
// Skip: increment 'skip' query param (defaults to 1) and include current filters
|
||||
const skipBtn = document.getElementById('review-skip-btn');
|
||||
skipBtn.addEventListener('click', function(){
|
||||
const base = "{% url app_name|add:':question_review_next' %}";
|
||||
// read existing skip from current URL (if present) and increment
|
||||
const curParams = new URLSearchParams(window.location.search);
|
||||
let curSkip = parseInt(curParams.get('skip') || '0', 10) || 0;
|
||||
@@ -158,6 +168,8 @@
|
||||
|
||||
const params = new URLSearchParams();
|
||||
params.set('skip', String(newSkip));
|
||||
if (activeCategory) params.set('category', activeCategory);
|
||||
if (activeStatus) params.set('status', activeStatus);
|
||||
|
||||
window.location.href = base + '?' + params.toString();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user