[Koha-patches] [PATCH] Bug 2720 [FOLLOW-UP] Overdues which debar automatically should undebar automatically

Owen Leonard oleonard at myacpl.org
Fri Jul 5 19:11:44 CEST 2013


This follow-up to Bug 2720 makes some template changes which I think
make the interface a little more consistent and streamlined.

Instead of incorporating the manual entry form into the table it is
broken out and follows standard form structure. This lets the table be
hidden altogether if there are no existing restrictions.

The manual entry form is hidden by default and shown when you click a
link to add a manual restriction.

These changes have been applied to both the include file used for
circulation and patron detail and to the patron entry form template.

To test, add and remove manual restrictions from the circulation page,
the patron detail page, and the patron edit page. All operations should
work correctly.
---
 .../prog/en/includes/borrower_debarments.inc       |  115 +++++++++++---------
 .../prog/en/modules/members/memberentrygen.tt      |   94 +++++++++-------
 2 files changed, 118 insertions(+), 91 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/borrower_debarments.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/borrower_debarments.inc
index 9cef519..d85c19c 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/borrower_debarments.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/borrower_debarments.inc
@@ -1,64 +1,73 @@
 <script type="text/javascript">
    //<![CDATA[
-
-        function confirm_remove_restriction() {
-            return confirm(_("Remove restriction?"));
-        }
-
+        $(document).ready(function(e){
+            $("#remove_restriction").on("click",function(){
+                return confirm(_("Remove restriction?"));
+            });
+            var mrform = $("#manual_restriction_form");
+            var mrlink = $("#add_manual_restriction");
+            mrform.hide();
+            mrlink.on("click",function(e){
+                $(this).hide();
+                mrform.show();
+                e.preventDefault();
+            });
+            $("#cancel_manual_restriction").on("click",function(e){
+                mrlink.show();
+                mrform.hide();
+                e.preventDefault();
+            });
+        })
     //]]>
 </script>
 
 <div id="reldebarments">
-    [% UNLESS debarments %]<p>Patron is currently unrestricted.</p>[% END %]
-
-    <table>
-        <thead>
-            <tr>
-                 <th>Type</th>
-                 <th>Comment</th>
-                 <th>Expiration</th>
-                 [% IF ( CAN_user_borrowers ) %]
-                     <th> </th>
-                 [% END %]
-            </tr>
-        </thead>
-
-        <tbody>
-            [% FOREACH d IN debarments %]
+    [% IF ( debarments.size < 1 ) %]
+        <p>Patron is currently unrestricted.</p>
+    [% ELSE %]
+        <table>
+            <thead>
                 <tr>
-                    <td>[% d.type %]</td>
-                    <td>[% d.comment %]</td>
-                    <td>[% IF d.expiration %] [% d.expiration | $KohaDates %] [% ELSE %] <i>Indefinite</i> [% END %]</td>
-                    [% IF ( CAN_user_borrowers )%]
-                        <td>
-                            <a href="/cgi-bin/koha/members/mod_debarment.pl?borrowernumber=[% borrowernumber %]&borrower_debarment_id=[% d.borrower_debarment_id %]&action=del" onclick="return confirm_remove_restriction()">
-                                Remove
-                            </a>
-                        </td>
-                    [% END %]
+                     <th>Type</th>
+                     <th>Comment</th>
+                     <th>Expiration</th>
+                     [% IF ( CAN_user_borrowers ) %]
+                         <th> </th>
+                     [% END %]
                 </tr>
-            [% END %]
-        </tbody>
-
-        [% IF ( CAN_user_borrowers )%]
-            <form method="post" action="/cgi-bin/koha/members/mod_debarment.pl">
-                <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
-                <input type="hidden" name="action" value="add" />
-
-                <tfoot>
+            </thead>
+            <tbody>
+                [% FOREACH d IN debarments %]
                     <tr>
-                        <td>MANUAL</td>
-                        <td><input type="text" name="comment" /></td>
-                        <td>
-                            <input name="expiration" id="expiration" size="10" readonly="readonly" value="" class="datepicker" />
-                            <a href='#' onclick="document.getElementById('expiration').value='';">Clear Date</a>
-                        </td>
-                        <td>
-                            <input type="submit" value="Add restriction" />
-                        </td>
+                        <td>[% d.type %]</td>
+                        <td>[% d.comment %]</td>
+                        <td>[% IF d.expiration %] [% d.expiration | $KohaDates %] [% ELSE %] <i>Indefinite</i> [% END %]</td>
+                        [% IF ( CAN_user_borrowers )%]
+                            <td>
+                                <a id="remove_restriction" href="/cgi-bin/koha/members/mod_debarment.pl?borrowernumber=[% borrowernumber %]&borrower_debarment_id=[% d.borrower_debarment_id %]&action=del">
+                                    Remove
+                                </a>
+                            </td>
+                        [% END %]
                     </tr>
