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
Boxiang Sun
gitlab-ce
Commits
a5a7b574
Commit
a5a7b574
authored
May 22, 2017
by
Alfredo Sumaran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Paginate group results
[ci skip]
parent
a87d447c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
46 additions
and
7 deletions
+46
-7
app/assets/javascripts/groups/components/groups.vue
app/assets/javascripts/groups/components/groups.vue
+20
-0
app/assets/javascripts/groups/index.js
app/assets/javascripts/groups/index.js
+4
-1
app/assets/javascripts/groups/services/groups_service.js
app/assets/javascripts/groups/services/groups_service.js
+7
-5
app/assets/javascripts/groups/stores/groups_store.js
app/assets/javascripts/groups/stores/groups_store.js
+14
-0
app/views/dashboard/groups/_groups.html.haml
app/views/dashboard/groups/_groups.html.haml
+1
-1
No files found.
app/assets/javascripts/groups/components/groups.vue
View file @
a5a7b574
<
script
>
import
TablePaginationComponent
from
'
~/vue_shared/components/table_pagination
'
;
export
default
{
components
:
{
'
gl-pagination
'
:
TablePaginationComponent
,
},
props
:
{
groups
:
{
type
:
Array
,
required
:
true
,
},
pageInfo
:
{
type
:
Object
,
required
:
true
,
},
},
methods
:
{
change
(
pageNumber
)
{
const
param
=
gl
.
utils
.
setParamInURL
(
'
page
'
,
pageNumber
);
gl
.
utils
.
visitUrl
(
param
);
return
param
;
},
},
};
</
script
>
...
...
@@ -12,5 +29,8 @@ export default {
<
template
>
<div>
<group-folder
:groups=
"groups"
/>
<gl-pagination
:change=
"change"
:pageInfo=
"pageInfo"
/>
</div>
</
template
>
app/assets/javascripts/groups/index.js
View file @
a5a7b574
...
...
@@ -38,9 +38,12 @@ $(() => {
parentId
=
parentGroup
.
id
;
}
service
.
getGroups
(
parentId
)
const
page
=
gl
.
utils
.
getParameterByName
(
'
page
'
);
service
.
getGroups
(
parentId
,
page
)
.
then
((
response
)
=>
{
store
.
setGroups
(
response
.
json
(),
parentGroup
);
store
.
storePagination
(
response
.
headers
);
})
.
catch
(()
=>
{
// TODO: Handler error
...
...
app/assets/javascripts/groups/services/groups_service.js
View file @
a5a7b574
...
...
@@ -8,13 +8,15 @@ export default class GroupsService {
this
.
groups
=
Vue
.
resource
(
endpoint
);
}
getGroups
(
parentId
)
{
le
t
data
=
{};
getGroups
(
parentId
,
page
=
1
)
{
cons
t
data
=
{};
if
(
parentId
)
{
data
=
{
parent_id
:
parentId
,
};
data
.
parent_id
=
parentId
;
}
if
(
page
)
{
data
.
page
=
page
;
}
return
this
.
groups
.
get
(
data
);
...
...
app/assets/javascripts/groups/stores/groups_store.js
View file @
a5a7b574
...
...
@@ -2,6 +2,7 @@ export default class GroupsStore {
constructor
()
{
this
.
state
=
{};
this
.
state
.
groups
=
[];
this
.
state
.
pageInfo
=
{};
return
this
;
}
...
...
@@ -18,6 +19,19 @@ export default class GroupsStore {
return
rawGroups
;
}
storePagination
(
pagination
=
{})
{
let
paginationInfo
;
if
(
Object
.
keys
(
pagination
).
length
)
{
const
normalizedHeaders
=
gl
.
utils
.
normalizeHeaders
(
pagination
);
paginationInfo
=
gl
.
utils
.
parseIntPagination
(
normalizedHeaders
);
}
else
{
paginationInfo
=
pagination
;
}
this
.
state
.
pageInfo
=
paginationInfo
;
}
decorateGroups
(
rawGroups
)
{
this
.
groups
=
rawGroups
.
map
(
GroupsStore
.
decorateGroup
);
return
this
.
groups
;
...
...
app/views/dashboard/groups/_groups.html.haml
View file @
a5a7b574
.js-groups-list-holder
#dashboard-group-app
{
data:
{
endpoint:
dashboard_groups_path
(
format: :json
)
}
}
%groups-component
{
':groups'
=>
'state.groups'
}
%groups-component
{
':groups'
=>
'state.groups'
,
':page-info'
=>
'state.pageInfo'
}
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