Bug 29280 - Add star ratings to OPAC lists display
Summary: Add star ratings to OPAC lists display
Status: Failed QA
Alias: None
Product: Koha
Classification: Unclassified
Component: OPAC (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Lucas Gass (lukeg)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-19 20:35 UTC by Lucas Gass (lukeg)
Modified: 2023-07-04 15:04 UTC (History)
2 users (show)

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


Attachments
Bug 29280: Add OpacStarRatings to opac-shelves.tt (5.97 KB, patch)
2021-10-19 22:57 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 29280: (follow-up) add event handler when clicking on star ratings (846 bytes, patch)
2021-10-25 20:50 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 29280: Add OpacStarRatings to opac-shelves.tt (6.02 KB, patch)
2021-10-26 10:23 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 29280: (follow-up) add event handler when clicking on star ratings (896 bytes, patch)
2021-10-26 10:23 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 29280: (follow-up) Move OpacStarRating logic to template (1.79 KB, patch)
2021-11-01 17:36 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Bug 29280: Add OpacStarRatings to opac-shelves.tt (6.09 KB, patch)
2021-11-01 21:18 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 29280: (follow-up) add event handler when clicking on star ratings (954 bytes, patch)
2021-11-01 21:18 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 29280: (follow-up) Move OpacStarRating logic to template (1.85 KB, patch)
2021-11-01 21:18 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 Lucas Gass (lukeg) 2021-10-19 20:35:38 UTC
OPACStarRatings already exist on the OPAC details, results, and patron pages. Some librarians would find it handy if they were also included on OPAC lists (opac-shelves.tt)
Comment 1 Lucas Gass (lukeg) 2021-10-19 22:57:45 UTC
Created attachment 126558 [details] [review]
Bug 29280: Add OpacStarRatings to opac-shelves.tt

To test:
-Apply patch and restart everything
-Set the system preference 'OpacStarRatings' to 'results, detail, lists, and patron'
-Build a public lists with some items that have ratings
-View the list page and you should see the ratings appear
-Make sure that the ratings and the number of votes are acurate
-Ratings on the opac-shelves should look and function just like those on the OPAC results page
-Turn the 'OpacStarRatings' system pref to 'only detials' and 'no', making sure they do not show in the lists display
Comment 2 Owen Leonard 2021-10-21 16:22:25 UTC
Although it was introduced for (and named for) user-related pages, the include file user-star-ratings.inc could be used here, I think. Unless the ratings are supposed to display, but not be interacted with?

If they are supposed to be interacted with, the template will need to include the relevant JS:

    [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
        [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %]
        [% Asset.js("js/ratings.js") | $raw %]
    [% END %]
Comment 3 Lucas Gass (lukeg) 2021-10-22 14:45:50 UTC
(In reply to Owen Leonard from comment #2)
> Although it was introduced for (and named for) user-related pages, the
> include file user-star-ratings.inc could be used here, I think. Unless the
> ratings are supposed to display, but not be interacted with?
> 
> If they are supposed to be interacted with, the template will need to
> include the relevant JS:
> 
>     [% IF ( Koha.Preference('OpacStarRatings') == 'all' ) %]
>         [% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") | $raw %]
>         [% Asset.js("js/ratings.js") | $raw %]
>     [% END %]

Thanks for looking at this Owen! I followed the behavior of results.tt, which doesn't seem to allow users to interact with OpacStarRatings, only view them. 

Do you think we should allow patrons to interact with ratings on both results and lists? (if they are logged in) And if so, should I handle all of that in this bug?
Comment 4 Owen Leonard 2021-10-25 17:04:16 UTC
(In reply to Lucas Gass from comment #3)
> Thanks for looking at this Owen! I followed the behavior of results.tt,
> which doesn't seem to allow users to interact with OpacStarRatings, only
> view them. 

My mistake, I was misremembering. I don't recall if there was any particular reason for it to be like this, but that discussion can happen on a different bug.
Comment 5 Owen Leonard 2021-10-25 17:41:24 UTC
The search results page adds this event handler to keep the page from jumping if someone clicks one of the stars:

$(".br-readonly a").on("click", function(e){
    e.preventDefault();
});

Could you add that to opac-shelves.tt in a follow-up?
Comment 6 Lucas Gass (lukeg) 2021-10-25 20:50:12 UTC
Created attachment 126861 [details] [review]
Bug 29280: (follow-up) add event handler when clicking on star ratings
Comment 7 Owen Leonard 2021-10-26 10:23:00 UTC
Created attachment 126899 [details] [review]
Bug 29280: Add OpacStarRatings to opac-shelves.tt

To test:
-Apply patch and restart everything
-Set the system preference 'OpacStarRatings' to 'results, detail, lists, and patron'
-Build a public lists with some items that have ratings
-View the list page and you should see the ratings appear
-Make sure that the ratings and the number of votes are acurate
-Ratings on the opac-shelves should look and function just like those on the OPAC results page
-Turn the 'OpacStarRatings' system pref to 'only detials' and 'no', making sure they do not show in the lists display

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 8 Owen Leonard 2021-10-26 10:23:03 UTC
Created attachment 126900 [details] [review]
Bug 29280: (follow-up) add event handler when clicking on star ratings

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 9 Katrin Fischer 2021-11-01 12:40:03 UTC
Sorry, not trying to throw this out, but:

+$template->param(
+    OpacStarRatings => C4::Context->preference("OpacStarRatings")
+);
+

Should we not remove this in favor of using TT in the template?
Comment 10 Lucas Gass (lukeg) 2021-11-01 17:34:00 UTC
(In reply to Katrin Fischer from comment #9)
> Sorry, not trying to throw this out, but:
> 
> +$template->param(
> +    OpacStarRatings => C4::Context->preference("OpacStarRatings")
> +);
> +
> 
> Should we not remove this in favor of using TT in the template?

Indeed, we should!
Comment 11 Lucas Gass (lukeg) 2021-11-01 17:36:15 UTC
Created attachment 127190 [details] [review]
Bug 29280: (follow-up) Move OpacStarRating logic to template
Comment 12 Katrin Fischer 2021-11-01 21:18:12 UTC
Created attachment 127200 [details] [review]
Bug 29280: Add OpacStarRatings to opac-shelves.tt

To test:
-Apply patch and restart everything
-Set the system preference 'OpacStarRatings' to 'results, detail, lists, and patron'
-Build a public lists with some items that have ratings
-View the list page and you should see the ratings appear
-Make sure that the ratings and the number of votes are acurate
-Ratings on the opac-shelves should look and function just like those on the OPAC results page
-Turn the 'OpacStarRatings' system pref to 'only detials' and 'no', making sure they do not show in the lists display

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

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Katrin Fischer 2021-11-01 21:18:16 UTC
Created attachment 127201 [details] [review]
Bug 29280: (follow-up) add event handler when clicking on star ratings

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

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 14 Katrin Fischer 2021-11-01 21:18:20 UTC
Created attachment 127202 [details] [review]
Bug 29280: (follow-up) Move OpacStarRating logic to template

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 15 Jonathan Druart 2021-11-03 13:32:38 UTC
Code is copy/pasted from somewhere else. I cannot push it like that.
Comment 16 Lucas Gass (lukeg) 2021-11-03 13:34:43 UTC
(In reply to Jonathan Druart from comment #15)
> Code is copy/pasted from somewhere else. I cannot push it like that.

I took most of this code from the OPACStarRatings on the results page. What needs to be amended?
Comment 17 Lucas Gass (lukeg) 2021-11-03 13:40:22 UTC
(In reply to Lucas Gass from comment #16)
> (In reply to Jonathan Druart from comment #15)
> > Code is copy/pasted from somewhere else. I cannot push it like that.

Are you asking me to put the repeated code in an include?
Comment 18 Jonathan Druart 2021-11-03 13:54:02 UTC
(In reply to Lucas Gass from comment #17)
> (In reply to Lucas Gass from comment #16)
> > (In reply to Jonathan Druart from comment #15)
> > > Code is copy/pasted from somewhere else. I cannot push it like that.
> 
> Are you asking me to put the repeated code in an include?

Yes, please? It can be done on a separate bug report if you prefer.
Comment 19 Lucas Gass (lukeg) 2021-11-03 15:25:34 UTC
(In reply to Jonathan Druart from comment #18)
> (In reply to Lucas Gass from comment #17)
> > (In reply to Lucas Gass from comment #16)
> > > (In reply to Jonathan Druart from comment #15)
> > > > Code is copy/pasted from somewhere else. I cannot push it like that.
> > 
> > Are you asking me to put the repeated code in an include?
> 
> Yes, please? It can be done on a separate bug report if you prefer.

No need for a separate bug, I will do it on this one!
Comment 20 Lucas Gass (lukeg) 2021-12-21 23:04:04 UTC
I filed Bug 29749 to clean up OpacStarRatings a bit. If it is pushed it will make adding OpacStarRatings to lists easier.
Comment 21 Katrin Fischer 2023-06-24 20:43:35 UTC
How can we move forward here?
Comment 22 Jonathan Druart 2023-07-04 15:04:03 UTC
Quick note: bug 33953 introduces Koha::Biblio->ratings