-                </tfoot>
-            </form>
-        [% END %]
-    </table>
+                [% END %]
+            </tbody>
+        </table>
+    [% END %]
+    <p><a href="#" id="add_manual_restriction">Add manual restriction</a></p>
+    [% IF ( CAN_user_borrowers )%]
+        <form method="post" action="/cgi-bin/koha/members/mod_debarment.pl" class="clearfix">
+            <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
+            <input type="hidden" name="action" value="add" />
+            <fieldset class="rows" id="manual_restriction_form">
+                <legend>Add manual restriction</legend>
+                <ol>
+                    <li><label for="rcomment">Comment:</label> <input type="text" id="rcomment" name="comment" /></li>
+                    <li><label for="rexpiration">Expiration:</label> <input name="expiration" id="rexpiration" size="10" readonly="readonly" value="" class="datepicker" />
+                        <a href='#' onclick="document.getElementById('expiration').value='';">Clear date</a></li>
+                </ol>
+            <fieldset class="action"><input type="submit" value="Add restriction" /> <a href="#" class="cancel" id="cancel_manual_restriction">Cancel</a></fieldset>
+            </fieldset>
+        </form>
+    [% END %]
 </div>
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
index dd60dfc..749e1f8 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt
@@ -35,6 +35,23 @@
         [% END %]
         $("#dateofbirth").datepicker({ maxDate: "-1D" });
         $("#entryform").preventDoubleFormSubmit();
+
+        var mrform = $("#manual_restriction_form");
+        var mrlink = $("#add_manual_restriction");
+        mrform.hide();
+        mrlink.on("click",function(e){
+            $(this).hide();
+            mrform.show();
+            e.preventDefault();
+        });
+        $("#cancel_manual_restriction").on("click",function(e){
+            $('#debarred_expiration').val('');
+            $('#add_debarment').prop('checked', false);
+            $('#debarred_comment').val('');
+            mrlink.show();
+            mrform.hide();
+            e.preventDefault();
+        });
     });
 
     function clear_entry(node) {
@@ -1296,50 +1313,51 @@
 
 			</ol>
 			</fieldset>
-    
+
               <fieldset class="rows">
                 <legend>Patron restrictions</legend>
 
-                [% UNLESS debarments %]<p>Patron is currently unrestricted.</p>[% END %]
-
-                <table>
-                    <thead>
-                        <tr>
-                             <th>Type</th>
-                             <th>Comment</th>
-                             <th>Expiration</th>
-                             <th>Remove?</th>
-                        </tr>
-                    </thead>
-
-                    <tbody>
-                        [% FOREACH d IN debarments %]
+                [% IF ( debarments.size < 1 ) %]
+                    <p>Patron is currently unrestricted.</p>
+                [% ELSE %]
+                    <table>
+                        <thead>
                             <tr>
-                                <td>[% d.type %]</td>
-                                <td>[% d.comment %]</td>
-                                <td>[% IF d.expiration %] [% d.expiration | $KohaDates %] [% ELSE %] <i>Indefinite</i> [% END %]</td>
-                                <td>
-                                    <input type="checkbox" id="debarment_[% d.borrower_debarment_id %]" name="remove_debarment" value="[% d.borrower_debarment_id %]" />
-                                </td>
+                                 <th>Type</th>
+                                 <th>Comment</th>
+                                 <th>Expiration</th>
+                                 <th>Remove?</th>
                             </tr>
-                        [% END %]
-                    </tbody>
+                        </thead>
+
+                        <tbody>
+                            [% FOREACH d IN debarments %]
+                                <tr>
+                                    <td>[% d.type %]</td>
+                                    <td>[% d.comment %]</td>
+                                    <td>[% IF d.expiration %] [% d.expiration | $KohaDates %] [% ELSE %] <i>Indefinite</i> [% END %]</td>
+                                    <td>
+                                        <input type="checkbox" id="debarment_[% d.borrower_debarment_id %]" name="remove_debarment" value="[% d.borrower_debarment_id %]" />
+                                    </td>
+                                </tr>
+                            [% END %]
+                        </tbody>
+                    </table>
+                [% END %]
+                    <p><a href="#" id="add_manual_restriction">Add manual restriction</a></p>
+                    <fieldset id="manual_restriction_form">
+                        <input type="hidden" id="add_debarment" name="add_debarment" value="1" />
+                        <legend>Add manual restriction</legend>
+                        <ol>
+                            <li><label for="debarred_comment">Comment: </label><input type="text" id="debarred_comment" name="debarred_comment" onchange="$('#add_debarment').prop('checked', true);" /></li>
+                            <li><label for="debarred_expiration">Expiration: </label><input name="debarred_expiration" id="debarred_expiration" size="10" readonly="readonly" value="" class="datepicker" onchange="$('#add_debarment').prop('checked', true);" />
+                                    <a href='javascript:void(0)' onclick="$('#debarred_expiration').val('');">Clear date</a></li>
 
-                    <tfoot>
-                        <tr>
-                            <td>
-                                Add new
-                                <input type="checkbox" id="add_debarment" name="add_debarment" value="1" />
-                            </td>
-                            <td><input type="text" id="debarred_comment" name="debarred_comment" onchange="$('#add_debarment').prop('checked', true);" /></td>
-                            <td>
-                                <input name="debarred_expiration" id="debarred_expiration" size="10" readonly="readonly" value="" class="datepicker" onchange="$('#add_debarment').prop('checked', true);" />
-                                <a href='javascript:void(0)' onclick="$('#debarred_expiration').val('');">Clear date</a>
-                            </td>
-                            <td><a class="btn" href='javascript:void(0)' onclick="$('#debarred_expiration').val(''); $('#add_debarment').prop('checked', false); $('#debarred_comment').val('');">Clear new restriction</a></td>
-                        </tr>
-                    </tfoot>
-                </table>
+                        </ol>
+                        <p>
+                            <a class="cancel" id="cancel_manual_restriction" href="#" onclick="">Cancel</a>
+                        </p>
+                    </fieldset>
             </fieldset>
 		[% END %]
 
-- 
1.7.9.5


More information about the Koha-patches mailing list