| Summary: | Handling NULL data in ajax calls for cities | ||
|---|---|---|---|
| Product: | Koha | Reporter: | Thibaud Guillot (thibaud_g) <thibaud.guillot> |
| Component: | Circulation | Assignee: | Thibaud Guillot (thibaud_g) <thibaud.guillot> |
| Status: | Needs documenting --- | QA Contact: | Martin Renvoize (ashimema) <martin.renvoize> |
| Severity: | normal | ||
| Priority: | P5 - low | CC: | baptiste.wojtkowski, fridolin.somers, gmcharlt, kyle, lucas, martin.renvoize, victor, wainuiwitikapark |
| Version: | Main | ||
| Hardware: | All | ||
| OS: | All | ||
| GIT URL: | Initiative type: | --- | |
| Sponsorship status: | --- | Crowdfunding goal: | 0 |
| Patch complexity: | Trivial patch | Documentation contact: | |
| Documentation submission: | Text to go in the release notes: | ||
| Version(s) released in: |
24.11.00,24.05.04,23.11.09
|
Circulation function: | |
| Bug Depends on: | |||
| Bug Blocks: | 37492 | ||
| Attachments: |
Bug 36196 : Handling NULL data on ajax call
Bug 36196: Handling NULL data on ajax call Bug 36196: Handling NULL data on ajax call Bug 36196: Handling NULL data on ajax call |
||
|
Description
Thibaud Guillot (thibaud_g)
2024-02-28 15:18:30 UTC
Created attachment 162535 [details] [review] Bug 36196 : Handling NULL data on ajax call Test plan: 1) Update some data in your cities table, sample for one send: "UPDATE cities SET city_state=NULL WHERE cityid=<id>" 2) Go on "/cgi-bin/koha/admin/cities.pl" and wait a entire life :) 3) Apply this patch 4) Rebuild your po files if needed 5) Reload the same page and now you get normally the datatable Sponsored by : BibLibre Created attachment 162551 [details] [review] Bug 36196: Handling NULL data on ajax call Test plan: 1) Update some data in your cities table, sample for one send: "UPDATE cities SET city_state=NULL WHERE cityid=<id>" 2) Go on "/cgi-bin/koha/admin/cities.pl" and wait a entire life :) 3) Apply this patch 4) Rebuild your po files if needed 5) Reload the same page and now you get normally the datatable Sponsored by : BibLibre Created attachment 162552 [details] [review] Bug 36196: Handling NULL data on ajax call Test plan: 1) Update some data in your cities table, sample for one send: "UPDATE cities SET city_state=NULL WHERE cityid=<id>" 2) Go on "/cgi-bin/koha/admin/cities.pl" and wait a entire life :) 3) Apply this patch 4) Rebuild your po files if needed 5) Reload the same page and now you get normally the datatable Sponsored by : BibLibre Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> This seem to be the proper way to handle null values: https://stackoverflow.com/questions/48917064/how-do-you-properly-handle-null-values-in-datatables/48920248#48920248 Hopefully that works in our case. From reading quickly: Adding «"defaultContent": ""» And maybe having to change our "targets" value if for some reason it only work with '_all' (and that we somehow can get away without [0,1,2,3,4]) Another source: https://stackoverflow.com/questions/57711349/how-to-deal-with-null-values-in-jquery-datatable-when-using-ajax/57714479#57714479 --- And another. According to the usage of defaultContent there, we can even target individual columns for default values: https://datatables.net/forums/discussion/50823/handling-null-values So it seems pretty sure we can use that. Hi, Thanks Victor for your feedback, I think that will be better too... to be honest I look into the code and I found the same behavior in identity_providers.tt#L419.. I will modify this Hello,
The way this fixes the behaviour for default seems standard in koha :
koha@koha-dev:~/src$ git grep -C1 "return data.escapeHtml();"
koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt- if ( data != null ) {
koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt: return data.escapeHtml();
koha-tmpl/intranet-tmpl/prog/en/modules/admin/branches.tt- }
--
koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt- if ( type == 'display' ) {
koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt: return data.escapeHtml();
koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt- }
--
koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_provider_domains.tt- if ( data != null ) {
koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_provider_domains.tt: return data.escapeHtml();
koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_provider_domains.tt- }
--
koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_provider_domains.tt- if ( data != null ) {
koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_provider_domains.tt: return data.escapeHtml();
koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_provider_domains.tt- }
--
koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_providers.tt- if ( data != null ) {
koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_providers.tt: return data.escapeHtml();
koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_providers.tt- }
--
koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt- if ( data != null ) {
koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt: return data.escapeHtml();
koha-tmpl/intranet-tmpl/prog/en/modules/admin/smtp_servers.tt- }
--
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt- if ( data != null ) {
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt: return data.escapeHtml();
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt- }
--
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt- if ( data && type == 'display' ) {
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt: return data.escapeHtml();
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt- }
--
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt- if (data != null) {
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt: return data.escapeHtml();
koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt- } else {
--
koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt- if ( data != null ) {
koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt: return data.escapeHtml();
koha-tmpl/intranet-tmpl/prog/en/modules/tools/quotes.tt- }
Since this ticket aims at fixing a broken functionnality, couldn't we just pass QA for this one and consider changing the way it works in general in another ticket ?
Created attachment 169699 [details] [review] Bug 36196: Handling NULL data on ajax call Test plan: 1) Update some data in your cities table, sample for one send: "UPDATE cities SET city_state=NULL WHERE cityid=<id>" 2) Go on "/cgi-bin/koha/admin/cities.pl" and wait a entire life :) 3) Apply this patch 4) Rebuild your po files if needed 5) Reload the same page and now you get normally the datatable Sponsored by: BibLibre Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Passing QA here and moved the discussion around defaultContent to a new wider bug.. we should certainly consider it. Thanks for all the hard work! Pushed to main for the next 24.11.00 release as RM Assistant Thanks Martin, I was considering not blocking on that issue and letting other QA people chip in, you rear my mind :) And thanks for the new ticket. > The way this fixes the behaviour for default seems standard in koha : (In reply to Baptiste Wojtkowski (bwoj) from comment #7) We have a lot of unofficial standards and sometimes it's a trap ^^" Backported to 24.05.x for upcoming 24.05.04 Pushed to 23.11.x for 23.11.09 Not backporting to 23.05.x unless requested Not backporting to 22.11 unless requested |