Bug 29628 - Purchase suggestion link on staff main page should always show, even if logged in branch has 0 suggestions
Summary: Purchase suggestion link on staff main page should always show, even if logge...
Status: RESOLVED DUPLICATE of bug 29571
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Lucas Gass
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-12-03 00:49 UTC by Lucas Gass
Modified: 2021-12-10 14:32 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes the display of suggestions pending approval section on the staff interface home page so that it always shows, even if the current library has no suggestions. For example: Suggestions pending approval: Centerville: 0 / All libraries: 2
Version(s) released in:


Attachments
Bug 29628: Show purchase suggestion link when there are any suggestions systemwide (3.24 KB, patch)
2021-12-03 00:59 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 29628: (follow-up) fix for rare edge case (9.69 KB, patch)
2021-12-03 14:41 UTC, Andreas Roussos
Details | Diff | Splinter Review
Bug 29628: Show purchase suggestion link when there are any suggestions systemwide (3.29 KB, patch)
2021-12-04 04:37 UTC, David Nind
Details | Diff | Splinter Review
Bug 29628: (follow-up) fix for rare edge case (9.74 KB, patch)
2021-12-04 04:38 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Lucas Gass 2021-12-03 00:49:05 UTC
Currently if a logged in location has suggestions at that branch we will show some like:

Suggestions pending approval: Centerville: 1 / All libraries: 2 

But if the logged in branch has 0 suggestions we display nothing. Many librarians find this a bit confusing and would prefer, if there are any suggestions systemwide, to show something like: 


Suggestions pending approval: Centerville: 0 / All libraries: 2
Comment 1 Lucas Gass 2021-12-03 00:59:03 UTC
Created attachment 128188 [details] [review]
Bug 29628: Show purchase suggestion link when there are any suggestions systemwide

To test:
1. Make some purchase suggestions at different branches.
2. Log in to a branch with a suggestion and visit /cgi-bin/koha/mainpage.pl
3. See something like: Suggestions pending approval: Centerville: 1 / All libraries: 2
4. Log into a branch with no suggestions, no link about suggestions
5. Apply patch
6. Repeat step 2, and still see something like: Centerville: 1 / All libraries: 2
7. Try a branch with no suggestions, now you see a link like: Centerville: 0 / All libraries: 2
Comment 2 Andreas Roussos 2021-12-03 14:41:05 UTC
Created attachment 128220 [details] [review]
Bug 29628: (follow-up) fix for rare edge case

When the number of pending suggestions in the currently selected branch
is equal to the number of pending suggestions across all branches, the
`all_pendingsuggestions` template parameter is equal to 0. This results
in the "Suggestions pending approval:" block not being printed at all.

This follow-up patch fixes that.

Also fixed is the display of pending suggestions in Home > Acquisitions.

Test plan:
1) Apply this patch.
2) Create two Library branches; submit two suggestions in each one.
3) Visit the Home page, and also visit Home > Acquisitions: you should
   only see "${BRANCH_CODE}: 2" suggestions pending approval, regardless
   of the branch you have selected using the 'Set library' menu option.
4) Delete both suggestions from the 1st branch, and set your library
   to be the 1st branch.
5) Visit the same pages: this time "${BRANCH_CODE}: 0 / All libraries: 2"
   is displayed.
6) Set your library to be the 2nd branch, and visit the same two pages:
   this time "${BRANCH_CODE}: 2" is displayed.
Comment 3 David Nind 2021-12-04 04:37:57 UTC
Created attachment 128242 [details] [review]
Bug 29628: Show purchase suggestion link when there are any suggestions systemwide

To test:
1. Make some purchase suggestions at different branches.
2. Log in to a branch with a suggestion and visit /cgi-bin/koha/mainpage.pl
3. See something like: Suggestions pending approval: Centerville: 1 / All libraries: 2
4. Log into a branch with no suggestions, no link about suggestions
5. Apply patch
6. Repeat step 2, and still see something like: Centerville: 1 / All libraries: 2
7. Try a branch with no suggestions, now you see a link like: Centerville: 0 / All libraries: 2

