[Koha-patches] [PATCH] Bug 10010 - Use jQueryUI Accordion to display constraints in MARC subfield editor

Owen Leonard oleonard at myacpl.org
Tue Apr 9 16:58:07 CEST 2013


The jQueryUI Accordion widget, included by default in Koha, is
well-suited to handle the kind of show/hide actions which are used in
the MARC subfield editor. This patch replaces the custom-writted JS with
jQueryUI JS and markup.

To test, load the tag subfield editor: Admin -> MARC frameworks -> MARC
structure -> Subfields -> Edit. Confirm that basic, advanced, and other
contraints panels are show/hidden correctly. Confirm that tabs work, and
that edit operations are not disrupted.
---
 .../intranet-tmpl/prog/en/css/staff-global.css     |    5 +-
 .../en/modules/admin/marc_subfields_structure.tt   |   65 ++++++++------------
 2 files changed, 29 insertions(+), 41 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
index 7613053..065e492 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
@@ -2397,7 +2397,10 @@ div.authorizedheading {
 .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
 
 /* jQuery UI Accordion */
-.ui-accordion-header { font-weight: bold; font-size : 110%; }
+.ui-accordion-header,
+.ui-widget-content .ui-accordion-header {
+    font-weight: bold; font-size : 110%;
+}
 
 video {
     width: 480px;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt
index a0177db..0d369ca 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc_subfields_structure.tt
@@ -4,32 +4,10 @@
 [% INCLUDE 'doc-head-close.inc' %]
 <script type="text/javascript">
 //<![CDATA[
-
-$(document).ready(function() {
-    $('#subfieldtabs').tabs();
-        $("a.displaymore").click(function(){
-        var link = $(this);
-        var constraints = $("#"+$(this).attr("href").replace("#",""));
-        constraints.toggle();
-            if($(constraints).is(':visible')){
-                link.html(_("Hide constraints"));
-            } else {
-                link.html(_("Display more constraints"));
-            }
+    $(document).ready(function() {
+        $( ".constraints" ).accordion();
+        $('#subfieldtabs').tabs();
     });
-});
-
-/*function displayMoreConstraint(numlayer){
-    var thisdiv = document.getElementById(numlayer);
-    if(thisdiv.getAttribute("class") == "content_hidden"){
-        thisdiv.removeAttribute('class');
-        thisdiv.setAttribute("class","content_visible");
-    } else {
-        thisdiv.removeAttribute('class');
-        thisdiv.setAttribute("class","content_hidden");
-    }
-}*/
-
 //]]>
 </script>
 </head>
@@ -71,7 +49,6 @@ $(document).ready(function() {
     <input type="hidden" name="op" value="add_validate" />
 	<input type="hidden" name="tagfield" value="[% tagfield %]" />
     <input type="hidden" name="frameworkcode" value="[% frameworkcode %]" />
-    <input type="submit" value="Save changes" />
     
     <div id="subfieldtabs" class="toptabs numbered">
    <ul>
@@ -87,9 +64,11 @@ $(document).ready(function() {
     </ul>
     
     [% FOREACH loo IN loop %] 
-        <div id="sub[% loo.urisubfieldcode %]field">
-        
-               <fieldset class="rows" style="float:none;"><legend>[% IF ( loo.new_subfield ) %]Add new subfield[% ELSE %]Basic constraints[% END %]</legend>
+        <div class="constraints" id="sub[% loo.urisubfieldcode %]field">
+
+               <h3><a href="#basic[% loo.urisubfieldcode %]">Basic constraints</a></h3>
+                    <div id="basic[% loo.urisubfieldcode %]">
+                    <fieldset class="rows">
                 	<ol>
                 		[% IF ( subfieldcode == 0 || subfieldcode ) %] 
                 		<li><span class="label">Subfield code:</span> [% loo.subfieldcode %] <input type="hidden" name="tagsubfield" value="[% loo.subfieldcode %]" /></li>
@@ -102,12 +81,13 @@ $(document).ready(function() {
                 		<li><label for="mandatory[% loo.row %]">Mandatory: </label>[% loo.mandatory %]</li>
                 		<li><label for="tab[% loo.row %]">Managed in tab: </label>[% loo.tab %] (ignore means that the subfield does not display in the record editor)</li>
                 	</ol>
-            </fieldset>
-			
-            <a class="displaymore" href="#more[% loo.urisubfieldcode %]">Display more constraints</a>
-            <div id="more[% loo.urisubfieldcode %]" style="display:none; clear: both">
-             <fieldset class="rows" style="float:none;">
-				<legend>Advanced constraints:</legend>
+                    </fieldset>
+                    </div>
+
+
+            <h3><a href="#adv[% loo.urisubfieldcode %]">Advanced constraints</a></h3>
+            <div id="adv[% loo.urisubfieldcode %]">
+            <fieldset class="rows">
                 <ol><li><label for="defaultvalue[% loo.row %]">Default value:</label>
                     <input type="text" name="defaultvalue" id="defaultvalue[% loo.row %]" value="[% loo.defaultvalue %]" /></li>
 				<li><label for="maxlength[% loo.row %]">Max length:</label><input type="text" id="maxlength[% loo.row %]" name="maxlength" value="[% loo.maxlength %]" size="4" /> (see online help)</li>
@@ -116,19 +96,24 @@ $(document).ready(function() {
                 <li><label for="link[% loo.row %]">Link:</label><input type="text" id="link[% loo.row %]" name="link" value="[% loo.link %]" size="10" maxlength="80" /> (e.g., Title or Local-Number) <span class="error"><em>NOTE: If you change this value you must ask your administrator to run misc/batchRebuildBiblioTables.pl.</em></span></li>
                 <li><label for="kohafield[% loo.row %]">Koha link:</label>[% loo.kohafield %]</li>
 			</ol>
-	</fieldset>
-	 <fieldset class="rows" style="float:none;">
-                <legend>Other Options: (choose one)</legend>
+            </fieldset>
+            </div>
+            <h3><a href="#oth[% loo.urisubfieldcode %]">Other options (choose one)</a></h3>
+            <div id="oth[% loo.urisubfieldcode %]">
+            <fieldset class="rows">
                     	<ol>
                     		<li><label for="authorised_value[% loo.row %]">Authorized value:</label>[% loo.authorised_value %]</li>
                     		<li><label for="authtypecode[% loo.row %]">Thesaurus:</label>[% loo.authtypes %]</li>
                     		<li><label for="value_builder[% loo.row %]">Plugin:</label>[% loo.value_builder %]</li>
                     	</ol>
-				</fieldset>
-            </div><br class="clear" /><!-- /more  -->
+            </fieldset>
+            </div>
         </div><!-- /content_sub -->
         [% END %]
 		</div><!-- /content -->
+        <fieldset class="action">
+            <input type="submit" value="Save changes" /> <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=[% tagfield %]&frameworkcode=[% frameworkcode %]" class="cancel">Cancel</a>
+        </fieldset>
     </form>
 [% END %]
 
-- 
1.7.9.5


More information about the Koha-patches mailing list