<template>
    <v-breadcrumbs large divider="&gt;" :items="breadcrumbs"></v-breadcrumbs>
</template>

<script>
  export default {
    name: 'BreadcrumbComponent',
    data () {
      return {
        breadcrumbs: []
      }
    },
    created () {
      this.updateList()
    },
    mounted () {
      this.updateList()
    },
    watch: {
      '$route' () {
        this.updateList()
      }
    },
    methods: {
      updateList () {
        let self = this
        const decline = ['AppIndexView', 'Vzdelávanie'];
        self.breadcrumbs = []

        this.$route.matched.forEach((route) => {
          if (decline.includes(route.name)) return

          self.breadcrumbs.push({
            text: route.name,
            href: self.$router.resolve({
              name: route.name,
              params: null
            }).href,
            disabled: (self.$route.name === route.name)
          })
        })
      }
    }
  }
</script>

<style scoped>

</style>