diff --git a/resources/forum/blade-tailwind/js/forum.js b/resources/forum/blade-tailwind/js/forum.js index 3753ae940..4580c217b 100644 --- a/resources/forum/blade-tailwind/js/forum.js +++ b/resources/forum/blade-tailwind/js/forum.js @@ -1,5 +1,5 @@ import feather from 'feather-icons'; -import { createApp, ref, reactive, watch } from 'vue/dist/vue.esm-bundler.js'; +import { createApp, ref, reactive, watch, computed } from 'vue/dist/vue.esm-bundler.js'; import axios from 'axios'; import Pickr from '@simonwep/pickr'; import draggable from 'vuedraggable/src/vuedraggable'; @@ -7,7 +7,7 @@ import draggable from 'vuedraggable/src/vuedraggable'; import '@simonwep/pickr/dist/themes/classic.min.css'; window.axios = axios; -window.Vue = { createApp, ref, reactive, watch }; +window.Vue = { createApp, ref, reactive, watch, computed }; window.VueDraggable = draggable; // Initialize dark mode theme from main app settings @@ -52,24 +52,48 @@ document.addEventListener('DOMContentLoaded', function () { createApp({ setup() { const isCollapsed = ref(true); + const isManageDropdownCollapsed = ref(true); const isUserDropdownCollapsed = ref(true); window.addEventListener('click', event => { const ignore = ['navbar-toggler', 'navbar-toggler-icon', 'dropdown-toggle']; if (ignore.some(className => event.target.classList.contains(className))) return; if (!isCollapsed.value) isCollapsed.value = true; + if (!isManageDropdownCollapsed.value) isManageDropdownCollapsed.value = true; if (!isUserDropdownCollapsed.value) isUserDropdownCollapsed.value = true; }); return { isCollapsed, + isManageDropdownCollapsed, isUserDropdownCollapsed, }; } }).mount('.v-navbar'); - function findModal(key) - { + const pendingApprovalElement = document.getElementById('pending-approval'); + if (pendingApprovalElement) { + createApp({ + setup() { + const allIds = JSON.parse(pendingApprovalElement.dataset.allIds || '[]'); + const selectedIds = ref([]); + + const selectAll = computed({ + get: () => allIds.length > 0 && selectedIds.value.length === allIds.length, + set: (val) => { + selectedIds.value = val ? [...allIds] : []; + } + }); + + return { + selectedIds, + selectAll + }; + } + }).mount(pendingApprovalElement); + } + + function findModal(key) { const modal = document.querySelector(`[data-modal=${key}]`); if (!modal) throw `Attempted to open modal '${key}' but no such modal found.`; @@ -77,48 +101,46 @@ document.addEventListener('DOMContentLoaded', function () { return modal; } - function openModal(modal) - { - setTimeout(function() - { + function openModal(modal) { + setTimeout(function () { modal.classList.remove('hidden'); modal.classList.add('flex'); }, 200); } - document.querySelectorAll('[data-open-modal]').forEach(item => - { - item.addEventListener('click', event => - { + function closeModal(modal) { + setTimeout(function () { + modal.classList.remove('flex'); + modal.classList.add('hidden'); + }, 200); + } + + document.addEventListener('click', event => { + const openTrigger = event.target.closest('[data-open-modal]'); + if (openTrigger) { event.preventDefault(); + openModal(findModal(openTrigger.dataset.openModal)); + return; + } - openModal(findModal(event.currentTarget.dataset.openModal)); - }); - }); - - document.querySelectorAll('[data-close-modal]').forEach(modalClose => - { - modalClose.addEventListener('click', event => - { + const closeTrigger = event.target.closest('[data-close-modal]'); + if (closeTrigger) { event.preventDefault(); + const modal = closeTrigger.closest('[data-modal]'); + if (modal) closeModal(modal); + return; + } - setTimeout(function() - { - modalClose.closest('[data-modal]').classList.remove('flex'); - modalClose.closest('[data-modal]').classList.add('hidden'); - }, 200); - }); - }); - - document.querySelectorAll('[data-dismiss]').forEach(item => - { - item.addEventListener('click', event => event.currentTarget.parentElement.style.display = 'none'); + const dismissTrigger = event.target.closest('[data-dismiss]'); + if (dismissTrigger) { + const target = dismissTrigger.parentElement; + if (target) target.style.display = 'none'; + } }); const hash = window.location.hash.substr(1); - if (hash.startsWith('modal=')) - { - openModal(findModal(hash.replace('modal=',''))); + if (hash.startsWith('modal=')) { + openModal(findModal(hash.replace('modal=', ''))); } feather.replace(); diff --git a/resources/forum/blade-tailwind/views/category/manage.blade.php b/resources/forum/blade-tailwind/views/category/manage.blade.php index e420e86ca..30a31176a 100644 --- a/resources/forum/blade-tailwind/views/category/manage.blade.php +++ b/resources/forum/blade-tailwind/views/category/manage.blade.php @@ -13,21 +13,25 @@ @endcan -
{{ trans('forum::categories.none') }}
+ @else +