Fix table sorting after loading search results

This commit is contained in:
jekkos
2015-09-07 08:35:59 +02:00
parent 80f7966d1c
commit b680cdff36
9 changed files with 46 additions and 36 deletions

View File

@@ -6,7 +6,8 @@ $(document).ready(function()
enable_select_all();
enable_checkboxes();
enable_row_selection();
enable_search('<?php echo site_url("$controller_name/suggest")?>','<?php echo $this->lang->line("common_confirm_search")?>');
enable_search({suggest_url: '<?php echo site_url("$controller_name/suggest")?>',
confirm_search_messsage: 'w<?php echo $this->lang->line("common_confirm_search")?>'});
enable_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>','<?php echo $this->lang->line($controller_name."_none_selected")?>');
});

View File

@@ -6,7 +6,7 @@ $(document).ready(function()
enable_select_all();
enable_checkboxes();
enable_row_selection();
enable_search('<?php echo site_url("$controller_name/suggest")?>','<?php echo $this->lang->line("common_confirm_search")?>');
enable_search(suggest_url: '<?php echo site_url("$controller_name/suggest")?>','<?php echo $this->lang->line("common_confirm_search")?>');
enable_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>','<?php echo $this->lang->line($controller_name."_none_selected")?>');
$('#generate_barcodes').click(function()

View File

@@ -6,11 +6,13 @@ $(document).ready(function()
enable_select_all();
enable_checkboxes();
enable_row_selection();
var widget = enable_search('<?php echo site_url("$controller_name/suggest")?>','<?php echo $this->lang->line("common_confirm_search")?>', undefined, {
'is_deleted' : function () {
return $("#is_deleted").is(":checked") ? 1 : 0;
}
});
var widget = enable_search({suggest_url : '<?php echo site_url("$controller_name/suggest")?>',
confirm_message : '<?php echo $this->lang->line("common_confirm_search")?>',
extra_params : {
'is_deleted' : function () {
return $("#is_deleted").is(":checked") ? 1 : 0;
}
}});
// clear suggestion cache when toggling filter
$("#is_deleted").change(function() {
widget.flushCache();

View File

@@ -5,7 +5,8 @@ $(document).ready(function()
init_table_sorting();
enable_select_all();
enable_row_selection();
enable_search('<?php echo site_url("$controller_name/suggest")?>','<?php echo $this->lang->line("common_confirm_search")?>');
enable_search({ suggest_url : '<?php echo site_url("$controller_name/suggest")?>',
confirm_search_message : '<?php echo $this->lang->line("common_confirm_search")?>'});
enable_email('<?php echo site_url("$controller_name/mailto")?>');
enable_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>','<?php echo $this->lang->line($controller_name."_none_selected")?>');
});

View File

@@ -6,20 +6,23 @@ $(document).ready(function()
init_table_sorting();
enable_checkboxes();
enable_row_selection();
enable_search('<?php echo site_url("$controller_name/suggest")?>','<?php echo $this->lang->line("common_confirm_search")?>');
var on_complete = function(response) {
$("#payment_summary").html(response.payment_summary);
};
enable_search({suggest_url : '<?php echo site_url("$controller_name/suggest")?>',
confirm_search_message : '<?php echo $this->lang->line("common_confirm_search")?>',
on_complete : on_complete});
enable_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>','<?php echo $this->lang->line($controller_name."_none_selected")?>');
$("#search_filter_section #only_invoices").change(function() {
do_search(true, function(response) {
$("#payment_summary").html(response.payment_summary);
});
do_search(true, on_complete());
return false;
});
$("#search_filter_section #only_cash").change(function() {
do_search(true, function(response) {
$("#payment_summary").html(response.payment_summary);
});
do_search(true, on_complete);
return false;
});

View File

@@ -5,7 +5,7 @@ $(document).ready(function()
init_table_sorting();
enable_select_all();
enable_row_selection();
enable_search('<?php echo site_url("$controller_name/suggest")?>','<?php echo $this->lang->line("common_confirm_search")?>');
enable_search({suggest_url : '<?php echo site_url("$controller_name/suggest")?>', confirm_search_message : '<?php echo $this->lang->line("common_confirm_search")?>'});
enable_email('<?php echo site_url("$controller_name/mailto")?>');
enable_delete('<?php echo $this->lang->line($controller_name."_confirm_delete")?>','<?php echo $this->lang->line($controller_name."_none_selected")?>');
});

13
dist/opensourcepos.js vendored
View File

@@ -17851,9 +17851,9 @@ Date.fullYearStart = '20';
}
}
function enable_search(suggest_url,confirm_search_message,format_item,extra_params)
function enable_search(options)
{
if (!format_item) {
if (!options.format_item) {
format_item = function(results) {
return results[0];
};
@@ -17867,10 +17867,11 @@ function enable_search(suggest_url,confirm_search_message,format_item,extra_para
$(this).attr('value','');
});
var widget = $("#search").autocomplete(suggest_url,{max:100,delay:10, selectFirst: false, formatItem : format_item, extraParams: extra_params});
var widget = $("#search").autocomplete(options.suggest_url,{max:100,delay:10, selectFirst: false,
formatItem : options.format_item, extraParams: options.extra_params});
$("#search").result(function(event, data, formatted)
{
do_search(true);
do_search(true, options.on_complete);
});
attach_search_listener();
@@ -17882,10 +17883,10 @@ function enable_search(suggest_url,confirm_search_message,format_item,extra_para
$('#limit_from').val(0);
if(get_selected_values().length >0)
{
if(!confirm(confirm_search_message))
if(!confirm(options.confirm_search_message))
return;
}
do_search(true);
do_search(true, options.on_complete);
});
return widget;

View File

File diff suppressed because one or more lines are too long

View File

@@ -12,9 +12,9 @@ function checkbox_click(event)
}
}
function enable_search(suggest_url,confirm_search_message,format_item,extra_params)
function enable_search(options)
{
if (!format_item) {
if (!options.format_item) {
format_item = function(results) {
return results[0];
};
@@ -28,10 +28,11 @@ function enable_search(suggest_url,confirm_search_message,format_item,extra_para
$(this).attr('value','');
});
var widget = $("#search").autocomplete(suggest_url,{max:100,delay:10, selectFirst: false, formatItem : format_item, extraParams: extra_params});
var widget = $("#search").autocomplete(options.suggest_url,{max:100,delay:10, selectFirst: false,
formatItem : options.format_item, extraParams: options.extra_params});
$("#search").result(function(event, data, formatted)
{
do_search(true);
do_search(true, options.on_complete);
});
attach_search_listener();
@@ -43,10 +44,10 @@ function enable_search(suggest_url,confirm_search_message,format_item,extra_para
$('#limit_from').val(0);
if(get_selected_values().length >0)
{
if(!confirm(confirm_search_message))
if(!confirm(options.confirm_search_message))
return;
}
do_search(true);
do_search(true, options.on_complete);
});
return widget;