Films
@@ -249,15 +249,24 @@
const catSelect = document.getElementById('{{ form.category.id_for_label }}');
const progressRange = document.getElementById('{{ form.progress_percent.id_for_label }}');
const progressDisplay = document.getElementById('progress-display');
+ const itemStatus = '{{ item.status|default:"active" }}';
- function updateSections() {
- document.querySelectorAll('.cat-section').forEach(el => el.style.display = 'none');
- const sec = document.getElementById('section-' + catSelect.value);
- if (sec) sec.style.display = 'block';
+ function updateVisibility() {
+ const cat = catSelect.value;
+
+ // Show only the section matching the selected category
+ document.querySelectorAll('[data-show-category]').forEach(el => {
+ el.style.display = el.dataset.showCategory === cat ? 'block' : 'none';
+ });
+
+ // Hide fields that are not applicable for the current status
+ document.querySelectorAll('[data-hide-status]').forEach(el => {
+ el.style.display = el.dataset.hideStatus === itemStatus ? 'none' : '';
+ });
}
- catSelect.addEventListener('change', updateSections);
- updateSections();
+ catSelect.addEventListener('change', updateVisibility);
+ updateVisibility();
progressRange.addEventListener('input', function() {
progressDisplay.textContent = Math.round(this.value) + '%';