diff --git a/phpmyfaq/admin/assets/src/content/faqs.overview.js b/phpmyfaq/admin/assets/src/content/faqs.overview.js index 6beac58878..3c9558663b 100644 --- a/phpmyfaq/admin/assets/src/content/faqs.overview.js +++ b/phpmyfaq/admin/assets/src/content/faqs.overview.js @@ -38,15 +38,10 @@ export const handleFaqOverview = async () => { const faqs = await fetchAllFaqsByCategory(categoryId, language, onlyInactive, onlyNew); await populateCategoryTable(categoryId, faqs.faqs); const deleteFaqButtons = document.querySelectorAll('.pmf-button-delete-faq'); - const toggleStickyAllFaqs = document.querySelectorAll('.pmf-admin-faqs-all-sticky'); const toggleStickyFaq = document.querySelectorAll('.pmf-admin-sticky-faq'); - const toggleActiveAllFaqs = document.querySelectorAll('.pmf-admin-faqs-all-active'); const toggleActiveFaq = document.querySelectorAll('.pmf-admin-active-faq'); const translationDropdown = document.querySelectorAll('#dropdownAddNewTranslation'); - allFaqsAreActive(categoryId); - allFaqsAreSticky(categoryId); - deleteFaqButtons.forEach((element) => { element.addEventListener('click', async (event) => { event.preventDefault(); @@ -98,29 +93,6 @@ export const handleFaqOverview = async () => { }); }); - toggleStickyAllFaqs.forEach((element) => { - element.addEventListener('change', async (event) => { - event.preventDefault(); - - const categoryId = event.target.getAttribute('data-pmf-category-id'); - const faqIds = []; - const token = event.target.getAttribute('data-pmf-csrf'); - - const checkboxes = document.querySelectorAll('input[type=checkbox]'); - if (checkboxes) { - checkboxes.forEach((checkbox) => { - if (checkbox.getAttribute('data-pmf-category-id-sticky') === categoryId) { - checkbox.checked = element.checked; - if (checkbox.checked === true) { - faqIds.push(checkbox.getAttribute('data-pmf-faq-id')); - } - } - }); - await saveStatus(categoryId, faqIds, token, event.target.checked, 'sticky'); - } - }); - }); - toggleStickyFaq.forEach((element) => { element.addEventListener('change', async (event) => { event.preventDefault(); @@ -133,29 +105,6 @@ export const handleFaqOverview = async () => { }); }); - toggleActiveAllFaqs.forEach((element) => { - element.addEventListener('change', async (event) => { - event.preventDefault(); - - const categoryId = event.target.getAttribute('data-pmf-category-id'); - const faqIds = []; - const token = event.target.getAttribute('data-pmf-csrf'); - - const checkboxes = document.querySelectorAll('input[type=checkbox]'); - if (checkboxes) { - checkboxes.forEach((checkbox) => { - if (checkbox.getAttribute('data-pmf-category-id-active') === categoryId) { - checkbox.checked = element.checked; - if (checkbox.checked === true) { - faqIds.push(checkbox.getAttribute('data-pmf-faq-id')); - } - } - }); - await saveStatus(categoryId, faqIds, token, event.target.checked, 'active'); - } - }); - }); - toggleActiveFaq.forEach((element) => { element.addEventListener('change', async (event) => { event.preventDefault(); @@ -349,28 +298,6 @@ const clearCategoryTable = (categoryId) => { tableBody.innerHTML = ''; }; -const allFaqsAreActive = (categoryId) => { - const checkboxes = document.querySelectorAll('.pmf-admin-active-faq'); - const allChecked = Array.from(checkboxes).every((checkbox) => checkbox.checked); - if (allChecked) { - const mainCheckboxToggle = document.getElementById(`active_category_block_${categoryId}`); - if (mainCheckboxToggle) { - mainCheckboxToggle.checked = true; - } - } -}; - -const allFaqsAreSticky = (categoryId) => { - const checkboxes = document.querySelectorAll('.pmf-admin-sticky-faq'); - const allChecked = Array.from(checkboxes).every((checkbox) => checkbox.checked); - if (allChecked) { - const mainCheckboxToggle = document.getElementById(`sticky_category_block_${categoryId}`); - if (mainCheckboxToggle) { - mainCheckboxToggle.checked = true; - } - } -}; - const initializeCheckboxState = () => { const filterForInactive = document.getElementById('pmf-checkbox-filter-inactive'); const filterForNew = document.getElementById('pmf-checkbox-filter-new'); diff --git a/phpmyfaq/assets/templates/admin/content/faq.overview.twig b/phpmyfaq/assets/templates/admin/content/faq.overview.twig index bf5048a180..3fd720b7c1 100644 --- a/phpmyfaq/assets/templates/admin/content/faq.overview.twig +++ b/phpmyfaq/assets/templates/admin/content/faq.overview.twig @@ -71,24 +71,10 @@ {{ msgDate }}