Bug 24502 introduced filtering by embedded columns. It would be great if datatables wrapper for the API in bug 20212 could use this feature.
Created attachment 98612 [details] [review] Bug 24561: Datatables api wrapper also filter and order embedded columns This patch adds the ability to filter and order by embedded columns. To use it you must in JS: $('datatable_selector').api({datatables_options}) where datatables_options are all datatables options plus: 1. embed: [list of embeddable tables] This option adds x-koha-embed header to request. 2. header_filter: true|false This option if true sets x-koha-query header with stringyfied json of filters Oderable and searchable columns must define data option as string, otherwise filter and order won't be possible. If you must custom the output, use the render function. For example: * Don't > $('.table_selector').api({ > columns: [ > { > data: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); * Do > $('.table_selector').api({ > columns: [ > { > data: 'holds.patron.firstname', > render: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); To test you must implement and test bug 20936, where it will be used.
Created attachment 98624 [details] [review] Bug 24561: Datatables api wrapper also filter and order embedded columns This patch adds the ability to filter and order by embedded columns. To use it you must in JS: $('datatable_selector').api({datatables_options}) where datatables_options are all datatables options plus: 1. embed: [list of embeddable tables] This option adds x-koha-embed header to request. 2. header_filter: true|false This option if true sets x-koha-query header with stringyfied json of filters Oderable and searchable columns must define data option as string, otherwise filter and order won't be possible. If you must custom the output, use the render function. For example: * Don't > $('.table_selector').api({ > columns: [ > { > data: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); * Do > $('.table_selector').api({ > columns: [ > { > data: 'holds.patron.firstname', > render: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); To test you must implement and test bug 20936, where it will be used.
Created attachment 99254 [details] [review] Bug 24561: Datatables api wrapper also filter and order embedded columns This patch adds the ability to filter and order by embedded columns. To use it you must in JS: $('datatable_selector').api({datatables_options}) where datatables_options are all datatables options plus: 1. embed: [list of embeddable tables] This option adds x-koha-embed header to request. 2. header_filter: true|false This option if true sets x-koha-query header with stringyfied json of filters Oderable and searchable columns must define data option as string, otherwise filter and order won't be possible. If you must custom the output, use the render function. For example: * Don't > $('.table_selector').api({ > columns: [ > { > data: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); * Do > $('.table_selector').api({ > columns: [ > { > data: 'holds.patron.firstname', > render: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); To test you must implement and test bug 20936, where it will be used.
Created attachment 99255 [details] [review] Bug 24561: Datatables api wrapper also filter and order embedded columns This patch adds the ability to filter and order by embedded columns. To use it you must in JS: $('datatable_selector').api({datatables_options}) where datatables_options are all datatables options plus: 1. embed: [list of embeddable tables] This option adds x-koha-embed header to request. 2. header_filter: true|false This option if true sets x-koha-query header with stringyfied json of filters Oderable and searchable columns must define data option as string, otherwise filter and order won't be possible. If you must custom the output, use the render function. For example: * Don't > $('.table_selector').api({ > columns: [ > { > data: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); * Do > $('.table_selector').api({ > columns: [ > { > data: 'holds.patron.firstname', > render: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); To test you must implement and test bug 20936, where it will be used.
I don't know why, but when applying this bug with git bz, bug 20212 doesn't appear as an option. Maybe it's because is in state "ASSIGNED" To succesfully apply this bug, first apply 20212 manually.
Created attachment 99723 [details] [review] Bug 24561: Datatables api wrapper also filter and order embedded columns This patch adds the ability to filter and order by embedded columns. To use it you must in JS: $('datatable_selector').api({datatables_options}) where datatables_options are all datatables options plus: 1. embed: [list of embeddable tables] This option adds x-koha-embed header to request. 2. header_filter: true|false This option if true sets x-koha-query header with stringyfied json of filters Oderable and searchable columns must define data option as string, otherwise filter and order won't be possible. If you must custom the output, use the render function. For example: * Don't > $('.table_selector').api({ > columns: [ > { > data: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); * Do > $('.table_selector').api({ > columns: [ > { > data: 'holds.patron.firstname', > render: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); To test you must implement and test bug 20936, where it will be used.
Created attachment 100039 [details] [review] Bug 24561: Datatables api wrapper also filter and order embedded columns This patch adds the ability to filter and order by embedded columns. To use it you must in JS: $('datatable_selector').api({datatables_options}) where datatables_options are all datatables options plus: 1. embed: [list of embeddable tables] This option adds x-koha-embed header to request. 2. header_filter: true|false This option if true sets x-koha-query header with stringyfied json of filters Oderable and searchable columns must define data option as string, otherwise filter and order won't be possible. If you must custom the output, use the render function. For example: * Don't > $('.table_selector').api({ > columns: [ > { > data: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); * Do > $('.table_selector').api({ > columns: [ > { > data: 'holds.patron.firstname', > render: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); To test you must implement and test bug 20936, where it will be used.
Created attachment 100126 [details] [review] Bug 24561: Datatables api wrapper also filter and order embedded columns This patch adds the ability to filter and order by embedded columns. To use it you must in JS: $('datatable_selector').api({datatables_options}) where datatables_options are all datatables options plus: 1. embed: [list of embeddable tables] This option adds x-koha-embed header to request. 2. header_filter: true|false This option if true sets x-koha-query header with stringyfied json of filters Oderable and searchable columns must define data option as string, otherwise filter and order won't be possible. If you must custom the output, use the render function. For example: * Don't > $('.table_selector').api({ > columns: [ > { > data: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); * Do > $('.table_selector').api({ > columns: [ > { > data: 'holds.patron.firstname', > render: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); To test you must implement and test bug 20936, where it will be used. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 100401 [details] [review] Bug 24561: Datatables api wrapper also filter and order embedded columns This patch adds the ability to filter and order by embedded columns. To use it you must in JS: $('datatable_selector').api({datatables_options}) where datatables_options are all datatables options plus: 1. embed: [list of embeddable tables] This option adds x-koha-embed header to request. 2. header_filter: true|false This option if true sets x-koha-query header with stringyfied json of filters Oderable and searchable columns must define data option as string, otherwise filter and order won't be possible. If you must custom the output, use the render function. For example: * Don't > $('.table_selector').api({ > columns: [ > { > data: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); * Do > $('.table_selector').api({ > columns: [ > { > data: 'holds.patron.firstname', > render: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); To test you must implement and test bug 20936, where it will be used. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Created attachment 103727 [details] [review] Bug 24561: Add a Datatables api wrapper that implements filter and order embedded columns This patch adds the ability to filter and order by embedded columns. To use it you must in JS: $('datatable_selector').api({datatables_options}) where datatables_options are all datatables options plus: 1. embed: [list of embeddable tables] This option adds x-koha-embed header to request. 2. header_filter: true|false This option if true sets x-koha-query header with stringyfied json of filters Oderable and searchable columns must define data option as string, otherwise filter and order won't be possible. If you must custom the output, use the render function. For example: * Don't > $('.table_selector').api({ > columns: [ > { > data: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); * Do > $('.table_selector').api({ > columns: [ > { > data: 'holds.patron.firstname', > render: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); To test you must implement and test bug 20936, where it will be used. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment on attachment 103727 [details] [review] Bug 24561: Add a Datatables api wrapper that implements filter and order embedded columns Review of attachment 103727 [details] [review]: ----------------------------------------------------------------- ::: koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ +571,5 @@ > + } else { > + delete options.query_parameters; > + } > + > + dataSet._match = 'starts_with'; It is inconsistent with current behavior - we do filter on any port of string
Great job Augustín, I found only one small issue with this, see Comment 11
Created attachment 104037 [details] [review] Bug 24561: (follow-up) Set default matching criteria to 'contains' and add configuration option This patch adds option.criteria as an option. Possible values are 'contains', 'starts_with', 'ends_with' and 'exact'. 'contains' is the default value.
(In reply to Josef Moravec from comment #12) > Great job Augustín, I found only one small issue with this, see Comment 11 Thanks for you comments Josef, I just applied your suggestions (I hope) Please test this patch again. Cheers
Created attachment 104384 [details] [review] Bug 24561: (follow-up) Use full_numbers for pagingType We are trying to keep the current datatables behaviour so this is a trivial yet sensible change. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Created attachment 104424 [details] [review] Bug 24561: Add a Datatables api wrapper that implements filter and order embedded columns This patch adds the ability to filter and order by embedded columns. To use it you must in JS: $('datatable_selector').api({datatables_options}) where datatables_options are all datatables options plus: 1. embed: [list of embeddable tables] This option adds x-koha-embed header to request. 2. header_filter: true|false This option if true sets x-koha-query header with stringyfied json of filters Oderable and searchable columns must define data option as string, otherwise filter and order won't be possible. If you must custom the output, use the render function. For example: * Don't > $('.table_selector').api({ > columns: [ > { > data: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); * Do > $('.table_selector').api({ > columns: [ > { > data: 'holds.patron.firstname', > render: function(row, type, val, meta) { > return '<a href="'+row.link+'">'+row.holds.patron.firstname+'</a>'; > }, > orderable: true, > searchable: true > } > ] > }); To test you must implement and test bug 20936, where it will be used. Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 104425 [details] [review] Bug 24561: (follow-up) Set default matching criteria to 'contains' and add configuration option This patch adds option.criteria as an option. Possible values are 'contains', 'starts_with', 'ends_with' and 'exact'. 'contains' is the default value. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 104426 [details] [review] Bug 24561: (follow-up) Use full_numbers for pagingType We are trying to keep the current datatables behaviour so this is a trivial yet sensible change. Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Nice work everyone! Pushed to master for 20.05
missing dependencies - not backported to 19.11.x
+jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { + console.warn(message); +}; Has this been added on purpose or for debug? This is a non advertised change, switched from alert to console.log. I don't think we want that in production (better to display an alert to the end user to help them to report the relevant issue).