From 3b0109537849c6c23535b447254922072729ad05 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 16 Jan 2013 16:51:13 +0100 Subject: [PATCH 1/6] 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' %]
+ + +
From 8367e9628b1a334e7c25917ce6761c804bc76776 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 24 Jan 2013 09:21:34 -0500 Subject: [PATCH 2/6] Bug 4354 - Followup - Add row highlighting Test plan: * Click on a row to edit * Note that the row is highlighted in orange Signed-off-by: Jonathan Druart Signed-off-by: Nicole C. Engard All tests pass. Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer Signed-off-by: Jared Camins-Esakov --- koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css | 1 + koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css index 91d0431cf7..f8d75022d1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css +++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css @@ -254,6 +254,7 @@ table+table { border : 0; } +.highlighted-row { background-color: orange !important } tr.highlight td, tr.highlight th, tr.odd td { background-color : #F3F3F3; 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 76f54a2334..6611d67a5f 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 @@ -10,7 +10,9 @@ $(document).ready(function() { $('#selectlibrary').submit(); }); $(".editrule").click(function(){ + $('#default-circulation-rules td').removeClass('highlighted-row'); $(this).parent().parent().find("td").each(function (i) { + $(this).addClass('highlighted-row'); itm = $(this).text(); itm = itm.replace(/^\s*|\s*$/g,''); var current = $("#default-circulation-rules tr:last td:eq("+i+")"); From 4243b517214f95964c69da269d75f1746b5c897f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 18 Mar 2013 12:41:56 +0100 Subject: [PATCH 3/6] Bug 4354: Followup Add a Cancel button New cancel button on the edit row. Add a prevent message when editing a new row. Signed-off-by: Katrin Fischer Signed-off-by: Jared Camins-Esakov --- .../prog/en/modules/admin/smart-rules.tt | 70 +++++++++++++------ 1 file changed, 48 insertions(+), 22 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 6611d67a5f..b236e9af19 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 @@ -4,36 +4,58 @@ [% INCLUDE 'calendar.inc' %]