mirror of
git://git.yoctoproject.org/layerindex-web.git
synced 2025-07-19 20:59:01 +02:00
rrs/recipes: Add support for persist search and filters.
Now when search something the URL is modified and you can share the URL for access to the data. [YOCTO #7809] Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
This commit is contained in:
parent
aab0a9ad3f
commit
3ccb422aeb
11
rrs/views.py
11
rrs/views.py
|
@ -253,6 +253,15 @@ class RecipeListView(ListView):
|
||||||
else:
|
else:
|
||||||
self.maintainer_name = 'All'
|
self.maintainer_name = 'All'
|
||||||
|
|
||||||
|
if 'search' in self.request.GET.keys():
|
||||||
|
self.search = self.request.GET['search']
|
||||||
|
|
||||||
|
# only allow one type of filter search or upstream_status/maintainer
|
||||||
|
self.upstream_status = 'All'
|
||||||
|
self.maintainer_name = 'All'
|
||||||
|
else:
|
||||||
|
self.search = ''
|
||||||
|
|
||||||
_check_url_params(self.upstream_status, self.maintainer_name)
|
_check_url_params(self.upstream_status, self.maintainer_name)
|
||||||
|
|
||||||
self.milestone_statistics = _get_milestone_statistics(milestone)
|
self.milestone_statistics = _get_milestone_statistics(milestone)
|
||||||
|
@ -309,6 +318,8 @@ class RecipeListView(ListView):
|
||||||
all_maintainers.append(rm['maintainer__name'])
|
all_maintainers.append(rm['maintainer__name'])
|
||||||
context['all_maintainers'] = all_maintainers
|
context['all_maintainers'] = all_maintainers
|
||||||
|
|
||||||
|
context['search'] = self.search
|
||||||
|
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def recipes_report(request, release_name, milestone_name):
|
def recipes_report(request, release_name, milestone_name):
|
||||||
|
|
|
@ -167,6 +167,16 @@ $(document).ready(function() {
|
||||||
recipesTable = $('#recipestable')
|
recipesTable = $('#recipestable')
|
||||||
upstreamStatus = $("<div/>").html('{{ upstream_status }}').text()
|
upstreamStatus = $("<div/>").html('{{ upstream_status }}').text()
|
||||||
maintainer = $("<div/>").html('{{ maintainer_name }}').text()
|
maintainer = $("<div/>").html('{{ maintainer_name }}').text()
|
||||||
|
search = '{{ search }}'
|
||||||
|
|
||||||
|
function updateQueryString(queryString) {
|
||||||
|
if (window.history.pushState) {
|
||||||
|
var newurl = window.location.protocol + "//" +
|
||||||
|
window.location.host + window.location.pathname +
|
||||||
|
queryString
|
||||||
|
window.history.pushState({path:newurl}, '', newurl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function updateRecipeCount() {
|
function updateRecipeCount() {
|
||||||
$('#recipestable').show()
|
$('#recipestable').show()
|
||||||
|
@ -243,21 +253,38 @@ $(document).ready(function() {
|
||||||
|
|
||||||
updateStatusSelected()
|
updateStatusSelected()
|
||||||
updateMaintainerSelected()
|
updateMaintainerSelected()
|
||||||
|
|
||||||
|
queryString = ''
|
||||||
|
if (search != '') {
|
||||||
|
$.uiTableFilter(recipesTable, search);
|
||||||
|
queryString = '?search=' + search
|
||||||
|
} else {
|
||||||
|
if (upstreamStatus != 'All' && maintainer != 'All') {
|
||||||
|
queryString = '?upstream_status=' + upstreamStatus +
|
||||||
|
'&maintainer_name=' + maintainer
|
||||||
|
} else if (upstreamStatus != 'All') {
|
||||||
|
queryString = '?upstream_status=' + upstreamStatus
|
||||||
|
} else if (maintainer != 'All') {
|
||||||
|
queryString = '?maintainer_name=' + maintainer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateQueryString(queryString)
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#form-search").submit(function( event ) {
|
$("#form-search").submit(function( event ) {
|
||||||
upstreamStatus = 'All'
|
upstreamStatus = 'All'
|
||||||
maintainer = 'All'
|
maintainer = 'All'
|
||||||
search_text = $("#filter").val()
|
search = $("#filter").val()
|
||||||
$("#clear-search-btn").show()
|
$("#clear-search-btn").show()
|
||||||
applyFilters()
|
applyFilters()
|
||||||
$.uiTableFilter(recipesTable, search_text);
|
|
||||||
updateRecipeCount()
|
updateRecipeCount()
|
||||||
|
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
});
|
});
|
||||||
|
|
||||||
function clearSearch() {
|
function clearSearch() {
|
||||||
$("#filter").val('')
|
$("#filter").val('')
|
||||||
|
search = $("#filter").val()
|
||||||
$("#clear-search-btn").hide()
|
$("#clear-search-btn").hide()
|
||||||
applyFilters()
|
applyFilters()
|
||||||
updateRecipeCount()
|
updateRecipeCount()
|
||||||
|
@ -299,6 +326,10 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
if (search != '') {
|
||||||
|
$("#filter").val(search)
|
||||||
|
$("#clear-search-btn").show()
|
||||||
|
}
|
||||||
applyFilters()
|
applyFilters()
|
||||||
updateRecipeCount()
|
updateRecipeCount()
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user