Bug 26032

Summary: Add 'is new' filter in items search
Product: Koha Reporter: Fridolin Somers <fridolin.somers>
Component: SearchingAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P5 - low CC: emmi.takkinen, jonathan.druart
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=24443
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
There is a new filter in item search, when the database column 'items.new_status' is used. It allows searching items defined as new or not new, like the filter on damaged or not damaged.
Version(s) released in:
20.11.00
Attachments: Bug 26032: Add unit test
Bug 26032: Add 'is new' filter in items search
Bug 26032: Add unit test
Bug 26032: Add 'is new' filter in items search
Bug 26032: (follow-up) Replace IFNULL() mysqlism with COALESCE()
Bug 26032: Add unit test
Bug 26032: Add 'is new' filter in items search
Bug 26032: (follow-up) Replace IFNULL() mysqlism with COALESCE()
Bug 26032: (follow-up 2) show 'is new' filter only if items.new_status is used
Bug 26032: (follow-up 2) show 'is new' filter only if items.new_status is used
Bug 26032: (follow-up 2) show 'is new' filter only if items.new_status is used
Bug 26032: Add unit test
Bug 26032: Add 'is new' filter in items search
Bug 26032: (follow-up) Replace IFNULL() mysqlism with COALESCE()
Bug 26032: (follow-up 2) show 'is new' filter only if items.new_status is used
Bug 26032: Add unit test
Bug 26032: Add 'is new' filter in items search
Bug 26032: (follow-up) Replace IFNULL() mysqlism with COALESCE()
Bug 26032: (follow-up) show 'is new' filter only if items.new_status is used
Bug 26032: Add unit test
Bug 26032: Add 'is new' filter in items search
Bug 26032: (follow-up) Replace IFNULL() mysqlism with COALESCE()
Bug 26032: (follow-up) show 'is new' filter only if items.new_status is used

Description Fridolin Somers 2020-07-21 09:42:51 UTC
In items search, add a filter on value of items.new_status with a Ignore/Yes/No.
Yes meaning != 0, No meaning = 0, with considering that NULL value is like 0.
Comment 1 Fridolin Somers 2020-07-21 10:32:50 UTC
Created attachment 107141 [details] [review]
Bug 26032: Add unit test

Run prove t/db_dependent/Items.t
Comment 2 Fridolin Somers 2020-07-21 10:33:51 UTC
Created attachment 107142 [details] [review]
Bug 26032: Add 'is new' filter in items search

In items search, add a filter on value of items.new_status with a Ignore/Yes/No.
Yes meaning != 0, No meaning = 0, with considering that NULL value is like 0.

This patch adds 'isnull' option to filter, this may be reused on other
fields.

Test plan :
1) Define an item subfield on items.new_status with authorised values YES_NO (0 or 1)
2) Edit an item A to set new_status=1
3) Edit an item B to set new_status=0
4) Perform an item search with 'is new' = 'ignore' => you get all items
5) Perform an item search with 'is new' = 'yes' => you get item A
6) Perform an item search with 'is new' = 'no' => you get all items but A
Comment 3 Emmi Takkinen 2020-10-07 08:00:46 UTC
Followed test plan and filtering works as expected. However tests fail since they seem to take whole db in account not just test items. Should there be more filters (e.g by homebranch like in test above)?
Comment 4 Fridolin Somers 2020-10-13 12:55:26 UTC
Created attachment 111554 [details] [review]
Bug 26032: Add unit test

Run prove t/db_dependent/Items.t
Comment 5 Fridolin Somers 2020-10-13 12:56:09 UTC
Created attachment 111555 [details] [review]
Bug 26032: Add 'is new' filter in items search

In items search, add a filter on value of items.new_status with a Ignore/Yes/No.
Yes meaning != 0, No meaning = 0, with considering that NULL value is like 0.

This patch adds 'isnull' option to filter, this may be reused on other
fields.

