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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
9803579e
Commit
9803579e
authored
7 years ago
by
Filipa Lacerda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent default click since we change the url manually
Adds tests
parent
87d90b5b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
6 deletions
+41
-6
app/assets/javascripts/vue_shared/components/table_pagination.vue
...ts/javascripts/vue_shared/components/table_pagination.vue
+4
-0
changelogs/unreleased/34810-vue-pagination.yml
changelogs/unreleased/34810-vue-pagination.yml
+4
-0
spec/javascripts/vue_shared/components/table_pagination_spec.js
...avascripts/vue_shared/components/table_pagination_spec.js
+33
-6
No files found.
app/assets/javascripts/vue_shared/components/table_pagination.vue
View file @
9803579e
...
@@ -46,6 +46,10 @@ export default {
...
@@ -46,6 +46,10 @@ export default {
},
},
methods
:
{
methods
:
{
changePage
(
e
)
{
changePage
(
e
)
{
e
.
preventDefault
();
if
(
e
.
target
.
parentElement
.
classList
.
contains
(
'
disabled
'
))
return
;
const
text
=
e
.
target
.
innerText
;
const
text
=
e
.
target
.
innerText
;
const
{
totalPages
,
nextPage
,
previousPage
}
=
this
.
pageInfo
;
const
{
totalPages
,
nextPage
,
previousPage
}
=
this
.
pageInfo
;
...
...
This diff is collapsed.
Click to expand it.
changelogs/unreleased/34810-vue-pagination.yml
0 → 100644
View file @
9803579e
---
title
:
Prevent disabled pagination button to be clicked
merge_request
:
author
:
This diff is collapsed.
Click to expand it.
spec/javascripts/vue_shared/components/table_pagination_spec.js
View file @
9803579e
...
@@ -105,21 +105,48 @@ describe('Pagination component', () => {
...
@@ -105,21 +105,48 @@ describe('Pagination component', () => {
expect
(
changeChanges
.
one
).
toEqual
(
1
);
expect
(
changeChanges
.
one
).
toEqual
(
1
);
});
});
it
(
'
should do nothing
'
,
()
=>
{
it
(
'
should not call change callback if clicked link is disabled
'
,
()
=>
{
const
spy
=
jasmine
.
createSpy
(
'
spy
'
);
component
=
new
PaginationComponent
({
component
=
new
PaginationComponent
({
propsData
:
{
propsData
:
{
pageInfo
:
{
pageInfo
:
{
totalPages
:
10
,
nextPage
:
2
,
nextPage
:
2
,
previousPage
:
''
,
page
:
1
,
perPage
:
20
,
previousPage
:
NaN
,
total
:
84
,
totalPages
:
5
,
},
},
change
,
change
:
spy
,
},
},
}).
$mount
();
}).
$mount
();
component
.
changePage
({
target
:
{
innerText
:
'
...
'
}
}
);
component
.
$el
.
querySelector
(
'
a
'
).
click
(
);
expect
(
changeChanges
.
one
).
toEqual
(
1
);
expect
(
spy
).
not
.
toHaveBeenCalled
();
});
it
(
'
should call change callback when link is clicked
'
,
()
=>
{
const
spy
=
jasmine
.
createSpy
(
'
spy
'
);
component
=
new
PaginationComponent
({
propsData
:
{
pageInfo
:
{
nextPage
:
3
,
page
:
2
,
perPage
:
20
,
previousPage
:
1
,
total
:
84
,
totalPages
:
5
,
},
change
:
spy
,
},
}).
$mount
();
component
.
$el
.
querySelector
(
'
a
'
).
click
();
expect
(
spy
).
toHaveBeenCalled
();
});
});
});
});
...
...
This diff is collapsed.
Click to expand it.
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