Add wish priorities filter
This commit is contained in:
parent
4b849e0ab0
commit
e518afb99c
5 changed files with 124 additions and 3 deletions
|
@ -62,6 +62,10 @@ $(function () {
|
|||
.then(handleFetchResponse)
|
||||
.then(function(response) {
|
||||
window.history.pushState({}, '', response.data.url);
|
||||
|
||||
$('.ui.dropdown.filter.priority')
|
||||
.dropdown('restore default value')
|
||||
.dropdown('restore default text');
|
||||
});
|
||||
} else {
|
||||
$('.button.wishlist-wish-add').addClass('disabled');
|
||||
|
@ -436,4 +440,42 @@ $(function () {
|
|||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Filter wishes
|
||||
*/
|
||||
$('.ui.dropdown.filter.priority')
|
||||
.dropdown({
|
||||
match : 'text',
|
||||
fullTextSearch : true,
|
||||
onChange : function() {
|
||||
$(this).addClass('disabled loading');
|
||||
|
||||
var wishlist_id = $('.dropdown.wishlists').dropdown('get value');
|
||||
|
||||
if (!Number.isInteger(parseInt(wishlist_id))) {
|
||||
$(this).removeClass('disabled loading');
|
||||
return false;
|
||||
}
|
||||
|
||||
var paramater = new URLSearchParams({
|
||||
wishlist : wishlist_id,
|
||||
priority : $(this).dropdown('get value'),
|
||||
});
|
||||
|
||||
fetch('/src/api/wishlists.php?' + paramater, {
|
||||
method : 'GET',
|
||||
})
|
||||
.then(handleFetchError)
|
||||
.then(handleFetchResponse)
|
||||
.then(function(response) {
|
||||
var html = response.results ? response.results : '';
|
||||
|
||||
$('.wishlist-cards').html(html);
|
||||
})
|
||||
.finally(() => {
|
||||
$(this).removeClass('disabled loading');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue