[Koha-patches] [PATCH] Bug 8163 [REVISED] Click to populate XSLT preferences with "default" or empty values

Owen Leonard oleonard at myacpl.org
Thu Nov 1 19:46:10 CET 2012


This patch adds markup and JavaScript to the system preferences
interface so that the user can click "default" or "empty" to populate
an XSLT-related pref with those vaules.

To test, open system preferences for the OPAC or staff client. In
the description for an XSLT-related preference click the "default"
link to populate the field with "default." Click the "leave empty"
link to empty the field.

Revised according to Julian Maurice's suggestion for a more
generic, flexible way to implement it.
---
 .../intranet-tmpl/prog/en/js/pages/preferences.js  |   10 ++++++++++
 .../prog/en/modules/admin/preferences/opac.pref    |    4 ++--
 .../en/modules/admin/preferences/staff_client.pref |    4 ++--
 3 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js b/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js
index 93dfaac..80b0fc6 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js
+++ b/koha-tmpl/intranet-tmpl/prog/en/js/pages/preferences.js
@@ -59,6 +59,16 @@ $( document ).ready( function () {
         mark_modified.call(this);
     } );
 
+    $(".set_syspref").click(function() {
+        var s = $(this).attr('data-syspref');
+        var v = $(this).attr('data-value');
+        // populate the input with the value in data-value
+        $("#pref_"+s).val(v);
+        // pass the DOM element to trigger "modified" to enable submit button
+        mark_modified.call($("#pref_"+s)[0]);
+        return false;
+    });
+
     window.onbeforeunload = function () {
         if ( KOHA.Preferences.Modified ) {
             return MSG_MADE_CHANGES;
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 1a9fa09..2866f8d 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
@@ -59,12 +59,12 @@ OPAC:
             - 'Display OPAC results using XSLT stylesheet at: '
             - pref: OPACXSLTResultsDisplay
               class: file
-            - '<br />Options:<br />- leave empty for "no xslt"<br />- enter "default" for the default one<br />- put a path to define a xslt file<br />- put an URL for an external specific stylesheet.<br />{langcode} will be replaced with current interface language'
+            - '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="OPACXSLTResultsDisplay" data-value="">Leave empty</a> for "no xslt"</li><li>enter "<a href="#" class="set_syspref" data-syspref="OPACXSLTResultsDisplay" data-value="default">default</a>" for the default one</li><li> put a path to define a xslt file</li><li>put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language'
         -
             - 'Display OPAC details using XSLT stylesheet at: '
             - pref: OPACXSLTDetailsDisplay
               class: file
-            - '<br />Options:<br />- leave empty for "no xslt"<br />- enter "default" for the default one<br />- put a path to define a xslt file<br />- put an URL for an external specific stylesheet.<br />{langcode} will be replaced with current interface language'
+            - '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="OPACXSLTDetailsDisplay" data-value="">Leave empty</a> for "no xslt"</li><li>enter "<a href="#" class="set_syspref" data-syspref="OPACXSLTDetailsDisplay" data-value="default">default</a>" for the default one</li><li>put a path to define a xslt file</li><li>put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language'
         -
             - On pages displayed with XSLT stylesheets on the OPAC,
             - pref: DisplayOPACiconsXSLT
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref
index b6be289..d9fc21a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/staff_client.pref
@@ -59,12 +59,12 @@ Staff Client:
             - 'Display results in the staff client using XSLT stylesheet at: '
             - pref: XSLTResultsDisplay
               class: file
-            - '<br />Options:<br />- leave empty for "no xslt"<br />- enter "default" for the default one<br />- put a path to define a xslt file<br />- put an URL for an external specific stylesheet.<br />{langcode} will be replaced with current interface language'
+            - '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="XSLTResultsDisplay" data-value="">Leave empty</a> for "no xslt"</li><li>enter "<a href="#" class="set_syspref" data-syspref="XSLTResultsDisplay" data-value="default">default</a>" for the default one</li><li> put a path to define a xslt file</li><li>put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language'
         -
             - 'Display details in the staff client using XSLT stylesheet at: '
             - pref: XSLTDetailsDisplay
               class: file
-            - '<br />Options:<br />- leave empty for "no xslt"<br />- enter "default" for the default one<br />- put a path to define a xslt file<br />- put an URL for an external specific stylesheet.<br />{langcode} will be replaced with current interface language'
+            - '<br />Options:<ul><li><a href="#" class="set_syspref" data-syspref="XSLTDetailsDisplay" data-value="">Leave empty</a> for "no xslt"</li><li>enter "<a href="#" class="set_syspref" data-syspref="XSLTDetailsDisplay" data-value="default">default</a>" for the default one</li><li>put a path to define a xslt file</li><li>put an URL for an external specific stylesheet.</li></ul>{langcode} will be replaced with current interface language'
         -
             - Use the Yahoo UI libraries
             - pref: yuipath
-- 
1.7.9.5


More information about the Koha-patches mailing list