Bugzilla – Attachment 164421 Details for
Bug 36521
Checkbox preferences should be allowed to be submitted empty
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36521: Checkbox preferences should be allowed to be submitted empty
Bug-36521-Checkbox-preferences-should-be-allowed-t.patch (text/plain), 2.82 KB, created by
Pedro Amorim
on 2024-04-04 12:47:52 UTC
(
hide
)
Description:
Bug 36521: Checkbox preferences should be allowed to be submitted empty
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-04-04 12:47:52 UTC
Size:
2.82 KB
patch
obsolete
>From 714fc37840fc168dd575f58b58a2b78cf73cfe7f Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 4 Apr 2024 12:35:56 +0000 >Subject: [PATCH] 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. >--- > .../prog/js/pages/preferences.js | 22 +++++++++++++++---- > 1 file changed, 18 insertions(+), 4 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >index 5da43dbf572..351e42fc44e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >@@ -10,10 +10,24 @@ KOHA.Preferences = { > > let sysprefs = $(form).find('.modified').not('.preference-checkbox').toArray().reduce((map, e) => ({ ...map, [$(e).attr('name')]: [$(e).val()].flat()}), {}); > >- // language prefs >- $(form).find('.modified.preference-checkbox:checked').toArray().forEach((elt) => { >- (sysprefs[$(elt).attr('name')] = sysprefs[$(elt).attr('name')] || []).push($(elt).val()); >- }); >+ // checkbox prefs >+ let modified_boxes = $(form).find(".modified.preference-checkbox"); >+ let all_boxes_unchecked = true; >+ if (modified_boxes.length > 0) { >+ modified_boxes >+ .toArray() >+ .filter(elt => $(elt).prop("checked")) >+ .forEach(elt => { >+ all_boxes_unchecked = false; >+ (sysprefs[$(elt).attr("name")] = >+ sysprefs[$(elt).attr("name")] || []).push($(elt).val()); >+ }); >+ if (all_boxes_unchecked) { >+ modified_boxes.toArray().forEach(elt => { >+ sysprefs[$(elt).attr("name")] = []; >+ }); >+ } >+ } > > if ( !Object.keys(sysprefs).length ) { > humanMsg.displayAlert( __("Nothing to save") ); >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36521
:
164420
|
164421
|
164427