When updating a system preference with a dropdown that contains checkboxes, the changes are not saved in the case where there were items checked and then you try to remove all checks. An example of this is OPACHoldsIfAvailableAtPickupExceptions. Set a couple patron categories as exceptions. Save. Remove all the categories from the exception list. Save. You get a message that says 'Nothing to Save' and the changes are not made.
*** Bug 31474 has been marked as a duplicate of this bug. ***
In preferences.js, if we are dealing with multiple select type system preference we check to make sure the value is not NULL before pushing anything to the unserialized array. I think we should allow for that value to be empty/null.
Created attachment 140064 [details] [review] Bug 31364: Allow multiple select system prefernces to saved when they are empty/null TO test: 1. Have a multiple select system preference like 'OPACHoldsIfAvailableAtPickupExceptions'. 2. Set a couple patron categories as exceptions and save. 3. Remove all the categories from the exception list and save. 4. You get a message that says 'Nothing to Save' and the changes are not made. 5. Apply patch 6. Try 2-4 again, excpet this time it should save.
Created attachment 140102 [details] [review] Bug 31364: Allow multiple select system prefernces to saved when they are empty/null TO test: 1. Have a multiple select system preference like 'OPACHoldsIfAvailableAtPickupExceptions'. 2. Set a couple patron categories as exceptions and save. 3. Remove all the categories from the exception list and save. 4. You get a message that says 'Nothing to Save' and the changes are not made. 5. Apply patch 6. Try 2-4 again, excpet this time it should save. Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Adds a comma in the end of the syspref list due to it sending an empty sysref value in addition to filled ones in the query string: > MariaDB [koha_kohadev]> select * from systempreferences where variable = "OPACHoldsIfAvailableAtPickupExceptions"\G > *************************** 1. row *************************** > variable: OPACHoldsIfAvailableAtPickupExceptions > value: B,HB, > options: > explanation: List the patron categories not affected by OPACHoldsIfAvailableAtPickup if off > type: Free Since the sysref object value is an array we can just check instead whether the array is empty. Will send a patch shortly
Created attachment 140201 [details] [review] Bug 31364: Check length of the multiple syspref array instead whether it is null The multiple systempreferences are always defined as an empty array at the minimum, so in order to determine whether we need to remove all the selections from the systempreference we should check whether the array is empty and not whether the array doesn't exist. To test: 1) Set at least 1 value for OPACHoldsIfAvailableAtPickupExceptions 2) Remove all the values for OPACHoldsIfAvailableAtPickupExceptions and notice you get the message "Nothing to save" 3) Apply patch and repeat, removing all the values should work now.
Created attachment 140220 [details] [review] Bug 31364: Check length of the multiple syspref array instead whether it is null The multiple systempreferences are always defined as an empty array at the minimum, so in order to determine whether we need to remove all the selections from the systempreference we should check whether the array is empty and not whether the array doesn't exist. To test: 1) Set at least 1 value for OPACHoldsIfAvailableAtPickupExceptions 2) Remove all the values for OPACHoldsIfAvailableAtPickupExceptions and notice you get the message "Nothing to save" 3) Apply patch and repeat, removing all the values should work now. Signed-off-by: David Nind <david@davidnind.com>
*** Bug 31524 has been marked as a duplicate of this bug. ***
Created attachment 140269 [details] [review] Bug 31364: Check length of the multiple syspref array instead whether it is null The multiple systempreferences are always defined as an empty array at the minimum, so in order to determine whether we need to remove all the selections from the systempreference we should check whether the array is empty and not whether the array doesn't exist. To test: 1) Set at least 1 value for OPACHoldsIfAvailableAtPickupExceptions 2) Remove all the values for OPACHoldsIfAvailableAtPickupExceptions and notice you get the message "Nothing to save" 3) Apply patch and repeat, removing all the values should work now. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Pushed to master for 22.11. Nice work everyone, thanks!
Backported to 22.05.x for upcoming 22.05.07 release
applied to 21.11.x for 21.11.14
Doesn't affect 21.05.x, not backported. Nothing to document, marking resolved.
revert on 21.11, bug not reproduced