mirror of https://github.com/MISP/MISP
fix: [UI] Cancelling search didn't work for index table
parent
123fce3f10
commit
44ffccf5cb
|
@ -101,7 +101,7 @@
|
|||
$url = $baseurl . '/' . $this->params['controller'] . '/' . $this->params['action'];
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var passedArgsArray = <?= isset($passedArgs) ? $passedArgs : '[]'; ?>;
|
||||
var passedArgsArray = <?= isset($passedArgs) ? $passedArgs : '{}'; ?>;
|
||||
<?php
|
||||
if (isset($containerId)) {
|
||||
echo 'var target = "#' . $containerId . '_content";';
|
||||
|
@ -112,9 +112,9 @@
|
|||
$(function() {
|
||||
$('#quickFilterButton').click(function() {
|
||||
if (typeof(target) !== 'undefined') {
|
||||
runIndexQuickFilter(passedArgsArray, url, target);
|
||||
runIndexQuickFilterFixed(passedArgsArray, url, target);
|
||||
} else {
|
||||
runIndexQuickFilter(passedArgsArray, url);
|
||||
runIndexQuickFilterFixed(passedArgsArray, url);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2211,6 +2211,7 @@ function cancelSearch() {
|
|||
$('#quickFilterButton').click();
|
||||
}
|
||||
|
||||
// Deprecated, when possible use runIndexQuickFilterFixed that is cleaner
|
||||
function runIndexQuickFilter(preserveParams, url, target) {
|
||||
if (typeof passedArgsArray === "undefined") {
|
||||
var passedArgsArray = [];
|
||||
|
@ -2274,6 +2275,54 @@ function runIndexQuickFilter(preserveParams, url, target) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object} preserveParams
|
||||
* @param {string} url
|
||||
* @param {string} [target]
|
||||
*/
|
||||
function runIndexQuickFilterFixed(preserveParams, url, target) {
|
||||
var $quickFilterField = $('#quickFilterField');
|
||||
var searchKey;
|
||||
if ($quickFilterField.data('searchkey')) {
|
||||
searchKey = $quickFilterField.data('searchkey');
|
||||
} else {
|
||||
searchKey = 'searchall';
|
||||
}
|
||||
if ($quickFilterField.val().trim().length > 0) {
|
||||
preserveParams[searchKey] = encodeURIComponent($quickFilterField.val().trim());
|
||||
} else {
|
||||
delete preserveParams[searchKey]
|
||||
}
|
||||
for (var key in preserveParams) {
|
||||
if (typeof key == 'number') {
|
||||
url += "/" + preserveParams[key];
|
||||
} else if (key !== 'page') {
|
||||
url += "/" + key + ":" + preserveParams[key];
|
||||
}
|
||||
}
|
||||
|
||||
if (target !== undefined) {
|
||||
$.ajax({
|
||||
beforeSend: function () {
|
||||
$(".loading").show();
|
||||
},
|
||||
success: function (data) {
|
||||
$(target).html(data);
|
||||
},
|
||||
error: function() {
|
||||
showMessage('fail', 'Could not fetch the requested data.');
|
||||
},
|
||||
complete: function() {
|
||||
$(".loading").hide();
|
||||
},
|
||||
type: "get",
|
||||
url: url
|
||||
});
|
||||
} else {
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
|
||||
function executeFilter(passedArgs, url) {
|
||||
for (var key in passedArgs) url += "/" + key + ":" + passedArgs[key];
|
||||
window.location.href=url;
|
||||
|
|
Loading…
Reference in New Issue