Bug 11502 - Branch filter in "Holds To Pull" is too fuzzy
Summary: Branch filter in "Holds To Pull" is too fuzzy
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: David Cook
QA Contact: Jonathan Druart
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-09 06:05 UTC by David Cook
Modified: 2014-12-07 20:05 UTC (History)
4 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:


Attachments
Bug 11502 - Branch filter in "Holds To Pull" is too fuzzy (2.22 KB, patch)
2014-01-09 06:17 UTC, David Cook
Details | Diff | Splinter Review
Bug 11502 - Branch filter in "Holds To Pull" is too fuzzy (2.28 KB, patch)
2014-01-09 07:56 UTC, Chris Cormack
Details | Diff | Splinter Review
Bug 11502 - Branch filter in "Holds To Pull" is too fuzzy (2.35 KB, patch)
2014-01-14 09:25 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2014-01-09 06:05:19 UTC
Currently, in the "Holds to Pull" list, the filter is too fuzzy/not exact enough.

The Scenario:
1 - You have a hold on an item at branch NM
2 - You have a hold on an item at branch NMH
3 - You have a hold on an item at either branch NM, NA, NB

Currently, if you filter by 'NM', you'll get all three holds to pull, even though you really only want holds 1 and 3.
Comment 1 David Cook 2014-01-09 06:17:57 UTC Comment hidden (obsolete)
Comment 2 Chris Cormack 2014-01-09 07:56:11 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2014-01-09 15:43:07 UTC
Hi David,
Could you explain why you match the < and >?
The ^$ are not enough?
Comment 4 David Cook 2014-01-13 22:45:06 UTC
(In reply to Jonathan Druart from comment #3)
> Hi David,
> Could you explain why you match the < and >?
> The ^$ are not enough?

Sure, Jonathan.

It's because DataTables interprets all the data in a table cell as one long string.

Sometimes, your string might be <td>BRANCH</td>.

Other times, it might be <td>BRANCH<br/>BRANCH1<br/>BRANCH2</td>.

If you were to only use ^$, 'BRANCH' would only match the first scenario. It wouldn't match the second, because the string ends with BRANCH2 - not BRANCH. 

However, we want it to match both scenarios, so we need to include < and >. 

In fact, there are 4 scenarios I see:

1) ^BRANCH$ (i.e. the string is only BRANCH)
2) ^BRANCH< (i.e. the string begins with BRANCH)
3) >BRANCH< (i.e. the string contains BRANCH in the middle somewhere)
4) >BRANCH$ (i.e. the string ends with BRANCH)

Does that answer your question?
Comment 5 Jonathan Druart 2014-01-14 09:24:10 UTC
(In reply to David Cook from comment #4)
> Does that answer your question?

Yes, thanks David.
Looking at the tt code, I seen that the cell contain 'reserveloo.holdingbranch', and I supposed it was a simple branch.
But in fact, this field is built with a concat in the sql query.
I should have read the test plan entirely...

So the patch works great. Marked as Passed QA.
Comment 6 Jonathan Druart 2014-01-14 09:25:41 UTC
Created attachment 24272 [details] [review]
Bug 11502 - Branch filter in "Holds To Pull" is too fuzzy

This patch uses regex checking via the DataTables fnFilter API method
to make the branch filter more precise on the "Holds to Pull" page.

The ability to use regex is built into DataTables so this just adds
the actual expression.

_TEST PLAN_

Before applying:

1) Add library (branches) with codes of NM, NMH, and NB
2) Add items (that can be placed on hold) at all these branches
3) Place a hold on an item that is only available at NM
4) Place a hold on an item that is only available at NMH
5) Place a hold on an item that is only available at NM and NB
6) Go to "Holds to Pull" in the Circulation module
7) Filter by these three different values
8) Note that filtering by "NM" will incorrectly bring up all three
holds, while "NMH" and "NB" will only pull up one (like they should).

Apply the patch.

9) Shift+refresh the page so that your Javascript refreshes
10) Repeat step 7 (filtering by the different branch values)
11) Note that filtering by "NM" will now only bring up the hold for "NM"
and the hold for "NM" and "NB", while the others still only bring up
one hold.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Comment 7 Galen Charlton 2014-01-14 16:35:21 UTC
Pushed to master.  Thanks, David!
Comment 8 Fridolin Somers 2014-03-18 07:46:38 UTC
Patch pushed to 3.14.x, will be in 3.14.5
Comment 9 Chris Cormack 2014-03-24 04:42:11 UTC
Pushed to 3.12.x will be in 3.12.12