Bug 36521

Summary: Checkbox preferences should be allowed to be submitted empty
Product: Koha Reporter: Pedro Amorim <pedro.amorim>
Component: Architecture, internals, and plumbingAssignee: Pedro Amorim <pedro.amorim>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: fridolin.somers, jonathan.druart, martin.renvoize, nick, oleonard, phil, tomascohen
Version: Main   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
24.05.00
Circulation function:
Bug Depends on:    
Bug Blocks: 35604    
Attachments: Bug 36521: Checkbox preferences should be allowed to be submitted empty
Bug 36521: Checkbox preferences should be allowed to be submitted empty
Bug 36521: Checkbox preferences should be allowed to be submitted empty

Description Pedro Amorim 2024-04-04 12:46:13 UTC

    
Comment 1 Pedro Amorim 2024-04-04 12:47:09 UTC Comment hidden (obsolete)
Comment 2 Pedro Amorim 2024-04-04 12:47:52 UTC
Created attachment 164421 [details] [review]
Bug 36521: Checkbox preferences should be allowed to be submitted empty

Visit:
http://localhost:8081/cgi-bin/koha/admin/preferences.pl?tab=i18n_l10n

Uncheck English on both 'language' and 'OPACLanguages'. Save.
Notice "Nothing to save" shows.
Apply patch. Repeat. Notice you can now save with all options empty.

To my knowledge, these 2 language preferences are the only checkbox preferences of this kind (correct me
if I'm wrong please).

I need to add a new system preference for bug 35604 listing all installed ILL backends so the user
may enable or disable each of the backends.
I want that particular system preference to be disabled as a whole if all backends are unchecked, but I was unable
to uncheck all before this patch.

I understand that for languages checkboxes specifically not allowing everything to be empty may make sense (at least
one language should be enabled, after all). But these languages checkbox preferences should be the exception, not the rule,
for this behaviour.
Comment 3 Jonathan Druart 2024-04-04 13:08:41 UTC
(In reply to Pedro Amorim from comment #2)
> To my knowledge, these 2 language preferences are the only checkbox
> preferences of this kind (correct me
> if I'm wrong please).

There is this patch in the queue
https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=163699

But I don't think they will conflict.
Comment 4 Pedro Amorim 2024-04-04 14:04:00 UTC
Thanks Joubu, I was not aware of that.
I think there certainly may be some overlap there with what I'm doing in bug 35604 in regards to multiple checkboxes being sortable, although I've had to create my own 'ill_backends' system preference type (because the options I need are dynamically loaded depending on what backends are installed, not from hardcoded option values coming from a *.pref file).

I'll definitely look at bug 29948 in the near future, probably rebase my work on that and see what can be reused/improved.
Comment 5 Jonathan Druart 2024-04-04 14:43:19 UTC
Found a bug:
http://localhost:8081/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=lang

language and opaclanguage have "English"
Deselect English for language, save OK
Deselect English for opaclanguage, save => "Nothing to save" FAIL
Comment 6 Jonathan Druart 2024-04-04 14:59:44 UTC
Created attachment 164427 [details] [review]
Bug 36521: Checkbox preferences should be allowed to be submitted empty

Visit:
http://localhost:8081/cgi-bin/koha/admin/preferences.pl?tab=i18n_l10n

Uncheck English on both 'language' and 'OPACLanguages'. Save.
Notice "Nothing to save" shows.
Apply patch. Repeat. Notice you can now save with all options empty.

To my knowledge, these 2 language preferences are the only checkbox preferences of this kind (correct me
if I'm wrong please).

I need to add a new system preference for bug 35604 listing all installed ILL backends so the user
may enable or disable each of the backends.
I want that particular system preference to be disabled as a whole if all backends are unchecked, but I was unable
to uncheck all before this patch.

I understand that for languages checkboxes specifically not allowing everything to be empty may make sense (at least
one language should be enabled, after all). But these languages checkbox preferences should be the exception, not the rule,
for this behaviour.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 7 Jonathan Druart 2024-04-04 14:59:59 UTC
(In reply to Jonathan Druart from comment #5)
> Found a bug:
> http://localhost:8081/cgi-bin/koha/admin/preferences.
> pl?tab=&op=search&searchfield=lang
> 
> language and opaclanguage have "English"
> Deselect English for language, save OK
> Deselect English for opaclanguage, save => "Nothing to save" FAIL

Cache was not cleared, sorry!
Comment 8 Jonathan Druart 2024-04-04 15:00:16 UTC
Trivial, bad bug, passing QA.
Comment 9 Katrin Fischer 2024-04-05 09:53:28 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 10 Fridolin Somers 2024-05-23 09:33:22 UTC
Does not apply easy on 23.11.x.
Please provide patches if needed.
Comment 11 Pedro Amorim 2024-05-23 11:49:50 UTC
(In reply to Fridolin Somers from comment #10)
> Does not apply easy on 23.11.x.
> Please provide patches if needed.

Don't think it's needed. This is just a fix for a problem highlighted in bug 35604 where there is a need of being able to submit a checkbox preference as empty.

Prior to bug 35604 (not yet pushed) the only checkbox preference(s) that exist is the language(s) preferences afaik and those work 'fine' not being able to submit empty. Happy to be corrected.