[Bug 42553] New: preferences.pl: Allow 'multiple_sortable' to use 'authval' source for dynamic choices
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 Bug ID: 42553 Summary: preferences.pl: Allow 'multiple_sortable' to use 'authval' source for dynamic choices Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: martin.renvoize@openfifth.co.uk QA Contact: testopia@bugs.koha-community.org The 'choices' renderer in admin/preferences.pl already supports a dynamic 'authval' source pattern, where the YAML can say: choices: authval source: SOMECATEGORY and the choices are populated from the named authorised value category at render time. The 'multiple_sortable' renderer (the SortableJS-backed drag-and-drop multi-select used by OPACAuthorIdentifiersAndInformation and ArticleRequestsSupportedFormats) does not have an equivalent. Choices must be hardcoded in the .pref YAML. This bug adds the same dynamic-source pattern to multiple_sortable so prefs needing an ordered, picker-driven multi-select of authorised values can declare: multiple_sortable: authval source: PAYMENT_TYPE Motivation: Bug 33501 (cashup amount should be configurable) needs an ordered multi-select of PAYMENT_TYPE auth values for a new CashupPaymentTypes preference. Adding it generically here means future prefs benefit too. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 --- Comment #1 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 198771 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198771&action=edit Bug 42553: preferences.pl: Allow 'multiple_sortable' to use 'authval' source The 'choices' renderer in admin/preferences.pl already supports a dynamic 'authval' source: the YAML can say choices: authval source: SOMECATEGORY and the choices are populated from the named authorised value category at render time. The 'multiple_sortable' renderer (the SortableJS-backed drag-and-drop multi-select used by OPACAuthorIdentifiersAndInformation and ArticleRequestsSupportedFormats) had no equivalent — choices had to be hardcoded in the .pref YAML. This patch adds the same dispatcher to 'multiple_sortable' so prefs needing an ordered, picker-driven multi-select of authorised values can declare: multiple_sortable: authval source: PAYMENT_TYPE Behaviour for existing prefs (which pass a hash directly to 'multiple_sortable') is unchanged — the new branch only fires when the value is a scalar. Test plan: 1. Create a temporary system preference using the new pattern, e.g. by adding to admin/preferences/accounting.pref: - pref: TestSortableAV multiple_sortable: authval source: PAYMENT_TYPE and seeding INSERT INTO systempreferences with type='Free'. 2. Visit Administration > System preferences and find the pref. 3. Verify the widget renders as a sortable list of every value in the PAYMENT_TYPE authorised value category, with checkboxes and drag handles, matching the look of OPACAuthorIdentifiersAndInformation. 4. Pick two or three, reorder them, save. 5. Reload the page and verify the order and selection are preserved. 6. With 'source' omitted or 'multiple_sortable' set to a string other than 'authval', verify the page raises a clear error. 7. Existing prefs (OPACAuthorIdentifiersAndInformation, ArticleRequestsSupportedFormats) continue to render unchanged. -- 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=42553 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |33501 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=33501 [Bug 33501] Cashup amount should be configurable -- 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=42553 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |martin.renvoize@openfifth.c |ity.org |o.uk -- 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=42553 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |david@davidnind.com --- Comment #2 from David Nind <david@davidnind.com> --- I get the first part of step 1, but not sure about the second part: and seeding INSERT INTO systempreferences with type='Free'. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Failed QA CC| |andrew@bywatersolutions.com --- Comment #3 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- (In reply to David Nind from comment #2)
I get the first part of step 1, but not sure about the second part:
and seeding INSERT INTO systempreferences with type='Free'.
The first part was less clear to me than the INSERT part :) I ran: INSERT INTO systempreferences (variable,value,type) VALUES ('TestSortableAV','','Free'); My syspref successfully saves which values I've selected, but does not save any re-ordering of the options. If I pull "Cash via SIP2" to the top of the list the page registers that the syspref has been modified and will allow me to save it, but when I reload the page the original order is restored. systempreferences.value only includes the codes of the selected payment_types, nothing about order. An additional weirdness, when I save changes to my syspref I get multiple lines in the confirmation message, one for each authorised value: Saved preference TestSortableAV_CASH Saved preference TestSortableAV_SIP00 etc -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 --- Comment #4 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Oh! It only preserves the order of the options that have been selected. That makes sense. If a value is not being used then we don't care what order it's in. The multiple messages on save are still weird, though. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |andrew@bywatersolutions.com |y.org | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |43215 --- Comment #5 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Investigated both issues raised in the comments above by tracing through this patch's test plan. 1. Reordering only persists for values that are already selected - this is expected, not a bug. In admin/preferences.pl _get_chunk(), the CHOICES list for multiple_sortable is built with: my @options = sort keys %{ $options{multiple_sortable} }; $chunk->{CHOICES} = [ map {...} uniq( @values, @options ) ]; @values is the previously saved, ordered list parsed from systempreferences.value (comma-separated); @options is every available choice, alphabetically re-sorted on every render. Order is therefore retained only for values that have actually been selected/saved - anything not selected is always shown alphabetically on the next render. This logic is unchanged by this patch (it is shared with the existing hardcoded multiple_sortable prefs such as OPACAuthorIdentifiersAndInformation), so it is working as intended. 2. The multiple "Saved preference ..." lines on save are a real quirk, but a pre-existing one in the shared checkbox/sortable widget - not something introduced by this patch. This branch's entire diff against main is the 11-line dispatcher in admin/preferences.pl; koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js is untouched. In that file, the ".preference-checkbox" change handler marks every checkbox of every checkbox-group preference on the page as "modified" (and a drag-reorder synthetically fires change() on the list's first checkbox, triggering the same thing), while KOHA.Preferences.Success() then emits one confirmation line per modified DOM element/id rather than one per underlying preference. It is reproducible today on main with OPACAuthorIdentifiersAndInformation / ArticleRequestsSupportedFormats. Filed bug 43215 (depends on this one) to track fixing the multi-message quirk separately, since it is a pre-existing widget issue rather than something this patch introduces. Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=43215 [Bug 43215] Checkbox/sortable system preferences show one 'Saved preference' message per option instead of per preference -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Failed QA |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Sponsorship status|--- |Sponsored Status|Needs Signoff |Signed Off Patch complexity|--- |Trivial patch Comma delimited| |OpenFifth list of Sponsors| |<https://openfifth.co.uk/> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #198771|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=42553 --- Comment #6 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 202896 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202896&action=edit Bug 42553: preferences.pl: Allow 'multiple_sortable' to use 'authval' source The 'choices' renderer in admin/preferences.pl already supports a dynamic 'authval' source: the YAML can say choices: authval source: SOMECATEGORY and the choices are populated from the named authorised value category at render time. The 'multiple_sortable' renderer (the SortableJS-backed drag-and-drop multi-select used by OPACAuthorIdentifiersAndInformation and ArticleRequestsSupportedFormats) had no equivalent — choices had to be hardcoded in the .pref YAML. This patch adds the same dispatcher to 'multiple_sortable' so prefs needing an ordered, picker-driven multi-select of authorised values can declare: multiple_sortable: authval source: PAYMENT_TYPE Behaviour for existing prefs (which pass a hash directly to 'multiple_sortable') is unchanged — the new branch only fires when the value is a scalar. Test plan: 1. Create a temporary system preference using the new pattern, e.g. by adding to admin/preferences/accounting.pref: - pref: TestSortableAV multiple_sortable: authval source: PAYMENT_TYPE and seeding INSERT INTO systempreferences with type='Free'. 2. Visit Administration > System preferences and find the pref. 3. Verify the widget renders as a sortable list of every value in the PAYMENT_TYPE authorised value category, with checkboxes and drag handles, matching the look of OPACAuthorIdentifiersAndInformation. 4. Pick two or three, reorder them, save. 5. Reload the page and verify the order and selection are preserved. 6. With 'source' omitted or 'multiple_sortable' set to a string other than 'authval', verify the page raises a clear error. 7. Existing prefs (OPACAuthorIdentifiersAndInformation, ArticleRequestsSupportedFormats) continue to render unchanged. Sponsored-by: OpenFifth <https://openfifth.co.uk/> Signed-off-by: Jackie Usher <jackie.usher@westsussex.gov.uk> Signed-off-by: Debbie McCarthy <debbie.mccarthy@westsussex.gov.uk> Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 Andrew Fuerste-Henry <andrew@bywatersolutions.com> 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=42553 Andrew Fuerste-Henry <andrew@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #202896|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=42553 --- Comment #7 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 202978 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202978&action=edit Bug 42553: preferences.pl: Allow 'multiple_sortable' to use 'authval' source The 'choices' renderer in admin/preferences.pl already supports a dynamic 'authval' source: the YAML can say choices: authval source: SOMECATEGORY and the choices are populated from the named authorised value category at render time. The 'multiple_sortable' renderer (the SortableJS-backed drag-and-drop multi-select used by OPACAuthorIdentifiersAndInformation and ArticleRequestsSupportedFormats) had no equivalent — choices had to be hardcoded in the .pref YAML. This patch adds the same dispatcher to 'multiple_sortable' so prefs needing an ordered, picker-driven multi-select of authorised values can declare: multiple_sortable: authval source: PAYMENT_TYPE Behaviour for existing prefs (which pass a hash directly to 'multiple_sortable') is unchanged — the new branch only fires when the value is a scalar. Test plan: 1. Create a temporary system preference using the new pattern, e.g. by adding to admin/preferences/accounting.pref: - pref: TestSortableAV multiple_sortable: authval source: PAYMENT_TYPE and seeding INSERT INTO systempreferences with type='Free'. 2. Visit Administration > System preferences and find the pref. 3. Verify the widget renders as a sortable list of every value in the PAYMENT_TYPE authorised value category, with checkboxes and drag handles, matching the look of OPACAuthorIdentifiersAndInformation. 4. Pick two or three, reorder them, save. 5. Reload the page and verify the order and selection are preserved. 6. With 'source' omitted or 'multiple_sortable' set to a string other than 'authval', verify the page raises a clear error. 7. Existing prefs (OPACAuthorIdentifiersAndInformation, ArticleRequestsSupportedFormats) continue to render unchanged. Sponsored-by: OpenFifth <https://openfifth.co.uk/> Signed-off-by: Jackie Usher <jackie.usher@westsussex.gov.uk> Signed-off-by: Debbie McCarthy <debbie.mccarthy@westsussex.gov.uk> Signed-off-by: Hannah Dunne-Howrie <hdunne-howrie@westminster.gov.uk> Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 --- Comment #8 from Andrew Fuerste-Henry <andrew@bywatersolutions.com> --- Created attachment 202979 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=202979&action=edit Bug 42553: (QA Follow-up) tidy preferences.pl Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42553 Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |26.11.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=42553 --- Comment #9 from Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> --- Thanks everyone! Pushed to main for 26.11! -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org