Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Frontend
Commits
a9d89587
Commit
a9d89587
authored
3 years ago
by
Erwan Rouchet
Committed by
Bastien Abadie
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fetch children when switching to an element already loaded in the store
parent
4eeec011
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1054
Fetch children when switching to an element already loaded in the store
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
vue/Navigation/ChildrenTree/TreeItem.vue
+18
-4
18 additions, 4 deletions
vue/Navigation/ChildrenTree/TreeItem.vue
with
18 additions
and
4 deletions
vue/Navigation/ChildrenTree/TreeItem.vue
+
18
−
4
View file @
a9d89587
...
...
@@ -111,10 +111,6 @@ export default {
data
:
()
=>
({
loading
:
false
}),
mounted
()
{
// Automatically fetch tree parent children
if
(
this
.
isParent
)
this
.
fetchChildren
()
},
computed
:
{
...
mapState
(
'
display
'
,
[
'
imageEdit
'
,
'
editionMode
'
]),
...
mapState
(
'
elements
'
,
[
...
...
@@ -270,9 +266,27 @@ export default {
}
},
watch
:
{
element
:
{
immediate
:
true
,
handler
(
newValue
,
oldValue
)
{
/*
* Automatically load all children if this TreeItem is the parent node of the tree.
* This is done as a watcher and not just in mounted as it is possible that the element changes without
* unmounting the component if the user switches between neighbors and the element is already in the store,
* for example when going back and forth between two elements multiple times,
* or when the element is in the selection or was in a navigation list.
*/
if
(
oldValue
?.
id
===
newValue
.
id
||
!
this
.
isParent
)
return
this
.
fetchChildren
()
}
},
selectedElement
:
{
immediate
:
true
,
handler
(
newValue
,
oldValue
)
{
/*
* Open every TreeItem all the way down to a highlighted element.
* This uses the fact that the highlighting will load all parents into the `parents` state, and nothing else.
*/
if
(
!
newValue
||
(
oldValue
&&
newValue
===
oldValue
))
return
const
parents
=
this
.
parents
[
newValue
.
id
]
if
(
parents
&&
parents
.
includes
(
this
.
node
.
element
.
id
)
&&
!
this
.
node
.
expanded
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment