Bug 24154 - No indication that Default checkout, hold and return policy are set if values are blank
Summary: No indication that Default checkout, hold and return policy are set if values...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Nick Clemens
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-03 17:58 UTC by Nick Clemens
Modified: 2021-12-13 21:13 UTC (History)
7 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.05.00


Attachments
Bug 24154: Get rules rather than values to determine if set or not (11.65 KB, patch)
2021-04-16 17:03 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 24154: Get rules rather than values to determine if set or not (11.70 KB, patch)
2021-04-21 13:43 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 24154: (follow-up) Make parameter and variable more explicit, add tests (8.14 KB, patch)
2021-04-23 10:35 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 24154: Adjust assignment (2.79 KB, patch)
2021-05-05 18:43 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 24154: Get rules rather than values to determine if set or not (11.76 KB, patch)
2021-05-09 13:06 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 24154: (follow-up) Make parameter and variable more explicit, add tests (8.18 KB, patch)
2021-05-09 13:06 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 24154: Adjust assignment (2.84 KB, patch)
2021-05-09 13:06 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2019-12-03 17:58:59 UTC
To recreate:
1 - Visit Admin->Circulation rules
2 - Go to a specific branch
3 - Clear all the boxes in Default checkout, hold and return policy and save
4 - No visible indication that anything is set
5 - Check the DB, (SELECT * FROM circulation_rules WHERE branchcode='BRANCH')
6 - Note there are rules
7 - Unset the rules, no visible change
8 - Check the D, rules are cleared
Comment 1 Jonathan Druart 2019-12-11 09:31:21 UTC
Nick, they ("" or nothing in DB) means the same, right?

If so we should not save them if "".
Comment 2 Nick Clemens 2021-04-16 16:58:50 UTC
(In reply to Jonathan Druart from comment #1)
> Nick, they ("" or nothing in DB) means the same, right?
> 
> If so we should not save them if "".

Not exist in the DB means fall back to other rules - exist in DB as "" means 'Unlimited'

Reason to allow:

Default for all libraries is 10
Library A wants default as unlimited

Library A can simply save the blank rule
Comment 3 Nick Clemens 2021-04-16 17:03:25 UTC
Created attachment 119767 [details] [review]
Bug 24154: Get rules rather than values to determine if set or not

Template plugin CirculationRules.Search returns "" if a rule doesn't exist or if
the rule exists but is set to ""

To get more info, we add a 'want_rule' parameter and use that to test if defined but
blank

To test:
1 - In circulation rules set the 'Default checkout, hold and return policy' without setting values
2 - Unset it
3 - Notice there is no visual difference
4 - Apply patch
5 - Reload the page
6 - note there is no 'Unset button' and first column says 'Not set'
7 - Save the rule with no values
8 - Now 'Defaults' is displayed and the unset button exists
Comment 4 Owen Leonard 2021-04-21 13:43:33 UTC
Created attachment 119950 [details] [review]
Bug 24154: Get rules rather than values to determine if set or not

Template plugin CirculationRules.Search returns "" if a rule doesn't
exist or if the rule exists but is set to ""

To get more info, we add a 'want_rule' parameter and use that to test
if defined but blank

To test:
1 - In circulation rules set the 'Default checkout, hold and return
    policy' without setting values
2 - Unset it
3 - Notice there is no visual difference
4 - Apply patch
5 - Reload the page
6 - note there is no 'Unset button' and first column says 'Not set'
7 - Save the rule with no values
8 - Now 'Defaults' is displayed and the unset button exists

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 5 Marcel de Rooy 2021-04-23 07:23:22 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2021-04-23 07:59:50 UTC
I would add a separate method for that. The additional parameter feels hacky.
Comment 7 Marcel de Rooy 2021-04-23 08:18:31 UTC Comment hidden (obsolete)
Comment 8 Marcel de Rooy 2021-04-23 08:23:56 UTC
(In reply to Jonathan Druart from comment #6)
> I would add a separate method for that. The additional parameter feels hacky.

Or I would propose at least something like:
additional_parameters instead of want_rule
and check for additional_parameters->{want_rule} 
and pass { want_rule => 1 } instead of only 1 at the end
Which is far more explanatory
Comment 9 Marcel de Rooy 2021-04-23 08:26:45 UTC
[% SET dcharp = ( patron_maxissueqty || patron_maxonsiteissueqty || rule_value || holdallowed || hold_fulfillment_policy || returnbranch ) %]

What means dcharp ?
Since it is not clear rightaway, I would suggest a better variable name here.
Maybe it's just me ?
Comment 10 Marcel de Rooy 2021-04-23 08:37:56 UTC
We need a few tests too indeed.

Moving to FQA for now
Comment 11 Nick Clemens 2021-04-23 10:35:38 UTC
Created attachment 120047 [details] [review]
Bug 24154: (follow-up) Make parameter and variable more explicit, add tests
Comment 12 Marcel de Rooy 2021-04-23 14:03:38 UTC
+                [% SET patron_maxonsiteissueqty = CirculationRules.Search( current_branch, undef, undef, 'patron_maxonsiteissueqty', { want_rule = 1 } ) %]


You probably mean: want_rule => 1 ?
Comment 13 Nick Clemens 2021-05-05 18:43:47 UTC
Created attachment 120561 [details] [review]
Bug 24154: Adjust assignment

The code seems to work either way
We have a mix in our code:
git grep "}) %]"

Using '=>' over '=' does look nicer
Comment 14 Katrin Fischer 2021-05-09 13:06:21 UTC
Created attachment 120741 [details] [review]
Bug 24154: Get rules rather than values to determine if set or not

Template plugin CirculationRules.Search returns "" if a rule doesn't
exist or if the rule exists but is set to ""

To get more info, we add a 'want_rule' parameter and use that to test
if defined but blank

To test:
1 - In circulation rules set the 'Default checkout, hold and return
    policy' without setting values
2 - Unset it
3 - Notice there is no visual difference
4 - Apply patch
5 - Reload the page
6 - note there is no 'Unset button' and first column says 'Not set'
7 - Save the rule with no values
8 - Now 'Defaults' is displayed and the unset button exists

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 15 Katrin Fischer 2021-05-09 13:06:26 UTC
Created attachment 120742 [details] [review]
Bug 24154: (follow-up) Make parameter and variable more explicit, add tests

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 16 Katrin Fischer 2021-05-09 13:06:31 UTC
Created attachment 120743 [details] [review]
Bug 24154: Adjust assignment

The code seems to work either way
We have a mix in our code:
git grep "}) %]"

Using '=>' over '=' does look nicer

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 17 Jonathan Druart 2021-05-10 14:17:32 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 18 Fridolin Somers 2021-05-12 14:22:22 UTC
Does not apply on 20.11.x.
It depends on Bug 27069 no ?