Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<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.id)" v-if="!group.active">{{group.name}}</a>
<span v-if="group.active">{{group.name}}</span>
</li>
</ol>
</nav>
</template>
<script>
function buildItems(values) {
let groups = [];
groups.push({
name: 'Root',
id: null,
active: false
});
for(let i = 0; i < values.length; i++) {
let group = values[i];
group.active = false;
groups.push(group);
}
// Activate the last item
groups[groups.length - 1].active = true;
return groups;
}
export default {
name: 'GroupsBreadcrumb',
props: {
values: Array
},
data() {
return {
groups: buildItems(this.values)
};
},
methods: {
changeBreadcrumb: function(groupId) {
console.log('changeBreadcrumb', groupId);
}
}
}
</script>
<style scoped>
nav {
margin-top: 10px;
}
</style>