Summary: | Purchase suggestion link on staff main page should always show, even if logged in branch has 0 suggestions | ||
---|---|---|---|
Product: | Koha | Reporter: | Lucas Gass <lucas> |
Component: | Acquisitions | Assignee: | Lucas Gass <lucas> |
Status: | RESOLVED DUPLICATE | QA Contact: | Testopia <testopia> |
Severity: | minor | ||
Priority: | P5 - low | CC: | a.roussos, david |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
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
Bug 29628: (follow-up) fix for rare edge case Bug 29628: Show purchase suggestion link when there are any suggestions systemwide Bug 29628: (follow-up) fix for rare edge case |
Description
Lucas Gass
2021-12-03 00:49:05 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 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. 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> 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> I wasn't able to replicate the edge case in the follow-up patch. Hi Lucas, can you please check if this is a duplicate to bug 29571? Thanks Katrin! I was sure I had signed of something similar, but I couldn't find it... (and it was only a week ago!) (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. *** This bug has been marked as a duplicate of bug 29571 *** (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. |