[Bug 42309] New: JS error when there are no cash registers
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 Bug ID: 42309 Summary: JS error when there are no cash registers Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Staff interface Assignee: koha-bugs@lists.koha-community.org Reporter: caroline.cyr-la-rose@inlibro.com QA Contact: testopia@bugs.koha-community.org CC: gmcharlt@gmail.com When you access the cash registers page and there are no cash registers yet, there is a JavaScript error in the console Uncaught TypeError: can't access property "DataTable", crtable is undefined To recreate: 0. Make sure there are no cash registers in the database (reset_all if using ktd, or delete them) 1. Enable UseCashRegisters 1.1. Go to Administration > System preferences 1.2. Search for UseCashRegisters 1.3. Set UseCashRegisters to Use 1.4. Click Save all Accounting preferences 2. Open the browser developer tools (F12) and select the Console tab 3. Go to Administration > Cash registers --> Uncaught TypeError: can't access property "DataTable", crtable is undefined -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff Assignee|koha-bugs@lists.koha-commun |caroline.cyr-la-rose@inlibr |ity.org |o.com Patch complexity|--- |Trivial patch -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 --- Comment #1 from Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> --- Created attachment 196944 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196944&action=edit Bug 42309: JS error when there are no cash registers This patch corrects a JavaScript error that appears on the cash registers page when there are no cash registers yet. To test : BEFORE applying the patch 0. Make sure there are no cash registers in the database (reset_all if using ktd, or delete them) 1. Enable UseCashRegisters 1.1. Go to Administration > System preferences 1.2. Search for UseCashRegisters 1.3. Set UseCashRegisters to Use 1.4. Click Save all Accounting preferences 2. Open the browser developer tools (F12) and select the Console tab 3. Go to Administration > Cash registers --> Uncaught TypeError: can't access property "DataTable", crtable is undefined 4. Apply the patch 5. Refresh the cash registers page --> The error is gone! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://bugs.koha-community | |.org/bugzilla3/show_bug.cgi | |?id=42277 --- Comment #2 from Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> --- I made the same correction as Jonathan did in bug 42277. (Copying without really understanding what I'm doing, so please let me know if this is not correct! But I figured I could manage a 1-character modification...) -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196944|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 --- Comment #3 from David Nind <david@davidnind.com> --- Created attachment 196966 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196966&action=edit Bug 42309: JS error when there are no cash registers This patch corrects a JavaScript error that appears on the cash registers page when there are no cash registers yet. To test : BEFORE applying the patch 0. Make sure there are no cash registers in the database (reset_all if using ktd, or delete them) 1. Enable UseCashRegisters 1.1. Go to Administration > System preferences 1.2. Search for UseCashRegisters 1.3. Set UseCashRegisters to Use 1.4. Click Save all Accounting preferences 2. Open the browser developer tools (F12) and select the Console tab 3. Go to Administration > Cash registers --> Uncaught TypeError: can't access property "DataTable", crtable is undefined 4. Apply the patch 5. Refresh the cash registers page --> The error is gone! Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|enhancement |normal CC| |david@davidnind.com Text to go in the| |This fixes a JavaScript release notes| |error in the browser | |console when there are no | |cash registers | |(Administration > | |Accounting > Cash | |registers): | | | |Uncaught TypeError: can't | |access property | |"DataTable", crtable is | |undefined -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 Brendan Lawlor <blawlor@clamsnet.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |blawlor@clamsnet.org Assignee|caroline.cyr-la-rose@inlibr |blawlor@clamsnet.org |o.com | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 Brendan Lawlor <blawlor@clamsnet.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 Brendan Lawlor <blawlor@clamsnet.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196966|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 --- Comment #4 from Brendan Lawlor <blawlor@clamsnet.org> --- Created attachment 197709 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=197709&action=edit Bug 42309: JS error when there are no cash registers This patch corrects a JavaScript error that appears on the cash registers page when there are no cash registers yet. To test : BEFORE applying the patch 0. Make sure there are no cash registers in the database (reset_all if using ktd, or delete them) 1. Enable UseCashRegisters 1.1. Go to Administration > System preferences 1.2. Search for UseCashRegisters 1.3. Set UseCashRegisters to Use 1.4. Click Save all Accounting preferences 2. Open the browser developer tools (F12) and select the Console tab 3. Go to Administration > Cash registers --> Uncaught TypeError: can't access property "DataTable", crtable is undefined 4. Apply the patch 5. Refresh the cash registers page --> The error is gone! Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 --- Comment #5 from Brendan Lawlor <blawlor@clamsnet.org> --- (In reply to Caroline Cyr La Rose from comment #2)
I made the same correction as Jonathan did in bug 42277. (Copying without really understanding what I'm doing, so please let me know if this is not correct! But I figured I could manage a 1-character modification...)
This is called the optional chaining operator. It's used like the . operator for accessing an object's properties or calls to a function. It can be used when the property or the function might not be available, then it returns undefined instead of throwing an error. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/... So in this case when there's no cash registers then the variable crtable isn't initialized and isn't able to call the function DataTable() without returning an error. Test note: It's cool how in the console error the link to cash_registers shows you exactly where the optional chaining was needed, even though the line numbers look way different. Uncaught TypeError: Cannot read properties of undefined (reading 'DataTable') at HTMLDocument.<anonymous> (cash_registers.pl:1612:38) Nice work! Passing QA -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 --- Comment #6 from Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com> --- (In reply to Brendan Lawlor from comment #5)
(In reply to Caroline Cyr La Rose from comment #2)
I made the same correction as Jonathan did in bug 42277. (Copying without really understanding what I'm doing, so please let me know if this is not correct! But I figured I could manage a 1-character modification...)
This is called the optional chaining operator. It's used like the . operator for accessing an object's properties or calls to a function. It can be used when the property or the function might not be available, then it returns undefined instead of throwing an error. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/ Optional_chaining
So in this case when there's no cash registers then the variable crtable isn't initialized and isn't able to call the function DataTable() without returning an error.
Thanks for the explanation Brendan! -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |26.05.00 released in| | Status|Passed QA |Pushed to main -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 --- Comment #7 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Nice work everyone! Pushed to main for 26.05 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 Jacob O'Mara <jacob.omara@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|26.05.00 |26.05.00,25.11.05 released in| | Status|Pushed to main |Pushed to stable -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42309 --- Comment #8 from Jacob O'Mara <jacob.omara@openfifth.co.uk> --- Thanks all, pushed to 25.11.x -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org