From 3b0109537849c6c23535b447254922072729ad05 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 16 Jan 2013 16:51:13 +0100 Subject: [PATCH] Bug 4354: Cannot edit existing issuing rules 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. The original author of this patch is Owen Leonard Test Plan: * Edit an existing circulation rule * Delete a circulation rule * Create a new circulation rule * Create a new circulation rule that is a dup of an old one and make sure that it still overwrites the old rule like before Signed-off-by: Nicole C. Engard All tests passed. Signed-off-by: Kyle M Hall Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer Comments on last patch. Signed-off-by: Jared Camins-Esakov --- .../prog/en/modules/admin/smart-rules.tt | 96 ++++++++++++++----- 1 file changed, 73 insertions(+), 23 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index 586d72feb4..76f54a2334 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -9,6 +9,50 @@ $(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,''); + var current = $("#default-circulation-rules tr:last td:eq("+i+")"); + if ( i != 5 ) { + $(current).find("input").val(itm); + // select the corresponding option + $(current).find("select option").each(function(){ + if ( $(this).text().toLowerCase() == itm.toLowerCase() ) { + $(this).attr('selected', 'selected'); + } + }); + if ( i == 0 || i == 1 ) { + // Disable the 2 first columns, we cannot update them. + var val = $(current).find("select option:selected").val(); + var name = "categorycode"; + if ( i == 1 ) { + name="itemtype"; + } + // Remove potential previous input added + $(current).find("input").remove(); + $(current).append(""); + } + } else { + // specific processing for the Hard due date column + var s = itm.split(' '); + var select_value; + if ( s[0] == "before" ) { + select_value = -1 + } else if ( s[0] == "on" ) { + select_value = 0 + } else if ( s[0] == "after" ) { + select_value = 1 + } + $(current).find("input").val(s[1]); + $(current).find("select").val(select_value); + } + }); + $("#default-circulation-rules tr:last td:eq(0) select").attr('disabled', 'disabled'); + $("#default-circulation-rules tr:last td:eq(1) select").attr('disabled', 'disabled'); + $("#default-circulation-rules tr:last td:last input").val(_("Save")); + return false; + }); }); //]]> @@ -57,11 +101,12 @@ $(document).ready(function() { [% IF ( definedbranch ) %]
-
[% END %] + [% END %]
- + +
@@ -76,8 +121,8 @@ for="tobranch">Clone these rules to:  [% FOREACH rule IN rules %] [% UNLESS ( loop.odd ) %] @@ -122,6 +167,7 @@ for="tobranch">Clone these rules to:Edit @@ -129,7 +175,7 @@ for="tobranch">Clone these rules to: + + - - + + - + - - - - - - - - - + + + + + + + + +
Patron category Item type
Delete - - + + + + +
[% INCLUDE 'date-format.inc' %]
+ + +
-- 2.39.5