Bugzilla – Attachment 156137 Details for
Bug 21173
Add hours as age unit to auto item modifications by age for damaged_on, itemlost_on and withdrawn_on fields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21173: Template and JavaScript changes
Bug-21173-Template-and-JavaScript-changes.patch (text/plain), 8.25 KB, created by
David Nind
on 2023-09-25 00:50:40 UTC
(
hide
)
Description:
Bug 21173: Template and JavaScript changes
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-09-25 00:50:40 UTC
Size:
8.25 KB
patch
obsolete
>From 199760fdb546e866e912541ade221de9694c8058 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >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 >Signed-off-by: David Nind <david@davidnind.com> >--- > .../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 22683cef3b..d79290753a 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 >@@ -83,11 +83,26 @@ > <legend>Rule <span class="rulecount">[% loop.count | html %]</span> <a href="#" class="remove_rule"><i class="fa fa-trash-can"></i> Remove this rule</a></legend> > <input type="hidden" name="unique_id" value="[% loop.count | html %]" /> <!-- FIXME on update, the unique_id should be filled --> > <div class="age"> >- <h5>Age in days</h5> >+ <h5>Age</h5> > <input class="age" type="text" inputmode="numeric" pattern="[0-9]*" value="[% rule.age | html %]" name="age_[% id | html %]" /> >+ <h5>Age unit</h5> >+ <div class="block"> >+ <select name="ageunit_[% id | html %]"> >+ <option value="">Choose an age unit</option> >+ [% FOR unit IN ageunits %] >+ [% IF rule.ageunit == unit %] >+ <option value="[% unit | html %]" selected="selected">[% unit | html %]</option> >+ [% ELSE %] >+ <option value="[% unit | html %]">[% unit | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ <span class="hint">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.</span> >+ </div> >+ > <h5>Age field</h5> > <div class="blocks"> >- <select name="agefield_[% id | html %]"> >+ <select name="agefield_[% id | html %]" onchange="unit_display()"> > <option value="">Choose an age field</option> > [% FOR field IN agefields %] > [% IF rule.agefield == field %] >@@ -158,11 +173,21 @@ > <legend>Rule <span class="rulecount"></span> <a href="#" class="remove_rule"><i class="fa fa-trash-can"></i> Remove this rule</a></legend> > <input type="hidden" name="unique_id" /> > <div class="age"> >- <h5>Age in days</h5> >+ <h5>Age</h5> > <input class="age" type="text" inputmode="numeric" pattern="[0-9]*" value="" name="age" /> >+ <h5>Age unit</h5> >+ <div class="block"> >+ <select name="ageunit"> >+ <option value="">Choose an age unit</option> >+ [% FOR unit IN ageunits %] >+ <option value="[% unit | html %]">[% unit | html %]</option> >+ [% END %] >+ </select> >+ <span class="hint">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.</span> >+ </div> > <h5>Age field</h5> > <div class="block"> >- <select name="agefield"> >+ <select name="agefield" onchange="unit_display()"> > <option value="">Choose an age field</option> > [% FOR field IN agefields %] > <option value="[% field | html %]">[% field | html %]</option> >@@ -212,6 +237,7 @@ > <thead> > <tr> > <th>Age</th> >+ <th>Age unit</th> > <th>Age field</th> > <th>Conditions</th> > <th>Substitutions</th> >@@ -222,11 +248,19 @@ > <tr> > <td> > [% IF rule.age.defined and rule.age.length > 0 %] >- <span>[% rule.age | html %] days</span> >+ <span>[% rule.age | html %]</span> > [% ELSE %] > <span>There is no age for this rule.</span> > [% END %] > </td> >+ <td> >+ [% IF rule.ageunit %] >+ [% rule.ageunit | html %] >+ [% ELSE %] >+ <!-- In case old rules do not contain an ageunit value display that 'Days' will be used --> >+ Days >+ [% END %] >+ </td> > <td> > [% 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 09c4da1fc8..c32a229e40 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.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21173
:
77547
|
77548
|
77604
|
77605
|
78917
|
79914
|
138870
|
138871
|
138872
|
138894
|
138895
|
138896
| 156137 |
156138
|
156139
|
158574
|
158575
|
160715
|
160716