Signed-off-by: David Nind <david@davidnind.com>
Comment 4 David Nind 2021-12-04 04:38:06 UTC
Created attachment 128243 [details] [review]
Bug 29628: (follow-up) fix for rare edge case

When the number of pending suggestions in the currently selected branch
is equal to the number of pending suggestions across all branches, the
`all_pendingsuggestions` template parameter is equal to 0. This results
in the "Suggestions pending approval:" block not being printed at all.

This follow-up patch fixes that.

Also fixed is the display of pending suggestions in Home > Acquisitions.

Test plan:
1) Apply this patch.
2) Create two Library branches; submit two suggestions in each one.
3) Visit the Home page, and also visit Home > Acquisitions: you should
   only see "${BRANCH_CODE}: 2" suggestions pending approval, regardless
   of the branch you have selected using the 'Set library' menu option.
4) Delete both suggestions from the 1st branch, and set your library
   to be the 1st branch.
5) Visit the same pages: this time "${BRANCH_CODE}: 0 / All libraries: 2"
   is displayed.
6) Set your library to be the 2nd branch, and visit the same two pages:
   this time "${BRANCH_CODE}: 2" is displayed.

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 David Nind 2021-12-04 05:12:45 UTC
I wasn't able to replicate the edge case in the follow-up patch.
Comment 6 Katrin Fischer 2021-12-06 00:08:35 UTC
Hi Lucas, can you please check if this is a duplicate to bug 29571?
Comment 7 David Nind 2021-12-06 00:24:33 UTC
Thanks Katrin! I was sure I had signed of something similar, but I couldn't find it... (and it was only a week ago!)
Comment 8 Lucas Gass 2021-12-06 16:06:24 UTC
(In reply to Katrin Fischer from comment #6)
> Hi Lucas, can you please check if this is a duplicate to bug 29571?

Katrin, looks like a duplicate to me. I will close this one but I am curious if Bug 29571 needs Andreas's follow-up. I am unable to reproduce the edge case.
Comment 9 Lucas Gass 2021-12-06 16:06:53 UTC

*** This bug has been marked as a duplicate of bug 29571 ***
Comment 10 Andreas Roussos 2021-12-10 14:32:33 UTC
(In reply to Lucas Gass from comment #8)
> (In reply to Katrin Fischer from comment #6)
> > Hi Lucas, can you please check if this is a duplicate to bug 29571?
> 
> Katrin, looks like a duplicate to me. I will close this one but I am curious
> if Bug 29571 needs Andreas's follow-up. I am unable to reproduce the edge
> case.
Hi Lucas -- by all means, please feel free to close this bug ;-)

Jonathan's fix in Bug 29571 is much shorter/cleaner than my follow-up
patch here, and also deals with the edge case I described.

FWIW, the edge case would manifest after applying the initial patch
submitted for this bug, since in the template file
koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt

178     [% IF ( CAN_user_suggestions_suggestions_manage && pendingsuggestions ) %]

was changed to

178     [% IF ( CAN_user_suggestions_suggestions_manage && all_pendingsuggestions ) %]

In mainpage.pl, the template parameter `all_pendingsuggestions` would
be equal to 0 if the number of pending suggestions in the currently
selected branch is equal to the number of pending suggestions across
all branches (see line 90 below):

 86     my $pendingsuggestions = Koha::Suggestions->search({ status => "ASKED" });
 87     my $local_pendingsuggestions_count = $pendingsuggestions->search({ 'me.branchcode' => C4::Context->userenv()->{'branch'} })->count();
 88     my $pendingsuggestions_count = $pendingsuggestions->count();
 89     $template->param(
 90         all_pendingsuggestions => $pendingsuggestions_count != $local_pendingsuggestions_count ? $pendingsuggestions_count : 0,
 91         pendingsuggestions => $local_pendingsuggestions_count
 92     );

Thus, the condition inside the template [% IF %] block would be false
and the "Suggestions pending approval:" text would not appear at all.