Newer
Older
<nav aria-label="breadcrumb" id="groups-breadcrumbs">
Sonia Zorba
committed
<li class="breadcrumb-item" v-for="group in groups" v-bind:class="{ active: group.active }" v-bind:key="group.groupId">
<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>
<a v-if="currentGroup" :href="'group/status?groupId=' + currentGroup.groupId" :download="currentGroup.groupName + '.csv'" id="csv-status-download" title="Download CSV">
<font-awesome-icon icon="download"></font-awesome-icon>
</a>
Sonia Zorba
committed
import { mapState } from 'vuex';
Sonia Zorba
committed
import client from 'api-client';
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
Sonia Zorba
committed
groups[groups.length - 1].active = true;
}
return groups;
}
export default {
name: 'GroupsBreadcrumb',
computed: mapState({
model: state => state.model,
Sonia Zorba
committed
input: state => state.input,
groups: state => buildItems(state.model.breadcrumbs),
isAdmin: state => state.model.permission === 'ADMIN',
currentGroup: state => state.model.breadcrumbs[state.model.breadcrumbs.length - 1]
}),
methods: {
changeBreadcrumb: function(groupId) {
Sonia Zorba
committed
this.input.selectedGroupId = groupId;
Sonia Zorba
committed
.then(model => {
this.$store.commit('updateGroups', model);
Sonia Zorba
committed
});
} else {
Sonia Zorba
committed
this.$store.dispatch('changeTab', 0);
Sonia Zorba
committed
}
position: relative;
}
#csv-status-download {
position: absolute;
right: 18px;
top: 12px;