Skip to content
GroupsBreadcrumb.vue 1.38 KiB
Newer Older
<template>
<nav aria-label="breadcrumb">
  <ol class="breadcrumb">
    <li class="breadcrumb-item" v-for="group in groups" v-bind:class="{ active: group.active }">
      <a href="#" v-on:click="changeBreadcrumb(group.groupId)" v-if="!group.active">{{group.groupName}}</a>
      <span v-if="group.active">{{group.groupName}}</span>
    </li>
  </ol>
</nav>
</template>

<script>
import {
  mapState
} from 'vuex';
function buildItems(values) {
  let groups = [];
  for (let i = 0; i < values.length; i++) {
    let group = values[i];
    group.active = false;
    groups.push(group);
  }
  // Activate the last item
  if (groups.length > 0) {
    groups[groups.length - 1].active = true;
  }
export default {
  name: 'GroupsBreadcrumb',
  computed: mapState({
    model: state => state.model,
    groups: state => buildItems(state.model.breadcrumbs)
  }),
  methods: {
    changeBreadcrumb: function(groupId) {
      this.input.selectedGroupId = groupId;
      this.input.searchFilter = null;
      if (this.input.selectedTab === 'groups') {
        client.fetchGroupsTab(this.input)
            this.$store.commit('updateGroups', model);
          });
      } else {
        this.$store.commit('setTabIndex', 0);
      }
</script>

<style scoped>
nav {
  margin-top: 10px;
}
</style>