Test plan :
1) Define an item subfield on items.new_status with authorised values YES_NO (0 or 1)
2) Edit an item A to set new_status=1
3) Edit an item B to set new_status=0
4) Perform an item search with 'is new' = 'ignore' => you get all items
5) Perform an item search with 'is new' = 'yes' => you get item A
6) Perform an item search with 'is new' = 'no' => you get all items but A
Comment 6 Fridolin Somers 2020-10-13 12:57:02 UTC
(In reply to Emmi Takkinen from comment #3)
> Followed test plan and filtering works as expected. However tests fail since
> they seem to take whole db in account not just test items. Should there be
> more filters (e.g by homebranch like in test above)?

You are right, Unit Test is now much better.
Comment 7 Fridolin Somers 2020-10-16 08:46:47 UTC
Created attachment 111834 [details] [review]
Bug 26032: (follow-up) Replace IFNULL() mysqlism with COALESCE()
Comment 8 Emmi Takkinen 2020-10-19 11:11:01 UTC
Created attachment 111961 [details] [review]
Bug 26032: Add unit test

Run prove t/db_dependent/Items.t

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Comment 9 Emmi Takkinen 2020-10-19 11:11:48 UTC
Created attachment 111962 [details] [review]
Bug 26032: Add 'is new' filter in items search

In items search, add a filter on value of items.new_status with a Ignore/Yes/No.
Yes meaning != 0, No meaning = 0, with considering that NULL value is like 0.

This patch adds 'isnull' option to filter, this may be reused on other
fields.

Test plan :
1) Define an item subfield on items.new_status with authorised values YES_NO (0 or 1)
2) Edit an item A to set new_status=1
3) Edit an item B to set new_status=0
4) Perform an item search with 'is new' = 'ignore' => you get all items
5) Perform an item search with 'is new' = 'yes' => you get item A
6) Perform an item search with 'is new' = 'no' => you get all items but A

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Comment 10 Emmi Takkinen 2020-10-19 11:12:43 UTC
Created attachment 111963 [details] [review]
Bug 26032: (follow-up) Replace IFNULL() mysqlism with COALESCE()

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Comment 11 Emmi Takkinen 2020-10-19 11:13:46 UTC
Works as expected and tests pass.
Comment 12 Katrin Fischer 2020-10-22 20:18:23 UTC
Hi Fridolin,

there is no mapping in MARC21 for the "new_status", so it cannot be edited via the item editor. It also seems that this is not set to any value by default. I am really not sure how this is used normally, it doesn't seem to be well integrated in "default" Koha right now. Can you explain?

I'd also love if the div had an id so it would e possible to hide the option for libraries not using this.
Comment 13 Katrin Fischer 2020-10-22 20:27:17 UTC
My problem is that the "is new" is not really a feature at the moment that is really advertised anywhere in standard Koha - I believe having a field to limit on with no idea where to set it will be confusing :(
Comment 14 Fridolin Somers 2020-10-23 10:01:26 UTC
Good points.

I propose to show this filter only if items.new_status has a mapping.

+ div with an id
Comment 15 Katrin Fischer 2020-10-23 10:11:12 UTC
Hi Frido, that sounds sensible, thx!
Comment 16 Fridolin Somers 2020-10-26 09:51:31 UTC
Created attachment 112500 [details] [review]
Bug 26032: (follow-up 2) show 'is new' filter only if items.new_status is used

Addition to test plan:
1) Apply on a database without Koha to MARC mapping on items.new_status
2Â) Check you dont see the 'is new' filter in items search form
Comment 17 Fridolin Somers 2020-10-26 09:52:06 UTC
Created attachment 112501 [details] [review]
Bug 26032: (follow-up 2) show 'is new' filter only if items.new_status is used

Addition to test plan:
1) Apply on a database without Koha to MARC mapping on items.new_status
2) Check you dont see the 'is new' filter in items search form
Comment 18 Fridolin Somers 2020-10-26 10:08:35 UTC
Created attachment 112502 [details] [review]
Bug 26032: (follow-up 2) show 'is new' filter only if items.new_status is used

Also adds a class 'item-new-status' to this filter to be able to hidde
even if items.new_status used.

Addition to test plan:
1) Apply on a database without Koha to MARC mapping on items.new_status
2) Check you dont see the 'is new' filter in items search form
3) Apply on a database with Koha to MARC mapping on items.new_status
4) Check you see class 'form-field item-new-status'
Comment 19 Séverine Queune 2020-10-30 14:07:04 UTC
Created attachment 112707 [details] [review]
Bug 26032: Add unit test

Run prove t/db_dependent/Items.t

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 20 Séverine Queune 2020-10-30 14:07:08 UTC
Created attachment 112708 [details] [review]
Bug 26032: Add 'is new' filter in items search

In items search, add a filter on value of items.new_status with a Ignore/Yes/No.
Yes meaning != 0, No meaning = 0, with considering that NULL value is like 0.

This patch adds 'isnull' option to filter, this may be reused on other
fields.

