useNavigationHelpers.ts 783 B

1234567891011121314151617181920212223242526272829
  1. import { onMounted, ref, useContext, Ref } from '@nuxtjs/composition-api'
  2. import * as _ from 'lodash'
  3. /**
  4. * @category composables/form
  5. * @class UseNavigationHelpers
  6. * Use Classe pour gérer les expansions des accordions
  7. */
  8. export class UseNavigationHelpers {
  9. public static expansionPanels () {
  10. const { route } = useContext()
  11. const panel: Ref<number> = ref(0)
  12. const activeAccordionId = route.value.query.accordion
  13. onMounted(() => {
  14. setTimeout(function () {
  15. _.each(document.getElementsByClassName('v-expansion-panel'), (element, index) => {
  16. if (element.id == activeAccordionId) {
  17. panel.value = index
  18. }
  19. })
  20. if (!panel.value) { panel.value = 0 }
  21. }, 0)
  22. })
  23. return {
  24. panel
  25. }
  26. }
  27. }