[Advanced search] Edit of stored query description can now be done. Formatted code a bit.
这个提交包含在:
父节点
7979431d95
当前提交
3baffed23e
共有 4 个文件被更改,包括 321 次插入 和 291 次删除
|
|
@ -120,15 +120,14 @@ class Search extends CI_Controller {
|
|||
$this->search_filter->delete_query($id);
|
||||
}
|
||||
|
||||
function edit_query() {
|
||||
function save_edited_query() {
|
||||
$data = array(
|
||||
'cat' => xss_clean($this->input->post('category')),
|
||||
'title' => xss_clean($this->input->post('title')),
|
||||
'note' => xss_clean($this->input->post('content'))
|
||||
'description' => xss_clean($this->input->post('description')),
|
||||
);
|
||||
|
||||
$this->db->where('id', xss_clean($this->input->post('id')));
|
||||
$this->db->update('notes', $data);
|
||||
$this->db->where('userid', $this->session->userdata['user_id']);
|
||||
$this->db->update('queries', $data);
|
||||
}
|
||||
|
||||
function fetchQueryResult($json, $returnquery) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ class Migration_add_queries_table extends CI_Migration
|
|||
{
|
||||
public function up()
|
||||
{
|
||||
$this->db->query("create table queries (id integer not null auto_increment, query text, description text, userid integer not null, primary key (id)) ENGINE=myisam DEFAULT CHARSET=utf8;");
|
||||
$this->db->query("create table if not exists queries (id integer not null auto_increment, query text, description text, userid integer not null, primary key (id)) ENGINE=myisam DEFAULT CHARSET=utf8;");
|
||||
}
|
||||
|
||||
public function down()
|
||||
|
|
|
|||
|
|
@ -52,289 +52,320 @@ function load_was_map() {
|
|||
|
||||
<?php if ($this->uri->segment(1) == "search" && $this->uri->segment(2) == "filter") { ?>
|
||||
|
||||
<script type="text/javascript" src="<?php echo base_url() ;?>assets/js/query-builder.standalone.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/query-builder.standalone.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(".search-results-box").hide();
|
||||
$(".search-results-box").hide();
|
||||
|
||||
$('#builder').queryBuilder({
|
||||
filters: [
|
||||
<?php foreach ($get_table_names->result() as $row) {
|
||||
$value_name = str_replace("COL_", "", $row->Field);
|
||||
if ($value_name != "PRIMARY_KEY" && strpos($value_name, 'MY_') === false && strpos($value_name, '_INTL') == false) { ?>
|
||||
{
|
||||
id: '<?php echo $row->Field; ?>',
|
||||
label: '<?php echo $value_name; ?>',
|
||||
<?php if (strpos($row->Type, 'int(') !== false) { ?>
|
||||
type: 'integer',
|
||||
operators: ['equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal']
|
||||
<?php } elseif(strpos($row->Type, 'double') !== false) { ?>
|
||||
type: 'double',
|
||||
operators: ['equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal']
|
||||
<?php } elseif(strpos($row->Type, 'datetime') !== false) { ?>
|
||||
type: 'datetime',
|
||||
operators: ['equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal']
|
||||
<?php } else { ?>
|
||||
type: 'string',
|
||||
operators: ['equal', 'not_equal', 'begins_with', 'contains', 'ends_with', 'is_empty', 'is_not_empty', 'is_null', 'is_not_null']
|
||||
<?php } ?>
|
||||
},
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
]
|
||||
});
|
||||
filters: [
|
||||
<?php foreach ($get_table_names->result() as $row) {
|
||||
$value_name = str_replace("COL_", "", $row->Field);
|
||||
if ($value_name != "PRIMARY_KEY" && strpos($value_name, 'MY_') === false && strpos($value_name, '_INTL') == false) { ?> {
|
||||
id: '<?php echo $row->Field; ?>',
|
||||
label: '<?php echo $value_name; ?>',
|
||||
<?php if (strpos($row->Type, 'int(') !== false) { ?>
|
||||
type: 'integer',
|
||||
operators: ['equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal']
|
||||
<?php } elseif (strpos($row->Type, 'double') !== false) { ?>
|
||||
type: 'double',
|
||||
operators: ['equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal']
|
||||
<?php } elseif (strpos($row->Type, 'datetime') !== false) { ?>
|
||||
type: 'datetime',
|
||||
operators: ['equal', 'not_equal', 'less', 'less_or_equal', 'greater', 'greater_or_equal']
|
||||
<?php } else { ?>
|
||||
type: 'string',
|
||||
operators: ['equal', 'not_equal', 'begins_with', 'contains', 'ends_with', 'is_empty', 'is_not_empty', 'is_null', 'is_not_null']
|
||||
<?php } ?>
|
||||
},
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
function export_search_result(){
|
||||
var result = $('#builder').queryBuilder('getRules');
|
||||
if (!$.isEmptyObject(result)) {
|
||||
xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
var a;
|
||||
if (xhttp.readyState === 4 && xhttp.status === 200) {
|
||||
// Trick for making downloadable link
|
||||
a = document.createElement('a');
|
||||
a.href = window.URL.createObjectURL(xhttp.response);
|
||||
// Give filename you wish to download
|
||||
a.download = "advanced_search_export.adi";
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
}
|
||||
};
|
||||
// Post data to URL which handles post request
|
||||
xhttp.open("POST", "<?php echo site_url('search/export_to_adif');?>", true);
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
// You should set responseType as blob for binary responses
|
||||
xhttp.responseType = 'blob';
|
||||
xhttp.send("search=" + JSON.stringify(result, null, 2));
|
||||
}
|
||||
}
|
||||
|
||||
function export_stored_query(id){
|
||||
xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
var a;
|
||||
if (xhttp.readyState === 4 && xhttp.status === 200) {
|
||||
// Trick for making downloadable link
|
||||
a = document.createElement('a');
|
||||
a.href = window.URL.createObjectURL(xhttp.response);
|
||||
// Give filename you wish to download
|
||||
a.download = "advanced_search_export.adi";
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
}
|
||||
};
|
||||
// Post data to URL which handles post request
|
||||
xhttp.open("POST", "<?php echo site_url('search/export_stored_query_to_adif');?>", true);
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
// You should set responseType as blob for binary responses
|
||||
xhttp.responseType = 'blob';
|
||||
xhttp.send("id=" + id);
|
||||
}
|
||||
|
||||
$('#btn-save').on('click', function() {
|
||||
var resultquery = $('#builder').queryBuilder('getRules');
|
||||
if (!$.isEmptyObject(resultquery)) {
|
||||
let message = 'Description: <input class="form-control input-group-sm getqueryname">'
|
||||
|
||||
BootstrapDialog.confirm({
|
||||
title: 'Query description',
|
||||
size: BootstrapDialog.SIZE_NORMAL,
|
||||
cssClass: 'description-dialog',
|
||||
closable: true,
|
||||
nl2br: false,
|
||||
message: message,
|
||||
btnCancelLabel: 'Cancel',
|
||||
btnOKLabel: 'Save',
|
||||
callback: function(result) {
|
||||
if(result) {
|
||||
$.post( "<?php echo site_url('search/save_query');?>", { search: JSON.stringify(resultquery, null, 2), description: $(".getqueryname").val() })
|
||||
.done(function( data ) {
|
||||
$(".alert").remove();
|
||||
$(".card-body.main").append('<div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Your query has been saved!</div>');
|
||||
$('#querydropdown').append( new Option(data.description, data.id) ); // We add the saved query to the dropdown
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
else{
|
||||
BootstrapDialog.show({
|
||||
title: 'Stored Queries',
|
||||
type: BootstrapDialog.TYPE_WARNING,
|
||||
size: BootstrapDialog.SIZE_NORMAL,
|
||||
cssClass: 'queries-dialog',
|
||||
nl2br: false,
|
||||
message: 'You need to make a query before you search!',
|
||||
buttons: [{
|
||||
label: 'Close',
|
||||
action: function (dialogItself) {
|
||||
dialogItself.close();
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function run_query() {
|
||||
$(".alert").remove();
|
||||
$(".runbutton").addClass('running');
|
||||
$(".runbutton").prop('disabled', true);
|
||||
let id = $('#querydropdown').val();
|
||||
$.post( "<?php echo site_url('search/run_query');?>", { id: id})
|
||||
.done(function( data ) {
|
||||
|
||||
$('.exportbutton').html('<button class="btn btn-sm btn-primary" onclick="export_stored_query('+id+')">Export to ADIF</button>');
|
||||
$('.card-body.result').empty();
|
||||
$(".search-results-box").show();
|
||||
|
||||
$('.card-body.result').append(data);
|
||||
$('.table').DataTable({
|
||||
"pageLength": 25,
|
||||
responsive: false,
|
||||
ordering: false,
|
||||
"scrollY": "400px",
|
||||
"scrollCollapse": true,
|
||||
"paging": false,
|
||||
"scrollX": true,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
'csv'
|
||||
]
|
||||
});
|
||||
// change color of csv-button if dark mode is chosen
|
||||
if (isDarkModeTheme()) {
|
||||
$(".buttons-csv").css("color", "white");
|
||||
}
|
||||
$(".runbutton").removeClass('running');
|
||||
$(".runbutton").prop('disabled', false);
|
||||
});
|
||||
}
|
||||
|
||||
function delete_stored_query(id) {
|
||||
BootstrapDialog.confirm({
|
||||
title: 'DANGER',
|
||||
message: 'Warning! Are you sure you want delete this stored query?' ,
|
||||
type: BootstrapDialog.TYPE_DANGER,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
btnOKClass: 'btn-danger',
|
||||
callback: function(result) {
|
||||
if(result) {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/search/delete_query',
|
||||
type: 'post',
|
||||
data: {'id': id
|
||||
},
|
||||
success: function(data) {
|
||||
$(".bootstrap-dialog-message").prepend('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>The stored query has been deleted!</div>');
|
||||
$("#query_" + id).remove(); // removes query from table in dialog
|
||||
$("#querydropdown option[value='"+id+"']").remove(); // removes query from dropdown
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function edit_stored_query(id) {
|
||||
|
||||
}
|
||||
|
||||
$('#btn-edit').on('click', function() {
|
||||
$(".alert").remove();
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/search/get_stored_queries',
|
||||
type: 'post',
|
||||
success: function (html) {
|
||||
BootstrapDialog.show({
|
||||
title: 'Stored Queries',
|
||||
size: BootstrapDialog.SIZE_WIDE,
|
||||
cssClass: 'queries-dialog',
|
||||
nl2br: false,
|
||||
message: html,
|
||||
buttons: [{
|
||||
label: 'Close',
|
||||
action: function (dialogItself) {
|
||||
dialogItself.close();
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#btn-get').on('click', function() {
|
||||
$(".alert").remove();
|
||||
var result = $('#builder').queryBuilder('getRules');
|
||||
if (!$.isEmptyObject(result)) {
|
||||
$(".searchbutton").addClass('running');
|
||||
$(".searchbutton").prop('disabled', true);
|
||||
|
||||
$.post( "<?php echo site_url('search/search_result');?>", { search: JSON.stringify(result, null, 2), temp: "testvar" })
|
||||
.done(function( data ) {
|
||||
$('.exportbutton').html('<button class="btn btn-sm btn-primary" onclick="export_search_result();">Export to ADIF</button>');
|
||||
|
||||
$('.card-body.result').empty();
|
||||
$(".search-results-box").show();
|
||||
|
||||
$('.card-body.result').append(data);
|
||||
$('.table').DataTable({
|
||||
"pageLength": 25,
|
||||
responsive: false,
|
||||
ordering: false,
|
||||
"scrollY": "400px",
|
||||
"scrollCollapse": true,
|
||||
"paging": false,
|
||||
"scrollX": true,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
'csv'
|
||||
]
|
||||
});
|
||||
// change color of csv-button if dark mode is chosen
|
||||
if (isDarkModeTheme()) {
|
||||
$(".buttons-csv").css("color", "white");
|
||||
}
|
||||
$(".searchbutton").removeClass('running');
|
||||
$(".searchbutton").prop('disabled', false);
|
||||
$("#btn-save").show();
|
||||
});
|
||||
}
|
||||
else{
|
||||
BootstrapDialog.show({
|
||||
title: 'Stored Queries',
|
||||
type: BootstrapDialog.TYPE_WARNING,
|
||||
size: BootstrapDialog.SIZE_NORMAL,
|
||||
cssClass: 'queries-dialog',
|
||||
nl2br: false,
|
||||
message: 'You need to make a query before you search!',
|
||||
buttons: [{
|
||||
label: 'Close',
|
||||
action: function (dialogItself) {
|
||||
dialogItself.close();
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#btn-set').on('click', function() {
|
||||
//$('#builder').queryBuilder('setRules', rules_basic);
|
||||
var result = $('#builder').queryBuilder('getRules');
|
||||
if (!$.isEmptyObject(result)) {
|
||||
rules_basic = result;
|
||||
function export_search_result() {
|
||||
var result = $('#builder').queryBuilder('getRules');
|
||||
if (!$.isEmptyObject(result)) {
|
||||
xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
var a;
|
||||
if (xhttp.readyState === 4 && xhttp.status === 200) {
|
||||
// Trick for making downloadable link
|
||||
a = document.createElement('a');
|
||||
a.href = window.URL.createObjectURL(xhttp.response);
|
||||
// Give filename you wish to download
|
||||
a.download = "advanced_search_export.adi";
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
}
|
||||
};
|
||||
// Post data to URL which handles post request
|
||||
xhttp.open("POST", "<?php echo site_url('search/export_to_adif'); ?>", true);
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
// You should set responseType as blob for binary responses
|
||||
xhttp.responseType = 'blob';
|
||||
xhttp.send("search=" + JSON.stringify(result, null, 2));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//When rules changed :
|
||||
$('#builder').on('getRules.queryBuilder.filter', function(e) {
|
||||
//$log.info(e.value);
|
||||
});
|
||||
function export_stored_query(id) {
|
||||
xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
var a;
|
||||
if (xhttp.readyState === 4 && xhttp.status === 200) {
|
||||
// Trick for making downloadable link
|
||||
a = document.createElement('a');
|
||||
a.href = window.URL.createObjectURL(xhttp.response);
|
||||
// Give filename you wish to download
|
||||
a.download = "advanced_search_export.adi";
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
}
|
||||
};
|
||||
// Post data to URL which handles post request
|
||||
xhttp.open("POST", "<?php echo site_url('search/export_stored_query_to_adif'); ?>", true);
|
||||
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
// You should set responseType as blob for binary responses
|
||||
xhttp.responseType = 'blob';
|
||||
xhttp.send("id=" + id);
|
||||
}
|
||||
|
||||
$('#btn-save').on('click', function() {
|
||||
var resultquery = $('#builder').queryBuilder('getRules');
|
||||
if (!$.isEmptyObject(resultquery)) {
|
||||
let message = 'Description: <input class="form-control input-group-sm getqueryname">'
|
||||
|
||||
BootstrapDialog.confirm({
|
||||
title: 'Query description',
|
||||
size: BootstrapDialog.SIZE_NORMAL,
|
||||
cssClass: 'description-dialog',
|
||||
closable: true,
|
||||
nl2br: false,
|
||||
message: message,
|
||||
btnCancelLabel: 'Cancel',
|
||||
btnOKLabel: 'Save',
|
||||
callback: function(result) {
|
||||
if (result) {
|
||||
$.post("<?php echo site_url('search/save_query'); ?>", {
|
||||
search: JSON.stringify(resultquery, null, 2),
|
||||
description: $(".getqueryname").val()
|
||||
})
|
||||
.done(function(data) {
|
||||
$(".alert").remove();
|
||||
$(".card-body.main").append('<div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Your query has been saved!</div>');
|
||||
$('#querydropdown').append(new Option(data.description, data.id)); // We add the saved query to the dropdown
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
} else {
|
||||
BootstrapDialog.show({
|
||||
title: 'Stored Queries',
|
||||
type: BootstrapDialog.TYPE_WARNING,
|
||||
size: BootstrapDialog.SIZE_NORMAL,
|
||||
cssClass: 'queries-dialog',
|
||||
nl2br: false,
|
||||
message: 'You need to make a query before you search!',
|
||||
buttons: [{
|
||||
label: 'Close',
|
||||
action: function(dialogItself) {
|
||||
dialogItself.close();
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function run_query() {
|
||||
$(".alert").remove();
|
||||
$(".runbutton").addClass('running');
|
||||
$(".runbutton").prop('disabled', true);
|
||||
let id = $('#querydropdown').val();
|
||||
$.post("<?php echo site_url('search/run_query'); ?>", {
|
||||
id: id
|
||||
})
|
||||
.done(function(data) {
|
||||
|
||||
$('.exportbutton').html('<button class="btn btn-sm btn-primary" onclick="export_stored_query(' + id + ')">Export to ADIF</button>');
|
||||
$('.card-body.result').empty();
|
||||
$(".search-results-box").show();
|
||||
|
||||
$('.card-body.result').append(data);
|
||||
$('.table').DataTable({
|
||||
"pageLength": 25,
|
||||
responsive: false,
|
||||
ordering: false,
|
||||
"scrollY": "400px",
|
||||
"scrollCollapse": true,
|
||||
"paging": false,
|
||||
"scrollX": true,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
'csv'
|
||||
]
|
||||
});
|
||||
// change color of csv-button if dark mode is chosen
|
||||
if (isDarkModeTheme()) {
|
||||
$(".buttons-csv").css("color", "white");
|
||||
}
|
||||
$(".runbutton").removeClass('running');
|
||||
$(".runbutton").prop('disabled', false);
|
||||
});
|
||||
}
|
||||
|
||||
function delete_stored_query(id) {
|
||||
BootstrapDialog.confirm({
|
||||
title: 'DANGER',
|
||||
message: 'Warning! Are you sure you want delete this stored query?',
|
||||
type: BootstrapDialog.TYPE_DANGER,
|
||||
closable: true,
|
||||
draggable: true,
|
||||
btnOKClass: 'btn-danger',
|
||||
callback: function(result) {
|
||||
if (result) {
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/search/delete_query',
|
||||
type: 'post',
|
||||
data: {
|
||||
'id': id
|
||||
},
|
||||
success: function(data) {
|
||||
$(".bootstrap-dialog-message").prepend('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>The stored query has been deleted!</div>');
|
||||
$("#query_" + id).remove(); // removes query from table in dialog
|
||||
$("#querydropdown option[value='" + id + "']").remove(); // removes query from dropdown
|
||||
},
|
||||
error: function() {
|
||||
$(".bootstrap-dialog-message").prepend('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>The stored query could not be deleted. Please try again!</div>');
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function edit_stored_query(id) {
|
||||
$('#description_' + id).attr('contenteditable', 'true');
|
||||
$('#description_' + id).focus();
|
||||
$('#edit_' + id).html('<a class="btn btn-primary btn-sm" href="javascript:save_edited_query(' + id + ');">Save</a>'); // Change to save button
|
||||
}
|
||||
|
||||
function save_edited_query(id) {
|
||||
$('#description_' + id).attr('contenteditable', 'false');
|
||||
$('#edit_' + id).html('<a class="btn btn-outline-primary btn-sm" href="javascript:edit_stored_query(' + id + ');">Edit</a>');
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/search/save_edited_query',
|
||||
type: 'post',
|
||||
data: {
|
||||
id: id,
|
||||
description: $('#description_' + id).html(),
|
||||
},
|
||||
success: function(html) {
|
||||
$('#edit_' + id).html('<a class="btn btn-outline-primary btn-sm" href="javascript:edit_stored_query(' + id + ');">Edit</a>'); // Change to edit button
|
||||
$(".bootstrap-dialog-message").prepend('<div class="alert alert-success"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>The query description has been updated!</div>');
|
||||
$("#querydropdown option[value='" + id + "']").text($('#description_' + id).html()); // Change text in dropdown
|
||||
},
|
||||
error: function() {
|
||||
$(".bootstrap-dialog-message").prepend('<div class="alert alert-danger"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Something went wrong with the save. Please try again!</div>');
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
$('#btn-edit').on('click', function() {
|
||||
$(".alert").remove();
|
||||
$.ajax({
|
||||
url: base_url + 'index.php/search/get_stored_queries',
|
||||
type: 'post',
|
||||
success: function(html) {
|
||||
BootstrapDialog.show({
|
||||
title: 'Stored Queries',
|
||||
size: BootstrapDialog.SIZE_WIDE,
|
||||
cssClass: 'queries-dialog',
|
||||
nl2br: false,
|
||||
message: html,
|
||||
buttons: [{
|
||||
label: 'Close',
|
||||
action: function(dialogItself) {
|
||||
dialogItself.close();
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#btn-get').on('click', function() {
|
||||
$(".alert").remove();
|
||||
var result = $('#builder').queryBuilder('getRules');
|
||||
if (!$.isEmptyObject(result)) {
|
||||
$(".searchbutton").addClass('running');
|
||||
$(".searchbutton").prop('disabled', true);
|
||||
|
||||
$.post("<?php echo site_url('search/search_result'); ?>", {
|
||||
search: JSON.stringify(result, null, 2),
|
||||
temp: "testvar"
|
||||
})
|
||||
.done(function(data) {
|
||||
$('.exportbutton').html('<button class="btn btn-sm btn-primary" onclick="export_search_result();">Export to ADIF</button>');
|
||||
|
||||
$('.card-body.result').empty();
|
||||
$(".search-results-box").show();
|
||||
|
||||
$('.card-body.result').append(data);
|
||||
$('.table').DataTable({
|
||||
"pageLength": 25,
|
||||
responsive: false,
|
||||
ordering: false,
|
||||
"scrollY": "400px",
|
||||
"scrollCollapse": true,
|
||||
"paging": false,
|
||||
"scrollX": true,
|
||||
dom: 'Bfrtip',
|
||||
buttons: [
|
||||
'csv'
|
||||
]
|
||||
});
|
||||
// change color of csv-button if dark mode is chosen
|
||||
if (isDarkModeTheme()) {
|
||||
$(".buttons-csv").css("color", "white");
|
||||
}
|
||||
$(".searchbutton").removeClass('running');
|
||||
$(".searchbutton").prop('disabled', false);
|
||||
$("#btn-save").show();
|
||||
});
|
||||
} else {
|
||||
BootstrapDialog.show({
|
||||
title: 'Stored Queries',
|
||||
type: BootstrapDialog.TYPE_WARNING,
|
||||
size: BootstrapDialog.SIZE_NORMAL,
|
||||
cssClass: 'queries-dialog',
|
||||
nl2br: false,
|
||||
message: 'You need to make a query before you search!',
|
||||
buttons: [{
|
||||
label: 'Close',
|
||||
action: function(dialogItself) {
|
||||
dialogItself.close();
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#btn-set').on('click', function() {
|
||||
//$('#builder').queryBuilder('setRules', rules_basic);
|
||||
var result = $('#builder').queryBuilder('getRules');
|
||||
if (!$.isEmptyObject(result)) {
|
||||
rules_basic = result;
|
||||
}
|
||||
});
|
||||
|
||||
//When rules changed :
|
||||
$('#builder').on('getRules.queryBuilder.filter', function(e) {
|
||||
//$log.info(e.value);
|
||||
});
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
|
|
|
|||
|
|
@ -13,15 +13,15 @@ $i = 1;
|
|||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach($result as $q) {
|
||||
echo '<tr id="query_' . $q->id . '">';
|
||||
echo '<td>' . $i++ . '</td>';
|
||||
echo '<td>' . $q->description . '</td>';
|
||||
echo '<td>' . $q->query . '</td>';
|
||||
echo '<td><a class="btn btn-outline-primary btn-sm" href="javascript:edit_stored_query(' . $q->id . ');">Edit</a></>';
|
||||
echo '<td><a class="btn btn-danger btn-sm" href="javascript:delete_stored_query(' . $q->id . ');">Delete</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
foreach ($result as $q) {
|
||||
echo '<tr id="query_' . $q->id . '">';
|
||||
echo '<td>' . $i++ . '</td>';
|
||||
echo '<td contenteditable="false" id="description_' . $q->id . '">' . $q->description . '</td>';
|
||||
echo '<td>' . $q->query . '</td>';
|
||||
echo '<td id="edit_' . $q->id . '"><a class="btn btn-outline-primary btn-sm" href="javascript:edit_stored_query(' . $q->id . ');">Edit</a></>';
|
||||
echo '<td><a class="btn btn-danger btn-sm" href="javascript:delete_stored_query(' . $q->id . ');">Delete</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
正在加载…
在新工单中引用