Test plan :
1) Define an item subfield on items.new_status with authorised values YES_NO (0 or 1)
2) Edit an item A to set new_status=1
3) Edit an item B to set new_status=0
4) Perform an item search with 'is new' = 'ignore' => you get all items
5) Perform an item search with 'is new' = 'yes' => you get item A
6) Perform an item search with 'is new' = 'no' => you get all items but A

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 21 Séverine Queune 2020-10-30 14:07:11 UTC
Created attachment 112709 [details] [review]
Bug 26032: (follow-up) Replace IFNULL() mysqlism with COALESCE()

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 22 Séverine Queune 2020-10-30 14:07:14 UTC
Created attachment 112710 [details] [review]
Bug 26032: (follow-up 2) show 'is new' filter only if items.new_status is used

Also adds a class 'item-new-status' to this filter to be able to hidde
even if items.new_status used.

Addition to test plan:
1) Apply on a database without Koha to MARC mapping on items.new_status
2) Check you dont see the 'is new' filter in items search form
3) Apply on a database with Koha to MARC mapping on items.new_status
4) Check you see class 'form-field item-new-status'

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 23 Katrin Fischer 2020-11-01 13:55:18 UTC
Created attachment 112809 [details] [review]
Bug 26032: Add unit test

Run prove t/db_dependent/Items.t

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 24 Katrin Fischer 2020-11-01 13:55:21 UTC
Created attachment 112810 [details] [review]
Bug 26032: Add 'is new' filter in items search

In items search, add a filter on value of items.new_status with a Ignore/Yes/No.
Yes meaning != 0, No meaning = 0, with considering that NULL value is like 0.

This patch adds 'isnull' option to filter, this may be reused on other
fields.

Test plan :
1) Define an item subfield on items.new_status with authorised values YES_NO (0 or 1)
2) Edit an item A to set new_status=1
3) Edit an item B to set new_status=0
4) Perform an item search with 'is new' = 'ignore' => you get all items
5) Perform an item search with 'is new' = 'yes' => you get item A
6) Perform an item search with 'is new' = 'no' => you get all items but A

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 25 Katrin Fischer 2020-11-01 13:55:25 UTC
Created attachment 112811 [details] [review]
Bug 26032: (follow-up) Replace IFNULL() mysqlism with COALESCE()

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 26 Katrin Fischer 2020-11-01 13:55:29 UTC
Created attachment 112812 [details] [review]
Bug 26032: (follow-up) show 'is new' filter only if items.new_status is used

Also adds a class 'item-new-status' to this filter to be able to hidde
even if items.new_status used.

Addition to test plan:
1) Apply on a database without Koha to MARC mapping on items.new_status
2) Check you dont see the 'is new' filter in items search form
3) Apply on a database with Koha to MARC mapping on items.new_status
4) Check you see class 'form-field item-new-status'

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Comment 27 Jonathan Druart 2020-11-03 13:23:16 UTC
Created attachment 112915 [details] [review]
Bug 26032: Add unit test

Run prove t/db_dependent/Items.t

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 28 Jonathan Druart 2020-11-03 13:23:19 UTC
Created attachment 112916 [details] [review]
Bug 26032: Add 'is new' filter in items search

In items search, add a filter on value of items.new_status with a Ignore/Yes/No.
Yes meaning != 0, No meaning = 0, with considering that NULL value is like 0.

This patch adds 'isnull' option to filter, this may be reused on other
fields.

Test plan :
1) Define an item subfield on items.new_status with authorised values YES_NO (0 or 1)
2) Edit an item A to set new_status=1
3) Edit an item B to set new_status=0
4) Perform an item search with 'is new' = 'ignore' => you get all items
5) Perform an item search with 'is new' = 'yes' => you get item A
6) Perform an item search with 'is new' = 'no' => you get all items but A

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 29 Jonathan Druart 2020-11-03 13:23:22 UTC
Created attachment 112917 [details] [review]
Bug 26032: (follow-up) Replace IFNULL() mysqlism with COALESCE()

Signed-off-by: Emmi Takkinen <emmi.takkinen@outlook.com>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 30 Jonathan Druart 2020-11-03 13:23:25 UTC
Created attachment 112918 [details] [review]
Bug 26032: (follow-up) show 'is new' filter only if items.new_status is used

Also adds a class 'item-new-status' to this filter to be able to hidde
even if items.new_status used.

Addition to test plan:
1) Apply on a database without Koha to MARC mapping on items.new_status
2) Check you dont see the 'is new' filter in items search form
3) Apply on a database with Koha to MARC mapping on items.new_status
4) Check you see class 'form-field item-new-status'

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 31 Jonathan Druart 2020-11-03 13:23:42 UTC
Added missing signed-off-by lines.
Comment 32 Jonathan Druart 2020-11-04 12:03:32 UTC
Pushed to master for 20.11, thanks to everybody involved!