Bug 31028: (follow-up) Remove special:undefined
There's a cleaner way to achieve this now using `additional_filters` and passing a function. This patch removes the `special:undefined` handling, replacing it with a single field filter passed as a function via additional_filters. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
9f8a1e2c2a
commit
96f5f80bdd
3 changed files with 40 additions and 21 deletions
|
@ -1353,6 +1353,18 @@ Note that permanent location is a code, and location may be an authval.
|
|||
$(document).ready(function() {
|
||||
var table_settings = [% TablesSettings.GetTableSettings( 'cataloguing', 'concerns', 'table_concerns', 'json' ) | $raw %];
|
||||
|
||||
var filtered = false;
|
||||
let additional_filters = {
|
||||
resolved_date: function(){
|
||||
if ( filtered ) {
|
||||
return { "=": null };
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
},
|
||||
biblio_id: [% biblionumber | uri %]
|
||||
};
|
||||
|
||||
var tickets_url = '/api/v1/tickets';
|
||||
var tickets = $("#table_concerns").kohaTable({
|
||||
"ajax": {
|
||||
|
@ -1434,15 +1446,16 @@ Note that permanent location is a code, and location may be an authval.
|
|||
"orderable": false
|
||||
},
|
||||
]
|
||||
}, table_settings, 0, { biblio_id: [% biblionumber | uri %]});
|
||||
}, table_settings, 0, additional_filters);
|
||||
|
||||
$('#hideResolved').on( "click", function() {
|
||||
// It would be great if we could pass null here but it gets stringified
|
||||
concerns.DataTable().columns('3').search('special:undefined').draw();
|
||||
$('#hideResolved').on("click", function() {
|
||||
filtered = true;
|
||||
tickets.DataTable().draw();
|
||||
});
|
||||
|
||||
$('#showAll').on( "click", function() {
|
||||
concerns.DataTable().columns('3').search('').draw();
|
||||
$('#showAll').on("click", function() {
|
||||
filtered = false;
|
||||
tickets.DataTable().draw();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -78,6 +78,17 @@
|
|||
|
||||
var table_settings = [% TablesSettings.GetTableSettings('cataloguing', 'concerns', 'table_concerns', 'json') | $raw %];
|
||||
|
||||
var filtered = false;
|
||||
let additional_filters = {
|
||||
resolved_date: function(){
|
||||
if ( filtered ) {
|
||||
return { "=": null };
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var tickets_url = '/api/v1/tickets';
|
||||
var tickets = $("#table_concerns").kohaTable({
|
||||
"ajax": {
|
||||
|
@ -168,15 +179,16 @@
|
|||
"orderable": false
|
||||
},
|
||||
]
|
||||
}, table_settings, 1);
|
||||
}, table_settings, 1, additional_filters);
|
||||
|
||||
$('#hideResolved').on("click", function() {
|
||||
// It would be great if we could pass null here but it gets stringified
|
||||
tickets.DataTable().columns('3').search('special:undefined').draw();
|
||||
filtered = true;
|
||||
tickets.DataTable().draw();
|
||||
});
|
||||
|
||||
$('#showAll').on("click", function() {
|
||||
tickets.DataTable().columns('3').search('').draw();
|
||||
filtered = false;
|
||||
tickets.DataTable().draw();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -586,18 +586,12 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) {
|
|||
var part = {};
|
||||
var attr = attributes[i];
|
||||
let criteria = options.criteria;
|
||||
if ( value === 'special:undefined' ) {
|
||||
value = null;
|
||||
if ( value.match(/^\^(.*)\$$/) ) {
|
||||
value = value.replace(/^\^/, '').replace(/\$$/, '');
|
||||
criteria = "exact";
|
||||
}
|
||||
if ( value !== null ) {
|
||||
if ( value.match(/^\^(.*)\$$/) ) {
|
||||
value = value.replace(/^\^/, '').replace(/\$$/, '');
|
||||
criteria = "exact";
|
||||
} else {
|
||||
// escape SQL LIKE special characters %
|
||||
value = value.replace(/(\%|\\)/g, "\\$1");
|
||||
}
|
||||
} else {
|
||||
// escape SQL LIKE special characters %
|
||||
value = value.replace(/(\%|\\)/g, "\\$1");
|
||||
}
|
||||
part[!attr.includes('.')?'me.'+attr:attr] = criteria === 'exact'
|
||||
? value
|
||||
|
|
Loading…
Reference in a new issue