useNavigationHelpers.ts 649 B

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