Skip to content

Toggle component tree recursively with alt key pressed #265

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/devtools/views/components/ComponentInstance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<!-- arrow wrapper for better hit box -->
<span class="arrow-wrapper"
v-if="instance.children.length"
@click.stop="toggle()">
@click.stop="toggle">
<span class="arrow right" :class="{ rotated: expanded }">
</span>
</span>
Expand Down Expand Up @@ -71,19 +71,20 @@ export default {
}
},
methods: {
toggle () {
this.toggleWithValue(!this.expanded)
toggle (event) {
this.toggleWithValue(!this.expanded, event.altKey)
},
expand () {
this.toggleWithValue(true)
},
collapse () {
this.toggleWithValue(false)
},
toggleWithValue (val) {
this.$store.commit('components/TOGGLE_INSTANCE', {
id: this.instance.id,
expanded: val
toggleWithValue (val, recursive = false) {
this.$store.dispatch('components/toggleInstance', {
instance: this.instance,
expanded: val,
recursive
})
},
select () {
Expand Down
19 changes: 18 additions & 1 deletion src/devtools/views/components/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,25 @@ const mutations = {
}
}

const actions = {
toggleInstance ({commit, dispatch}, {instance, expanded, recursive}) {
commit('TOGGLE_INSTANCE', {id: instance.id, expanded})

if (recursive) {
instance.children.forEach((child) => {
dispatch('toggleInstance', {
instance: child,
expanded,
recursive
})
})
}
}
}

export default {
namespaced: true,
state,
mutations
mutations,
actions
}