fix missing filters on status tab when user swithches to another state
This commit is contained in:
parent
2ed6cd9e46
commit
261c8e765f
|
|
@ -26,6 +26,20 @@
|
|||
|
||||
$(".selected_issue").bind "change", Issues.checkChanged
|
||||
|
||||
# Update state filters if present in page
|
||||
updateStateFilters: ->
|
||||
stateFilters = $('.issues-state-filters')
|
||||
newParams = {}
|
||||
paramKeys = ['author_id', 'label_name', 'milestone_title', 'assignee_id', 'issue_search']
|
||||
|
||||
for paramKey in paramKeys
|
||||
newParams[paramKey] = getUrlParameter(paramKey) or ''
|
||||
|
||||
if stateFilters.length
|
||||
stateFilters.find('a').each ->
|
||||
initialUrl = $(this).attr 'href'
|
||||
$(this).attr 'href', mergeUrlParams(newParams, initialUrl)
|
||||
|
||||
# Make sure we trigger ajax request only after user stop typing
|
||||
initSearch: ->
|
||||
@timer = null
|
||||
|
|
@ -54,6 +68,7 @@
|
|||
# Change url so if user reload a page - search results are saved
|
||||
history.replaceState {page: issuesUrl}, document.title, issuesUrl
|
||||
Issues.reload()
|
||||
Issues.updateStateFilters()
|
||||
dataType: "json"
|
||||
|
||||
checkChanged: ->
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
function getUrlParameter(sParam) {
|
||||
var sPageURL = decodeURIComponent(window.location.search.substring(1)),
|
||||
sURLVariables = sPageURL.split('&'),
|
||||
sParameterName,
|
||||
i;
|
||||
|
||||
for (i = 0; i < sURLVariables.length; i++) {
|
||||
sParameterName = sURLVariables[i].split('=');
|
||||
|
||||
if (sParameterName[0] === sParam) {
|
||||
return sParameterName[1] === undefined ? true : sParameterName[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} params - url keys and value to merge
|
||||
* @param {String} url
|
||||
*/
|
||||
function mergeUrlParams(params, url){
|
||||
var newUrl = decodeURIComponent(url);
|
||||
|
||||
Object.keys(params).forEach(function(paramName) {
|
||||
var pattern = new RegExp('\\b('+paramName+'=).*?(&|$)')
|
||||
if (url.search(pattern) >= 0){
|
||||
newUrl = newUrl.replace(pattern,'$1' + params[paramName] + '$2');
|
||||
} else {
|
||||
newUrl = newUrl + (newUrl.indexOf('?') > 0 ? '&' : '?') + paramName + '=' + params[paramName]
|
||||
}
|
||||
});
|
||||
|
||||
return newUrl;
|
||||
}
|
||||
Loading…
Reference in New Issue