When editing transport-cost-matrix, it will save the numbers but not if you've enabled transfers. It also doesn't reflect disabled/enabled correctly from the database, so if you go in and make changes it re-disables them. To recreate: 1. Turn on the UseTransportCostMatrix system preference 2. Got to Administration/transport cost matrix 3. Edit a number of boxes to add numbers and uncheck the 'disabled' box 4. save 5. Observe that all (or most?) of the boxes are still disabled. 6. Run a report: select * from transport_cost where cost !='0.00' 7. Observe that they are disabled. 8. in koha-mysql: update transport_cost set disable_transfer = 0 where cost !=0.00; 9. Repeat step 6, they should have 0 instead of 1 for disable_transfer 10. Navigate to the transport cost matrix (don't refresh the page!) 11. Observe that the boxes are still disabled 12. Save (no changes needed) 13. Repeat step 6 14. Observe they are once again marked as disable_transfer 1
Created attachment 187117 [details] [review] Bug 40655: Fix logic of adding the disabled class
Created attachment 187218 [details] [review] Bug 40655: Fix logic of adding the disabled class Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This fixes the two issues described by Lisette, but there is still a bad bug with saving the matrix. To recreate: 1. Apply the patch 2. Enable UseTransportCostMatrix and go to Administration > Transport cost matrix 3. Click in a box, uncheck disable, add a number and click save > The number saves as expected 4. In the same box click again, check disable and click save > Disabled is saved, but the number is not 5. In the same box click again, uncheck disabled and click save > This time when the page loads that cell can't be edited anymore and you get an error like: There were problems with your submission Invalid value for Centerville -> Fairfield 6. Refresh the page, same error and you still can't edit that cell. The user can break the ability to edit any cell like this. For number 4, is the value supposed to be cleared when you disable it? The function check_transport_cost(e) only runs on blur. That doesn't prevent the user from clicking the save button when there's an empty value there and that breaks the way the form is rendered. This may be a separate bug , but even if the alert pops up, the user can just ignore it and put any string value and click save, it's not doing proper form validation.
(In reply to Brendan Lawlor from comment #3) > This fixes the two issues described by Lisette, but there is still a bad bug > with saving the matrix. > > To recreate: > 1. Apply the patch > 2. Enable UseTransportCostMatrix and go to Administration > Transport cost > matrix > 3. Click in a box, uncheck disable, add a number and click save > > The number saves as expected > 4. In the same box click again, check disable and click save > > Disabled is saved, but the number is not > 5. In the same box click again, uncheck disabled and click save > > This time when the page loads that cell can't be edited anymore > and you get an error like: > There were problems with your submission > Invalid value for Centerville -> Fairfield > 6. Refresh the page, same error and you still can't edit that cell. The user > can break the ability to edit any cell like this. > > For number 4, is the value supposed to be cleared when you disable it? > > The function check_transport_cost(e) only runs on blur. That doesn't prevent > the user from clicking the save button when there's an empty value there and > that breaks the way the form is rendered. > > This may be a separate bug , but even if the alert pops up, the user can > just ignore it and put any string value and click save, it's not doing > proper form validation. Hey Brendan, I notice this behavior is also present as far back as 24.11.x. I also wondered if the value should be lost when we disable it. Since the bugfix in the patch is bad, libraries cannot edit their TCM, can we file this as a seperate bug and get this one in ASAP?
Created attachment 187396 [details] [review] Bug 40655: Fix logic of adding the disabled class Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
I filed a new bug for the form validation issue: bug 40948
Nice work everyone! Pushed to main for 25.11
Nice work everyone! Pushed to 25.05.x
Code is correct in 24.11.x, not backported