Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
1604c764
Commit
1604c764
authored
May 12, 2017
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Build tree object from endpoint response
parent
fa6d7094
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
82 additions
and
30 deletions
+82
-30
app/assets/javascripts/filterable_list.js
app/assets/javascripts/filterable_list.js
+2
-2
app/assets/javascripts/groups/components/group_folder.vue
app/assets/javascripts/groups/components/group_folder.vue
+1
-1
app/assets/javascripts/groups/components/group_item.vue
app/assets/javascripts/groups/components/group_item.vue
+8
-9
app/assets/javascripts/groups/components/groups.vue
app/assets/javascripts/groups/components/groups.vue
+1
-1
app/assets/javascripts/groups/groups_filterable_list.js
app/assets/javascripts/groups/groups_filterable_list.js
+0
-1
app/assets/javascripts/groups/index.js
app/assets/javascripts/groups/index.js
+12
-7
app/assets/javascripts/groups/services/groups_service.js
app/assets/javascripts/groups/services/groups_service.js
+10
-2
app/assets/javascripts/groups/stores/groups_store.js
app/assets/javascripts/groups/stores/groups_store.js
+42
-7
app/assets/stylesheets/pages/groups.scss
app/assets/stylesheets/pages/groups.scss
+6
-0
No files found.
app/assets/javascripts/filterable_list.js
View file @
1604c764
...
...
@@ -30,8 +30,8 @@ export default class FilterableList {
}
filterResults
(
url
,
data
)
{
const
endpoint
=
url
||
this
.
filterForm
.
getAttribute
(
'
action
'
);
const
additionalData
=
data
||
$
(
this
.
filterForm
).
serialize
();
const
endpoint
=
url
||
this
.
filterForm
.
getAttribute
(
'
action
'
);
const
additionalData
=
data
||
$
(
this
.
filterForm
).
serialize
();
$
(
this
.
listHolderElement
).
fadeTo
(
250
,
0.5
);
...
...
app/assets/javascripts/groups/components/group_folder.vue
View file @
1604c764
...
...
@@ -2,7 +2,7 @@
export
default
{
props
:
{
groups
:
{
type
:
Array
,
type
:
Object
,
required
:
true
,
},
},
...
...
app/assets/javascripts/groups/components/group_item.vue
View file @
1604c764
...
...
@@ -10,10 +10,6 @@ export default {
},
methods
:
{
toggleSubGroups
()
{
if
(
!
this
.
group
.
hasSubgroups
)
{
return
;
}
eventHub
.
$emit
(
'
toggleSubGroups
'
,
this
.
group
);
},
},
...
...
@@ -21,8 +17,11 @@ export default {
</
script
>
<
template
>
<li
@
click=
"toggleSubGroups"
class=
"list-group-item"
>
<span
v-show=
"group.hasSubgroups"
>
<li
@
click=
"toggleSubGroups"
class=
"list-group-item"
:id=
"group.id"
>
<span
v-show=
"group.expandable"
>
<i
v-show=
"group.isOpen"
class=
"fa fa-caret-down"
...
...
@@ -33,9 +32,9 @@ export default {
aria-hidden=
"true"
/>
</span>
<
p><a
:href=
"group.webUrl"
>
{{
group
.
fullName
}}
</a></p
>
<
p>
{{
group
.
description
}}
</p
>
<
code>
{{
group
.
id
}}
</code>
-
<code
v-show=
"group.isOrphan"
>
Orphan
</code>
<a
:href=
"group.webUrl"
>
{{
group
.
fullName
}}
</a></span
>
<
span>
{{
group
.
description
}}
</span
>
<group-folder
v-if=
"group.
subGroups && group.
isOpen"
:groups=
"group.subGroups"
/>
<group-folder
v-if=
"group.isOpen"
:groups=
"group.subGroups"
/>
</li>
</
template
>
app/assets/javascripts/groups/components/groups.vue
View file @
1604c764
...
...
@@ -2,7 +2,7 @@
export
default
{
props
:
{
groups
:
{
type
:
Array
,
type
:
Object
,
required
:
true
,
},
},
...
...
app/assets/javascripts/groups/groups_filterable_list.js
View file @
1604c764
import
FilterableList
from
'
~/filterable_list
'
;
export
default
class
GroupFilterableList
extends
FilterableList
{
constructor
(
form
,
filter
,
holder
,
store
)
{
super
(
form
,
filter
,
holder
);
...
...
app/assets/javascripts/groups/index.js
View file @
1604c764
...
...
@@ -31,19 +31,24 @@ $(() => {
};
},
methods
:
{
fetchGroups
()
{
service
.
getGroups
()
fetchGroups
(
parentGroup
)
{
let
parentId
=
null
;
if
(
parentGroup
)
{
parentId
=
parentGroup
.
id
;
}
service
.
getGroups
(
parentId
)
.
then
((
response
)
=>
{
store
.
setGroups
(
response
.
json
());
store
.
setGroups
(
response
.
json
()
,
parentGroup
);
})
.
catch
(()
=>
{
// TODO: Handler error
});
},
toggleSubGroups
(
group
)
{
GroupsStore
.
toggleSubGroups
(
group
);
this
.
fetchGroups
();
toggleSubGroups
(
parentGroup
=
null
)
{
GroupsStore
.
toggleSubGroups
(
parentGroup
);
this
.
fetchGroups
(
parentGroup
);
},
},
created
()
{
...
...
app/assets/javascripts/groups/services/groups_service.js
View file @
1604c764
...
...
@@ -8,7 +8,15 @@ export default class GroupsService {
this
.
groups
=
Vue
.
resource
(
endpoint
);
}
getGroups
()
{
return
this
.
groups
.
get
();
getGroups
(
parentId
)
{
let
data
=
{};
if
(
parentId
)
{
data
=
{
parent_id
:
parentId
,
};
}
return
this
.
groups
.
get
(
data
);
}
}
app/assets/javascripts/groups/stores/groups_store.js
View file @
1604c764
export
default
class
GroupsStore
{
constructor
()
{
this
.
state
=
{};
this
.
state
.
groups
=
[]
;
this
.
state
.
groups
=
{}
;
return
this
;
}
setGroups
(
groups
)
{
this
.
state
.
groups
=
this
.
decorateGroups
(
groups
)
;
setGroups
(
rawGroups
,
parent
=
null
)
{
const
parentGroup
=
parent
;
return
groups
;
if
(
parentGroup
)
{
parentGroup
.
subGroups
=
this
.
buildTree
(
rawGroups
);
}
else
{
this
.
state
.
groups
=
this
.
buildTree
(
rawGroups
);
}
return
rawGroups
;
}
buildTree
(
rawGroups
)
{
const
groups
=
this
.
decorateGroups
(
rawGroups
);
const
tree
=
{};
const
mappedGroups
=
{};
// Map groups to an object
for
(
let
i
=
0
,
len
=
groups
.
length
;
i
<
len
;
i
+=
1
)
{
const
group
=
groups
[
i
];
mappedGroups
[
group
.
id
]
=
group
;
mappedGroups
[
group
.
id
].
subGroups
=
{};
}
Object
.
keys
(
mappedGroups
).
forEach
((
key
)
=>
{
const
currentGroup
=
mappedGroups
[
key
];
// If the group is not at the root level, add it to its parent array of subGroups.
if
(
currentGroup
.
parentId
)
{
mappedGroups
[
currentGroup
.
parentId
].
subGroups
[
currentGroup
.
id
]
=
currentGroup
;
mappedGroups
[
currentGroup
.
parentId
].
isOpen
=
true
;
// Expand group if it has subgroups
}
else
{
// If the group is at the root level, add it to first level elements array.
tree
[
currentGroup
.
id
]
=
currentGroup
;
}
});
return
tree
;
}
decorateGroups
(
rawGroups
)
{
...
...
@@ -19,12 +52,14 @@ export default class GroupsStore {
static
decorateGroup
(
rawGroup
)
{
return
{
fullName
:
rawGroup
.
name
,
id
:
rawGroup
.
id
,
fullName
:
rawGroup
.
full_name
,
description
:
rawGroup
.
description
,
webUrl
:
rawGroup
.
web_url
,
parentId
:
rawGroup
.
parent
I
d
,
hasSubgroups
:
!!
rawGroup
.
parent_id
,
parentId
:
rawGroup
.
parent
_i
d
,
expandable
:
true
,
isOpen
:
false
,
subGroups
:
{},
};
}
...
...
app/assets/stylesheets/pages/groups.scss
View file @
1604c764
...
...
@@ -111,3 +111,9 @@
height
:
50px
;
}
}
.list-group
.list-group
{
margin-top
:
10px
;
margin-bottom
:
0
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment