[Koha-patches] [PATCH] [SIGNED-OFF] Proposed fix for Bug 4354, Cannot edit existing issuing rules

Nicole Engard nengard at bywatersolutions.com
Wed Jan 5 06:16:21 CET 2011


From: Owen Leonard <oleonard at myacpl.org>

This patch adds javascript which pulls the values from the
chosen row of data and populates the last row's form with
that data. Some changes have been made to the markup to
better accommodate this.

Possibly missing is some kind of visual feedback to the user
that the edit action is taking place in a different row from
where they clicked. Comments are especially welcomed on
this aspect of the interaction.

Signed-off-by: Nicole Engard <nengard at bywatersolutions.com>
---
 .../prog/en/modules/admin/smart-rules.tmpl         |   42 +++++++++++++-------
 1 files changed, 27 insertions(+), 15 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl
index 43ad653..0337e72 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tmpl
@@ -9,6 +9,16 @@ $(document).ready(function() {
         $('#branch').change(function() {
                 $('#selectlibrary').submit();
         });
+        $(".editrule").click(function(){
+            $(this).parent().parent().find("td").each(function (i) {
+                itm = $(this).text();
+                itm = itm.replace(/^\s*|\s*$/g,'');
+                $("#default-circulation-rules tr:last td:eq("+i+") input").val(itm);
+                $("#default-circulation-rules tr:last td:eq("+i+") select").val(itm);
+                $("#default-circulation-rules tr:last td:last input").val(_("Save"));
+            });
+            return false;
+        });
 });
 //]]>
 </script>
@@ -57,11 +67,12 @@ $(document).ready(function() {
             </select>
         </form>
 <!-- TMPL_IF Name="definedbranch" --><form action="/cgi-bin/koha/admin/clone-rules.pl" method="post"><label for="tobranch"><strong>Clone these rules to:</strong></label> <input type="hidden" name="frombranch" value="<!-- TMPL_VAR NAME="branch" -->" />
-            <select name="tobranch" id="tobranch"><!-- TMPL_LOOP NAME="branchloop" --><option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option><!-- /TMPL_LOOP --></select> <input type="submit" value="Clone" /></form><!-- /TMPL_IF --></fieldset>
+            <select name="tobranch" id="tobranch"><!-- TMPL_LOOP NAME="branchloop" --><option value="<!-- TMPL_VAR NAME="value" -->"><!-- TMPL_VAR NAME="branchname" --></option><!-- /TMPL_LOOP --></select> <input type="submit" value="Clone" /></form><!-- /TMPL_IF -->
 
         <form method="post" action="/cgi-bin/koha/admin/smart-rules.pl">
             <input type="hidden" name="op" value="add" />
-            <table>
+            <input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->"/>
+            <table id="default-circulation-rules">
             <tr>
                 <th>Patron Category</th>
                 <th>Item Type</th>
@@ -74,7 +85,7 @@ $(document).ready(function() {
                 <th>Renewals Allowed (count)</th>
                 <th>Holds Allowed (count)</th>
 		        <th>Rental Discount (%)</th>
-				<th>&nbsp;</th>
+				<th colspan="2">&nbsp;</th>
             </tr>
 				<!-- TMPL_LOOP NAME="rules" -->
 					<!-- TMPL_UNLESS NAME="__odd__" -->
@@ -108,6 +119,7 @@ $(document).ready(function() {
 							<td><!-- TMPL_VAR NAME="renewalsallowed" --></td>
 							<td><!-- TMPL_VAR NAME="reservesallowed" --></td>
 							<td><!-- TMPL_VAR NAME="rentaldiscount" --></td>
+                            <td><a href="#" class="editrule">Edit</a></td>
 							<td>
 								<a class="button" href="/cgi-bin/koha/admin/smart-rules.pl?op=delete&amp;itemtype=<!-- TMPL_VAR NAME="itemtype" -->&amp;categorycode=<!-- TMPL_VAR NAME="categorycode" -->&amp;branch=<!-- TMPL_VAR NAME="branch" -->">Delete</a>
 							</td>
@@ -115,7 +127,7 @@ $(document).ready(function() {
             	<!-- /TMPL_LOOP -->
                 <tr>
                     <td>
-                        <select name="categorycode">
+                        <select name="categorycode" id="categorycode">
                             <option value="*">All</option>
                         <!-- TMPL_LOOP NAME="categoryloop" -->
                             <option value="<!-- TMPL_VAR NAME="categorycode" -->"><!-- TMPL_VAR NAME="description" --></option>
@@ -123,23 +135,23 @@ $(document).ready(function() {
                         </select>
                     </td>
                     <td>
-                        <select name="itemtype" style="width:13em;">
+                        <select name="itemtype" id="matrixitemtype" style="width:13em;">
                             <option value="*">All</option>
                         <!-- TMPL_LOOP NAME="itemtypeloop" -->
                             <option value="<!-- TMPL_VAR NAME="itemtype" -->"><!-- TMPL_VAR NAME="description" --></option>
                         <!-- /TMPL_LOOP -->
                         </select>
                     </td>
-                    <td><input name="maxissueqty" size="3" /></td>
-                    <td><input name="issuelength" size="3" /> </td>
-                    <td><input name="fine" size="4" /></td>
-                    <td><input name="chargeperiod" size="2" /></td>
-                    <td><input name="firstremind" size="2" /> </td>
-                    <td><input name="finedays" size="3" /> </td>
-                    <td><input name="renewalsallowed" size="2" /></td>
-                    <td><input name="reservesallowed" size="2" /></td>
-		    <td><input name="rentaldiscount" size="2" /></td>
-                    <td><input type="hidden" name="branch" value="<!-- TMPL_VAR NAME="branch" -->"/><input type="submit" value="Add" class="submit" /></td>
+                    <td><input name="maxissueqty" id="maxissueqty" size="3" /></td>
+                    <td><input name="issuelength" id="issuelength" size="3" /> </td>
+                    <td><input name="fine" id="fine" size="4" /></td>
+                    <td><input name="chargeperiod" id="chargeperiod" size="2" /></td>
+                    <td><input name="firstremind" id="firstremind" size="2" /> </td>
+                    <td><input name="finedays" id="finedays" size="3" /> </td>
+                    <td><input name="renewalsallowed" id="renewalsallowed" size="2" /></td>
+                    <td><input name="reservesallowed" id="reservesallowed" size="2" /></td>
+		    <td><input name="rentaldiscount" size="2" id="rentaldiscount" /></td>
+                    <td colspan="2"><input type="submit" value="Save" class="submit" /></td>
                 </tr>
             </table>
         </form>
-- 
1.5.6.5



More information about the Koha-patches mailing list