[Koha-patches] [PATCH] Bug 8906 - Improve OAI management interface

Owen Leonard oleonard at myacpl.org
Thu Oct 11 21:21:26 CEST 2012


Revising OAI configuration interface to conform to
existing interface patterns:

- Properly-formatted form rows
- "clone" and "clear" links consistent with other
  forms which use these conventions
- Improved title and breadcrumbs
- Standard save and cancel markup

New to the mappings interface: A "clear" button
to remove or empty the contents of a row. This replaces
the help text about emptying fields.

To test: view, add and edit OAI sets and mappings. Try adding
and removing multiple set descriptions and mappings.
---
 .../prog/en/modules/admin/oai_set_mappings.tt      |   48 ++++++----
 .../prog/en/modules/admin/oai_sets.tt              |   97 +++++++++-----------
 2 files changed, 74 insertions(+), 71 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_set_mappings.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_set_mappings.tt
index 1724c06..58f3807 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_set_mappings.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_set_mappings.tt
@@ -1,10 +1,19 @@
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Admin &rsaquo; OAI set mappings</title>
+<title>Koha &rsaquo; Administration &rsaquo; OAI sets &rsaquo; OAI set mappings</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <script type="text/javascript">
 //<![CDATA[
 $(document).ready(function() {
-    // Some JS
+    $("#mappingform").submit(function(){
+      hideDialogBox();
+    });
+    $("#ORbutton").live("click", function(){
+       newCondition();
+       return false;
+    });
+    $(".clear-field").live("click",function(e){
+        clearRow(e.target);
+    });
 });
 
 function newCondition() {
@@ -13,14 +22,18 @@ function newCondition() {
     $("#ORbutton").parent('td').replaceWith('<td style="text-align:center">OR</td>');
     $(tr).parent('tbody').append(clone);
 }
-
+function clearRow(link){
+    var tr = $(link).parent().parent();
+    var found = tr.find('#ORbutton');
+    if( found.length ){
+      tr.find('input[type="text"]').attr("value","");
+    } else {
+      tr.find('input[type="text"]').attr("value","").end().hide();
+    }
+}
 function hideDialogBox() {
     $('div.dialog').remove();
 }
-
-function returnToSetsPage() {
-    window.location.href = "/cgi-bin/koha/admin/oai_sets.pl";
-}
 //]]>
 </script>
 </head>
@@ -29,7 +42,7 @@ function returnToSetsPage() {
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Admin</a> &rsaquo; <a href="/cgi-bin/koha/admin/oai_set_mappings.pl?id=[% id %]">OAI set mappings</a></div>
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; <a href="/cgi-bin/koha/admin/oai_sets.pl">OAI sets</a> &rsaquo; <a href="/cgi-bin/koha/admin/oai_set_mappings.pl?id=[% id %]">OAI set mappings</a></div>
 
 <div id="doc3" class="yui-t2">
 
@@ -37,16 +50,16 @@ function returnToSetsPage() {
   <div id="yui-main">
     <div class="yui-b">
       [% IF ( mappings_saved ) %]
-        <div class="dialog">
-          <p>Mappings have been saved</p>
+        <div class="dialog message">
+          <h4>Mappings have been saved</h4>
           <p><a href="/cgi-bin/koha/admin/oai_sets.pl">Return to sets management</a></p>
         </div>
       [% END %]
       <h1>Mappings for set '[% setName %]' ([% setSpec %])</h1>
       [% UNLESS ( mappings ) %]
-        <p class="warning">Warning: no mappings defined for this set</p>
+        <div class="dialog alert"><p><strong>Warning:</strong> No mappings have been defined for this set</p></div>
       [% END %]
-      <form action="/cgi-bin/koha/admin/oai_set_mappings.pl" method="post" onsubmit="hideDialogBox();">
+      <form action="/cgi-bin/koha/admin/oai_set_mappings.pl" method="post" id="mappingform">
         <table id="mappings">
           <thead>
             <tr>
@@ -55,6 +68,7 @@ function returnToSetsPage() {
               <th>&nbsp;</th>
               <th>Value</th>
               <th>&nbsp;</th>
+              <th>&nbsp;</th>
             </tr>
           </thead>
           <tbody>
@@ -67,11 +81,12 @@ function returnToSetsPage() {
                   <td><input type="text" name="marcvalue" value="[% mapping.marcvalue %]" /></td>
                   <td style="text-align:center">
                     [% IF ( loop.last ) %]
-                      <input type="button" id="ORbutton" value="OR" onclick="newCondition()"/>
+                      <input type="button" id="ORbutton" value="OR" title="Add another condition" />
                     [% ELSE %]
                       OR
                     [% END %]
                   </td>
+                  <td><a class="clear-field" href="#">Clear</a></td>
                 </tr>
               [% END %]
             [% ELSE %]
@@ -80,17 +95,16 @@ function returnToSetsPage() {
                 <td style="text-align:center"><input type="text" name="marcsubfield" size="1" /></td>
                 <td>is equal to</td>
                 <td><input type="text" name="marcvalue" /></td>
-                <td><input type="button" id="ORbutton" value="OR" onclick="newCondition()"/></td>
+                <td><input type="button" id="ORbutton" value="OR" /></td>
+                <td><a class="clear-field" href="#">Clear</a></td>
               </tr>
             [% END %]
           </tbody>
         </table>
-        <p class="hint">Hint: to delete a line, empty at least one of the text fields in this line</p>
         <input type="hidden" name="id" value="[% id %]" />
         <input type="hidden" name="op" value="save" />
         <fieldset class="action">
-            <input type="submit" value="Save" />
-            <input type="button" value="Cancel" onclick="returnToSetsPage();" />
+            <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/oai_sets.pl">Cancel</a>
         </fieldset>
       </form>
 
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt
index 21a0c4f..6f25c71 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oai_sets.tt
@@ -1,13 +1,13 @@
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Admin &rsaquo; OAI sets</title>
+<title>Koha &rsaquo; Administration &rsaquo; [% IF ( op_new ) %]OAI sets configuration &rsaquo; Add a new OAI set[% ELSE %]OAI sets configuration[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <script type="text/javascript">
 //<![CDATA[
 function newDescField() {
-    $("#descriptionlist").append(
-        '<li>' +
-        '<textarea style="vertical-align:middle" name="description"></textarea>' +
-        '<a style="cursor:pointer" onclick="delDescField(this)">&nbsp;&times;</a>' +
+    $("#adddescription").before(
+        '<li><label>setDescription: </label>' +
+        '<textarea style="vertical-align:middle" rows="2" cols="30" name="description"></textarea>' +
+        '<a onclick="delDescField(this); return false;" class="clear-field" href="#">Remove</a>' +
         '</li>'
     );
 }
@@ -18,7 +18,7 @@ function delDescField(minusButton) {
 }
 
 $(document).ready(function() {
-    // Some JS
+    new YAHOO.widget.Button("newoaiset");
 });
 //]]>
 </script>
@@ -28,67 +28,56 @@ $(document).ready(function() {
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
 
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Admin</a> &rsaquo; OAI sets</div>
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; [% IF ( op_new ) %]<a href="http://localhost:8888/cgi-bin/koha/admin/oai_sets.pl">OAI sets configuration</a> &rsaquo; Add a new OAI set[% ELSIF ( op_mod ) %]<a href="http://localhost:8888/cgi-bin/koha/admin/oai_sets.pl">OAI sets configuration</a> &rsaquo; Modify OAI set '[% spec %]'[% ELSE %] OAI sets configuration[% END %]</div>
 
 <div id="doc3" class="yui-t2">
 
 <div id="bd">
   <div id="yui-main">
     <div class="yui-b">
-      <h1>OAI sets configuration</h1>
-
-        [% IF op_new %]
-            <h2>Add a new set</h2>
+        [% IF ( op_new || op_mod ) %]
             <form method="post" action="/cgi-bin/koha/admin/oai_sets.pl">
+            [% IF ( op_new ) %]
+                <h2>Add a new OAI set</h2>
                 <input type="hidden" name="op" value="savenew" />
-                <fieldset>
-                    <label for="spec">setSpec</label>
-                    <input type="text" id="spec" name="spec" />
-                    <br />
-                    <label for="name">setName</label>
-                    <input type="text" id="name" name="name" />
-                    <br />
-                    <label>setDescriptions</label>
-                    <ul id="descriptionlist">
-                    </ul>
-                    <a style="cursor:pointer" onclick='newDescField()'>Add description</a>
-                </fieldset>
-                <input type="submit" value="Save" />
-                <input type="button" value="Cancel" onclick="window.location.href = '/cgi-bin/koha/admin/oai_sets.pl'" />
-            </form>
-        [% ELSE %][% IF op_mod %]
-            <h2>Modify set '[% spec %]'</h2>
-            <form method="post" action="/cgi-bin/koha/admin/oai_sets.pl">
-                <input type="hidden" name="op" value="savemod" />
-                <input type="hidden" name="id" value="[% id %]" />
-                <fieldset>
-                    <label for="spec">setSpec</label>
-                    <input type="text" id="spec" name="spec" value="[% spec %]" />
-                    <br />
-                    <label for="name">setName</label>
-                    <input type="text" id="name" name="name" value="[% name %]" />
-                    <br />
-                    <label>setDescriptions</label>
-                    <ul id="descriptionlist">
+            [% ELSIF ( op_mod ) %]
+                <h2>Modify OAI set '[% spec %]'</h2>
+                    <input type="hidden" name="op" value="savemod" />
+                    <input type="hidden" name="id" value="[% id %]" />
+            [% END %]
+                <fieldset id="oaidetails" class="rows">
+                    <ol>
+                        <li>
+                            <label for="spec" class="required">setSpec: </label>
+                            <input type="text" id="spec" name="spec" value="[% spec %]" />
+                        </li>
+                        <li>
+                            <label for="name" class="required">setName: </label>
+                            <input type="text" id="name" name="name" value="[% name %]" />
+                        </li>
                         [% FOREACH desc IN descriptions %]
                             <li>
-                                <textarea style="vertical-align:middle" name="description">[% desc.description %]</textarea>
-                                <a style="cursor:pointer" onclick="delDescField(this)">&nbsp;&times;</a>
+                                <label>setDescription: </label>
+                                <textarea style="vertical-align:middle" rows="2" cols="30" name="description">[% desc.description %]</textarea>
+                                <a onclick="delDescField(this); return false;" class="clear-field" href="#">Remove</a>
                             </li>
                         [% END %]
-                    </ul>
-                    <a style="cursor:pointer" onclick='newDescField()'>Add description</a>
+                        <li id="adddescription"><span class="label">&nbsp;</span><a class="clone-field" href="#" onclick='newDescField(); return false;'>Add description</a></li>
+
+                    </ol>
+                </fieldset>
+                <fieldset class="action">
+                    <input type="submit" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/oai_sets.pl">Cancel</a>
                 </fieldset>
-                <input type="submit" value="Save" />
-                <input type="button" value="Cancel" onclick="window.location.href = '/cgi-bin/koha/admin/oai_sets.pl'" />
             </form>
-        [% END %]
-        [% END %]
+        [% ELSE %]
 
-        <h2>List of sets</h2>
-        [% UNLESS ( op_new ) %]
-            <a href="/cgi-bin/koha/admin/oai_sets.pl?op=new">Add a new set</a>
-        [% END %]
+        <div id="toolbar">
+            <ul class="toolbar">
+            <li><a id="newoaiset" href="/cgi-bin/koha/admin/oai_sets.pl?op=new">New set</a></li>
+        </ul></div>
+
+        <h2>OAI sets</h2>
         [% IF sets_loop %]
             <table>
                 <thead>
@@ -127,9 +116,9 @@ $(document).ready(function() {
                 </tbody>
             </table>
         [% ELSE %]
-            <p>There is no set defined.</p>
+            <div class="dialog message"><p>There are no sets defined.</p></div>
+        [% END %]
         [% END %]
-
 
     </div>
   </div>
-- 
1.7.9.5



More information about the Koha-patches mailing list