From 04c98bd57d7d5131027523477eeef351d37c6cff Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Mon, 8 Aug 2022 13:40:36 +0000 Subject: [PATCH] Bug 21173: Template and JavaScript changes Sponsored-by: Toi Ohomai Institute of Technology, New Zealand --- .../automatic_item_modification_by_age.tt | 44 ++++++++++++++++--- .../js/automatic_item_modification_by_age.js | 25 +++++++++++ 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt index 5e8864597a4..8a40076742b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/automatic_item_modification_by_age.tt @@ -89,11 +89,26 @@ Rule [% loop.count | html %] Remove this rule
-
Age in days
+
Age
+
Age unit
+
+ + Only the items.damaged_on, items.itemlost_on and items.withdrawn_on age fields can use the 'Hours unit. If not set then days will be used. +
+
Age field
- [% FOR field IN agefields %] [% IF rule.agefield == field %] @@ -164,11 +179,21 @@ Rule Remove this rule
-
Age in days
+
Age
+
Age unit
+
+ + Only items.damaged_on, items.itemlost_on and items.withdrawn_on age fields can use the 'Hours' unit. If not set then days will be used. +
Age field
- [% FOR field IN agefields %] @@ -216,6 +241,7 @@ Age + Age unit Age field Conditions Substitutions @@ -226,11 +252,19 @@ [% IF rule.age.defined and rule.age.length > 0 %] - [% rule.age | html %] days + [% rule.age | html %] [% ELSE %] There is no age for this rule. [% END %] + + [% IF rule.ageunit %] + [% rule.ageunit | html %] + [% ELSE %] + + Days + [% END %] + [% IF rule.agefield %] [% rule.agefield | html %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js b/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js index 09c4da1fc8c..c32a229e406 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js +++ b/koha-tmpl/intranet-tmpl/prog/js/automatic_item_modification_by_age.js @@ -49,9 +49,32 @@ function update_rule_count(){ }); } +function unit_display(){ + var rules = document.querySelectorAll("input[name='unique_id'"); + for (var i = 0; i < rules.length; i++) { + var rule_id = rules[i].value; + if (rule_id) { + var age_field = $("select[name='agefield_" + rule_id + "']").val(); + if ( age_field == 'items.damaged_on' + || age_field == 'items.itemlost_on' + || age_field == 'items.withdrawn_on' ) + { + $("select[name='ageunit_" + rule_id + "'] option[value='Days']").removeAttr('selected'); + + $("select[name='ageunit_" + rule_id + "']").attr("disabled", false); + } else { + $("select[name='ageunit_" + rule_id + "'] option[value='Days']").attr('selected','selected'); + $("select[name='ageunit_" + rule_id + "']").attr("disabled", true); + } + } + } +} + + $(document).ready(function() { $("#new_rule .remove_rule").hide(); $("#new_rule a.remove_block").hide(); + unit_display(); $("#rules a.remove_block").click(function(e){ e.preventDefault(); remove_block_action($(this)); @@ -75,12 +98,14 @@ $(document).ready(function() { new_rule.find("input[name='condition_value']").attr('name', 'condition_value_' + unique_id); new_rule.find("input[name='substitution_value']").attr('name', 'substitution_value_' + unique_id); new_rule.find("input[name='age']").attr('name', 'age_' + unique_id); + new_rule.find("select[name='ageunit']").attr('name', 'ageunit_' + unique_id); new_rule.find("select[name='agefield']").attr('name', 'agefield_' + unique_id); new_rule.find("input[name='unique_id']").val(unique_id); $("#rules").append(new_rule); update_rule_count(); var scrollToPoint = new_rule.position(); + unit_display(); window.scroll(0, scrollToPoint.top - $("#toolbar").height() ); if( $("#rules").find(".rule").length > 0 ) { -- 2.20.1