Lines 855-864
function _dt_add_filters(table_node, table_dt, filters_options = {}) {
Link Here
|
855 |
$(th).removeClass('sorting').removeClass("sorting_asc").removeClass("sorting_desc"); |
855 |
$(th).removeClass('sorting').removeClass("sorting_asc").removeClass("sorting_desc"); |
856 |
if ( is_searchable ) { |
856 |
if ( is_searchable ) { |
857 |
let input_type = 'input'; |
857 |
let input_type = 'input'; |
|
|
858 |
let existing_search = column.search(); |
858 |
if ( $(th).data('filter') || filters_options.hasOwnProperty(i)) { |
859 |
if ( $(th).data('filter') || filters_options.hasOwnProperty(i)) { |
859 |
input_type = 'select' |
860 |
input_type = 'select' |
860 |
let filter_type = $(th).data('filter'); |
861 |
let filter_type = $(th).data('filter'); |
861 |
let existing_search = column.search(); |
|
|
862 |
let select = $('<select class="dt-select-filter"><option value=""></option></select'); |
862 |
let select = $('<select class="dt-select-filter"><option value=""></option></select'); |
863 |
|
863 |
|
864 |
// FIXME eval here is bad and dangerous, how do we workaround that? |
864 |
// FIXME eval here is bad and dangerous, how do we workaround that? |
Lines 869-874
function _dt_add_filters(table_node, table_dt, filters_options = {}) {
Link Here
|
869 |
} |
869 |
} |
870 |
$(filters_options[i]).each(function(){ |
870 |
$(filters_options[i]).each(function(){ |
871 |
let o = $('<option value="%s">%s</option>'.format(this._id, this._str)); |
871 |
let o = $('<option value="%s">%s</option>'.format(this._id, this._str)); |
|
|
872 |
// Compare with lc, or selfreg won't match ^SELFREG$ for instance, see bug 32517 |
873 |
// This is only for category, we might want to apply it only in this case. |
874 |
existing_search = existing_search.toLowerCase() |
872 |
if ( existing_search === this._id || (existing_search && this._id.match(existing_search)) ) { |
875 |
if ( existing_search === this._id || (existing_search && this._id.match(existing_search)) ) { |
873 |
o.prop("selected", "selected"); |
876 |
o.prop("selected", "selected"); |
874 |
} |
877 |
} |
Lines 877-883
function _dt_add_filters(table_node, table_dt, filters_options = {}) {
Link Here
|
877 |
$(th).html( select ); |
880 |
$(th).html( select ); |
878 |
} else { |
881 |
} else { |
879 |
var title = $(th).text(); |
882 |
var title = $(th).text(); |
880 |
var existing_search = table_dt.column(i).search(); |
|
|
881 |
if ( existing_search ) { |
883 |
if ( existing_search ) { |
882 |
$(th).html( '<input type="text" value="%s" style="width: 100%" />'.format(existing_search) ); |
884 |
$(th).html( '<input type="text" value="%s" style="width: 100%" />'.format(existing_search) ); |
883 |
} else { |
885 |
} else { |
884 |
- |
|
|