Skip to content

Commit a6aacb7

Browse files
author
Dobromir Hristov
committed
feat: track open event on technology card
1 parent 1261019 commit a6aacb7

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

src/components/Navigator.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:key="technology.path"
77
:technology="technology"
88
:active-path="activePath"
9+
@open="handleOpenOnCard"
910
/>
1011
</div>
1112
</template>
@@ -72,6 +73,10 @@ export default {
7273
debounceInput: debounce(function debounceInput({ target: { value } }) {
7374
this.filter = value;
7475
}, 500),
76+
// TODO: Add logic to fetch children async
77+
handleOpenOnCard(paths) {
78+
console.log(paths);
79+
},
7580
},
7681
};
7782
</script>

src/components/Navigator/NavigatorCard.vue

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
v-if="isOpen"
1818
:children="childrenFiltered"
1919
:nesting-index="3"
20-
:active-path="activePathRest"
20+
:active-path="activePathMinusFirst"
2121
/>
2222
</TransitionExpand>
2323
</div>
@@ -48,26 +48,21 @@ export default {
4848
};
4949
},
5050
computed: {
51-
activePathRest() {
52-
if (this.isCurrentPage) {
53-
return this.activePath.slice(1);
54-
}
55-
return this.activePath;
56-
},
51+
activePathMinusFirst: ({ activePath }) => activePath.slice(1),
52+
// TODO: move this to the backend
5753
childrenFiltered({ technology }) {
5854
return technology.children.filter(child => child.kind !== 'groupMarker');
5955
},
6056
isCurrentPage({ activePath, technology }) {
61-
return activePath[0] === technology.path;
57+
return activePath.length === 1 && activePath[0] === technology.path;
6258
},
6359
},
6460
methods: {
6561
toggleCard() {
6662
this.isOpen = !this.isOpen;
67-
this.emitOpenEvent(this.technology.path);
68-
},
69-
emitOpenEvent(path) {
70-
this.$emit('open', path);
63+
if (this.isOpen) {
64+
this.$emit('open', this.technology.path);
65+
}
7166
},
7267
},
7368
};

src/components/Navigator/NavigatorTreeLeaf.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
v-if="expanded && childrenFiltered.length"
2323
:children="childrenFiltered"
2424
:nesting-index="nestingIndex + 1"
25-
:active-path="activePathRest"
25+
:active-path="activePathMinusFirst"
2626
/>
2727
</TransitionExpand>
2828
</li>
@@ -66,9 +66,7 @@ export default {
6666
isActive({ item, activePath }) {
6767
return activePath.length === 1 && item.path === activePath[0];
6868
},
69-
activePathRest() {
70-
return this.activePath.slice(1);
71-
},
69+
activePathMinusFirst: ({ activePath }) => activePath.slice(1),
7270
// TODO: move this to the backend
7371
childrenFiltered({ item }) {
7472
return item.children ? item.children.filter(child => child.kind !== 'groupMarker') : [];

0 commit comments

Comments
 (0)