Skip to content

Commit

Permalink
fix: adding hidden class logic (#113)
Browse files Browse the repository at this point in the history
* fix: adding hidden class logic

* fix: expand/collapse all logic
  • Loading branch information
vb-oiko authored Dec 19, 2020
1 parent 92177d5 commit a924eab
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions src/components/Test.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ export default {
activeTab: 'testrun',
command: undefined,
showNextStep: false,
isOpened: false,
};
},
methods: {
humanize(ts) {
return moment.unix(ts / 1000).fromNow();
Expand All @@ -145,14 +145,13 @@ export default {
this.activeTab = tabname;
},
toggleAll() {
async toggleAll() {
this.$store.commit('testRunPage/toggleSubsteps');
this.isOpened = this.$store.getters['testRunPage/showSubsteps'];
this.test.steps.filter(s => s.type === 'meta').forEach(s => this.toggleSubsteps(s, this.isOpened));
this.test.steps.filter(s => s.type === 'meta').forEach(s => this.toggleSubsteps(s, !this.isOpened));
this.$forceUpdate();
},
toggleSubsteps(step, isOpened) {
toggleSubsteps(step, force) {
if (step.type !== 'meta') {
step.expanded
? this.$store.commit('testRunPage/setHoveredStep', step)
Expand All @@ -161,20 +160,19 @@ export default {
}
if (!step.opens) return true;
this.$set(step, 'opened', !step.opened);
this.$set(step, 'expanded', !step.expanded);
for (const section in this.$refs) {
if (section.startsWith(step.opens)) {
const els = this.$refs[section];
if (typeof isOpened === 'boolean') {
if (!step.opened) els.forEach(el => el.classList.add('hidden'));
if (step.opened) els.forEach(el => el.classList.remove('hidden'));
return;
}
if (!step.opened) els.forEach(el => el.classList.add('hidden'));
if (step.opened) els.forEach(el => el.classList.remove('hidden'));
}
if(typeof force === 'boolean'){
this.$set(step, 'opened', force);
this.$set(step, 'expanded', force);
this.$refs[step.opens].forEach(el=>{
el.classList.toggle('hidden', force);
});
} else {
this.$set(step, 'opened', !step.opened);
this.$set(step, 'expanded', !step.expanded);
this.$refs[step.opens].forEach(el=>{
el.classList.toggle('hidden');
});
}
},
},
Expand All @@ -187,7 +185,10 @@ export default {
},
selectedStep() {
return this.$store.getters['testRunPage/selectedStep'];
}
},
isOpened() {
return this.$store.getters['testRunPage/showSubsteps'];
},
}
};
</script>
Expand Down

0 comments on commit a924eab

Please sign in to comment.