Bugzilla – Attachment 128133 Details for
Bug 26296
Use new table column selection modal for OPAC suggestion fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26296: (follow-up) Make sure title remains mandatory
Bug-26296-follow-up-Make-sure-title-remains-mandat.patch (text/plain), 18.00 KB, created by
Owen Leonard
on 2021-12-01 15:22:12 UTC
(
hide
)
Description:
Bug 26296: (follow-up) Make sure title remains mandatory
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2021-12-01 15:22:12 UTC
Size:
18.00 KB
patch
obsolete
>From c687f20bea9bd7977390ae3eff2877c81f97f4b2 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 8 Nov 2021 17:27:03 +0000 >Subject: [PATCH] Bug 26296: (follow-up) Make sure title remains mandatory > >This patch adds a flag to the OPAC preferences file marking suggestion >title as mandatory OPACSuggestionMandatoryFields and excluded from >OPACSuggestionUnwantedFields. > >The patch also modifies the markup around required fields in the OPAC >suggestion form to comply with changes made in Bug 27668 to mandatory >field styling. > >To test, apply the patch and restart services. > >- Test the OPACSuggestionMandatoryFields preference. In the modal, > "title" should be checked and the label in red. It should not be > possible to uncheck the checkbox. > - Test that the "Select all" and "Clear all" links don't affect the > "title" checkbox. > - Confirm that your selections are still saved correctly. >- Test the OPACSuggestionUnwantedFields preference. In the modal, > "title" should be unchecked and disabled. > - Test that the "Select all" and "Clear all" links don't affect the > "title" checkbox. > - Confirm that your selections are saved correctly. >--- > admin/preferences.pl | 1 + > .../prog/en/modules/admin/preferences.tt | 2 +- > .../en/modules/admin/preferences/opac.pref | 2 ++ > .../admin/preferences/suggestions.json | 1 + > .../prog/js/pages/preferences.js | 18 +++++++++++--- > .../bootstrap/en/modules/opac-suggestions.tt | 24 +++++++++---------- > 6 files changed, 32 insertions(+), 16 deletions(-) > >diff --git a/admin/preferences.pl b/admin/preferences.pl >index 9e697a6a03..f405419999 100755 >--- a/admin/preferences.pl >+++ b/admin/preferences.pl >@@ -62,6 +62,7 @@ sub _get_chunk { > if( $options{'type'} && $options{'type'} eq 'modalselect' ){ > $chunk->{'source'} = $options{'source'}; > $chunk->{'exclusions'} = $options{'exclusions'} // ""; >+ $chunk->{'required'} = $options{'required'} // ""; > $chunk->{'type'} = 'modalselect'; > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >index 5f52994d3f..6842a59b13 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >@@ -130,7 +130,7 @@ > [% END %] > </select> > [% ELSIF ( CHUNK.type_modalselect ) %] >- <input type="text" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="modalselect preference preference-[% CHUNK.type | html %]" data-source="[% CHUNK.source | html %]" data-exclusions="[% CHUNK.exclusions | html %]" readonly="readonly" value="[% CHUNK.value | html %]"/> >+ <input type="text" name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="modalselect preference preference-[% CHUNK.type | html %]" data-source="[% CHUNK.source | html %]" data-required="[% CHUNK.required | html %]" data-exclusions="[% CHUNK.exclusions | html %]" readonly="readonly" value="[% CHUNK.value | html %]"/> > [% ELSIF ( CHUNK.type_multiple ) %] > <select name="pref_[% CHUNK.name | html %]" id="pref_[% CHUNK.name | html %]" class="preference preference-[% CHUNK.class or "choice" | html %]" multiple="multiple"> > [% FOREACH CHOICE IN CHUNK.CHOICES %][% IF ( CHOICE.selected ) %]<option value="[% CHOICE.value | html %]" selected="selected">[% ELSE %]<option value="[% CHOICE.value | html %]">[% END %][% CHOICE.text | html %]</option>[% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index 30855701f2..82db824158 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -609,12 +609,14 @@ OPAC: > - pref: OPACSuggestionMandatoryFields > type: modalselect > source: suggestions >+ required: title > - "<br />Note: if none of the above options are selected, 'Title' field would be mandatory anyway, by default." > - > - "Fields that should be hidden for patron purchase suggestions:" > - pref: OPACSuggestionUnwantedFields > type: modalselect > source: suggestions >+ exclusions: title > - '<br />Note: Do not make <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=OPACSuggestionMandatoryFields">OPACSuggestionMandatoryFields</a> unwanted fields ' > - > - pref: OpacHiddenItems >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/suggestions.json b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/suggestions.json >index e351df2155..6eac91b149 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/suggestions.json >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/suggestions.json >@@ -1,4 +1,5 @@ > { >+ "title": "title", > "author": "author", > "copyrightdate": "copyrightdate", > "isbn": "isbn", >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >index e7d8dad01a..75a6587ac5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/preferences.js >@@ -226,13 +226,18 @@ $( document ).ready( function () { > $(".modalselect").on("click", function(){ > var datasource = $(this).data("source"); > var exclusions = $(this).data("exclusions").split('|'); >+ var required = $(this).data("required").split('|'); > var pref_name = this.id.replace(/pref_/, ''); > var pref_value = this.value; > var prefs = pref_value.split("|"); > >+ >+ > $.getJSON( themelang + "/modules/admin/preferences/" + datasource + ".json", function( data ){ > var items = []; > var checked = ""; >+ var readonly = ""; >+ var disabled = ""; > var style = ""; > $.each( data, function( key, val ){ > if( prefs.indexOf( val ) >= 0 ){ >@@ -240,7 +245,10 @@ $( document ).ready( function () { > } else { > checked = ""; > } >- if( exclusions.indexOf( val ) >= 0 ){ >+ if( required.indexOf( val ) >= 0 ){ >+ style = "required"; >+ checked = ' checked="checked" '; >+ } else if( exclusions.indexOf( val ) >= 0 ){ > style = "disabled"; > disabled = ' disabled="disabled" '; > checked = ""; >@@ -283,11 +291,15 @@ $( document ).ready( function () { > > $("#select_all").on("click",function(e){ > e.preventDefault(); >- $(".dbcolumn_selection:not(:disabled)").prop("checked", true); >+ $("label:not(.required) .dbcolumn_selection:not(:disabled)").prop("checked", true); > }); > $("#clear_all").on("click",function(e){ > e.preventDefault(); >- $(".dbcolumn_selection").prop("checked", false); >+ $("label:not(.required) .dbcolumn_selection").prop("checked", false); >+ }); >+ >+ $("body").on("click", "label.required input.dbcolumn_selection", function(e){ >+ e.preventDefault(); > }); > > } ); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >index 6510f492c6..3223653bba 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt >@@ -79,7 +79,7 @@ > [% IF ( title_required ) %] > <label for="title" class="required">Title:</label> > <input type="text" id="title" name="title" class="span6" maxlength="255" value="[% title | html %]" required="required" /> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="title">Title:</label> > <input type="text" id="title" name="title" class="span6" maxlength="255" value="[% title | html %]" /> >@@ -90,7 +90,7 @@ > [% IF ( author_required ) %] > <label for="author" class="required">Author:</label> > <input type="text" id="author" name="author" class="span6" maxlength="80" value="[% author | html %]" required="required" /> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="author">Author:</label> > <input type="text" id="author" name="author" class="span6" maxlength="80" value="[% author | html %]" /> >@@ -103,7 +103,7 @@ > [% IF ( copyrightdate_required ) %] > <label for="copyrightdate" class="required">Copyright date:</label> > <input type="text" id="copyrightdate" name="copyrightdate" pattern="[12]\d{3}" size="4" maxlength="4" value="[% copyrightdate | html %]" required="required" /> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="copyrightdate">Copyright date:</label> > <input type="text" id="copyrightdate" name="copyrightdate" pattern="[12]\d{3}" size="4" maxlength="4" value="[% copyrightdate | html %]" /> >@@ -116,7 +116,7 @@ > [% IF ( isbn_required ) %] > <label for="isbn" class="required">Standard number (ISBN, ISSN or other):</label> > <input type="text" id="isbn" name="isbn" maxlength="80" value="[% isbn | html %]" required="required" /> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="isbn">Standard number (ISBN, ISSN or other):</label> > <input type="text" id="isbn" name="isbn" maxlength="80" value="[% isbn | html %]" /> >@@ -128,7 +128,7 @@ > [% IF ( publishercode_required ) %] > <label for="publishercode" class="required">Publisher:</label> > <input type="text" id="publishercode" name="publishercode" class="span6" maxlength="80" value="[% publishercode | html %]" required="required" /> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="publishercode">Publisher:</label> > <input type="text" id="publishercode" name="publishercode" class="span6" maxlength="80" value="[% publishercode | html %]" /> >@@ -140,7 +140,7 @@ > [% IF ( collectiontitle_required ) %] > <label for="collectiontitle" class="required">Collection title:</label> > <input type="text" id="collectiontitle" name="collectiontitle" class="span6" maxlength="80" value="[% collectiontitle | html %]" required="required" /> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="collectiontitle">Collection title:</label> > <input type="text" id="collectiontitle" name="collectiontitle" class="span6" maxlength="80" value="[% collectiontitle | html %]" /> >@@ -152,7 +152,7 @@ > [% IF ( place_required ) %] > <label for="place" class="required">Publication place:</label> > <input type="text" id="place" name="place" required="required" maxlength="80" value="[% place | html %]" /> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="place">Publication place:</label> > <input type="text" id="place" name="place" maxlength="80" value="[% place | html %]" /> >@@ -164,7 +164,7 @@ > [% IF ( quantity_required ) %] > <label for="quantity" class="required">Quantity:</label> > <input type="text" id="quantity" name="quantity" required="required" maxlength="4" size="4" /> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="quantity">Quantity:</label> > <input type="text" id="quantity" name="quantity" maxlength="4" size="4" /> >@@ -176,7 +176,7 @@ > [% IF ( itemtype_required ) %] > <label for="itemtype" class="required">Item type:</label> > [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20, required = 1, blank = 1 %] >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="itemtype">Item type:</label> > [% PROCESS 'av-build-dropbox.inc' name="itemtype", category="SUGGEST_FORMAT", size = 20, blank = 1 %] >@@ -190,7 +190,7 @@ > <select name="branchcode" id="branch" required="required"> > [% PROCESS options_for_libraries libraries => Branches.all %] > </select> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="branch">Library:</label> > <select name="branchcode" id="branch"> >@@ -210,7 +210,7 @@ > <option value="[% patron_reason_loo.authorised_value | html %]">[% patron_reason_loo.lib | html %]</option> > [% END %] > </select> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="patronreason">Reason for suggestion: </label> > <select name="patronreason" id="patronreason"> >@@ -228,7 +228,7 @@ > [% IF ( note_required ) %] > <label for="note" class="required">Notes:</label> > <textarea name="note" id="note" rows="5" cols="40" required="required">[% note | html %]</textarea> >- <span class="required">Required</span> >+ <div class="required_label required">Required</div> > [% ELSE %] > <label for="note">Notes:</label> > <textarea name="note" id="note" rows="5" cols="40">[% note | html %]</textarea> >-- >2.20.1
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 26296
:
114979
|
127457
|
128132
|
128133
|
128141
|
128142
|
128143
|
128538
|
128539