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
b3c9d965
Commit
b3c9d965
authored
Jan 26, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Converted filterable_list to axios
parent
3bb08565
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
25 deletions
+20
-25
app/assets/javascripts/filterable_list.js
app/assets/javascripts/filterable_list.js
+12
-17
app/assets/javascripts/groups/groups_filterable_list.js
app/assets/javascripts/groups/groups_filterable_list.js
+8
-8
No files found.
app/assets/javascripts/filterable_list.js
View file @
b3c9d965
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
axios
from
'
./lib/utils/axios_utils
'
;
/**
/**
* Makes search request for content when user types a value in the search input.
* Makes search request for content when user types a value in the search input.
...
@@ -54,32 +55,26 @@ export default class FilterableList {
...
@@ -54,32 +55,26 @@ export default class FilterableList {
this
.
listFilterElement
.
removeEventListener
(
'
input
'
,
this
.
debounceFilter
);
this
.
listFilterElement
.
removeEventListener
(
'
input
'
,
this
.
debounceFilter
);
}
}
filterResults
(
queryData
)
{
filterResults
(
params
)
{
if
(
this
.
isBusy
)
{
if
(
this
.
isBusy
)
{
return
false
;
return
false
;
}
}
$
(
this
.
listHolderElement
).
fadeTo
(
250
,
0.5
);
$
(
this
.
listHolderElement
).
fadeTo
(
250
,
0.5
);
return
$
.
ajax
({
this
.
isBusy
=
true
;
url
:
this
.
getFilterEndpoint
(),
data
:
queryData
,
return
axios
.
get
(
this
.
getFilterEndpoint
(),
{
type
:
'
GET
'
,
params
,
dataType
:
'
json
'
,
}).
then
((
res
)
=>
{
context
:
this
,
this
.
onFilterSuccess
(
res
,
params
);
complete
:
this
.
onFilterComplete
,
this
.
onFilterComplete
();
beforeSend
:
()
=>
{
}).
catch
(()
=>
this
.
onFilterComplete
());
this
.
isBusy
=
true
;
},
success
:
(
response
,
textStatus
,
xhr
)
=>
{
this
.
onFilterSuccess
(
response
,
xhr
,
queryData
);
},
});
}
}
onFilterSuccess
(
response
,
xhr
,
queryData
)
{
onFilterSuccess
(
response
,
queryData
)
{
if
(
response
.
html
)
{
if
(
response
.
html
)
{
this
.
listHolderElement
.
innerHTML
=
response
.
html
;
this
.
listHolderElement
.
innerHTML
=
response
.
data
.
html
;
}
}
// Change url so if user reload a page - search results are saved
// Change url so if user reload a page - search results are saved
...
...
app/assets/javascripts/groups/groups_filterable_list.js
View file @
b3c9d965
...
@@ -94,23 +94,23 @@ export default class GroupFilterableList extends FilterableList {
...
@@ -94,23 +94,23 @@ export default class GroupFilterableList extends FilterableList {
this
.
form
.
querySelector
(
`[name="
${
this
.
filterInputField
}
"]`
).
value
=
''
;
this
.
form
.
querySelector
(
`[name="
${
this
.
filterInputField
}
"]`
).
value
=
''
;
}
}
onFilterSuccess
(
data
,
xhr
,
queryData
)
{
onFilterSuccess
(
res
,
queryData
)
{
const
currentPath
=
this
.
getPagePath
(
queryData
);
const
currentPath
=
this
.
getPagePath
(
queryData
);
const
paginationData
=
{
const
paginationData
=
{
'
X-Per-Page
'
:
xhr
.
getResponseHeader
(
'
X-Per-Page
'
)
,
'
X-Per-Page
'
:
res
.
headers
[
'
x-per-page
'
]
,
'
X-Page
'
:
xhr
.
getResponseHeader
(
'
X-Page
'
)
,
'
X-Page
'
:
res
.
headers
[
'
x-page
'
]
,
'
X-Total
'
:
xhr
.
getResponseHeader
(
'
X-Total
'
)
,
'
X-Total
'
:
res
.
headers
[
'
x-total
'
]
,
'
X-Total-Pages
'
:
xhr
.
getResponseHeader
(
'
X-Total-Pages
'
)
,
'
X-Total-Pages
'
:
res
.
headers
[
'
x-total-pages
'
]
,
'
X-Next-Page
'
:
xhr
.
getResponseHeader
(
'
X-Next-Page
'
)
,
'
X-Next-Page
'
:
res
.
headers
[
'
x-next-page
'
]
,
'
X-Prev-Page
'
:
xhr
.
getResponseHeader
(
'
X-Prev-Page
'
)
,
'
X-Prev-Page
'
:
res
.
headers
[
'
x-prev-page
'
]
,
};
};
window
.
history
.
replaceState
({
window
.
history
.
replaceState
({
page
:
currentPath
,
page
:
currentPath
,
},
document
.
title
,
currentPath
);
},
document
.
title
,
currentPath
);
eventHub
.
$emit
(
'
updateGroups
'
,
data
,
Object
.
prototype
.
hasOwnProperty
.
call
(
queryData
,
this
.
filterInputField
));
eventHub
.
$emit
(
'
updateGroups
'
,
res
.
data
,
Object
.
prototype
.
hasOwnProperty
.
call
(
queryData
,
this
.
filterInputField
));
eventHub
.
$emit
(
'
updatePagination
'
,
paginationData
);
eventHub
.
$emit
(
'
updatePagination
'
,
paginationData
);
}
}
}
}
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