OPAC Browse: Various interface improvements
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 13 Jun 2013 20:22:13 +0000 (16:22 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 13 Jun 2013 20:22:13 +0000 (16:22 -0400)
  * Change of wording for the starts-with-article warnings, plus the
    addition of a link to browse with the same term without the article.

  * Forward button relabeled "Next", to be more consistent with other
    things.

  * Spinners for form submission and back/next buttons, done in a way
    similar to the OPAC search interfaces.

  * Apply the user setting 'opac.hits_per_page' to serve as the default
    number of browse hits per page when users are logged in.

  * Numbered browse results instead of bulleted.

  * Change of wording around the controls where the user enters browse
    terms and selects a search class and context location.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Browse.pm
Open-ILS/src/templates/opac/browse.tt2
Open-ILS/src/templates/opac/css/style.css.tt2
Open-ILS/src/templates/opac/parts/qtype_selector.tt2

index cc9d73c..62b0c4a 100644 (file)
@@ -15,6 +15,7 @@ use OpenSRF::Utils::SettingsClient;
 use Digest::MD5 qw/md5_hex/;
 use Apache2::Const -compile => qw/OK/;
 use MARC::Record;
+use List::Util qw/first/;
 #use Data::Dumper;
 #$Data::Dumper::Indent = 0;
 
@@ -56,7 +57,11 @@ sub prepare_browse_parameters {
     # XXX TODO add config.global_flag rows for browse limit-limit and
     # browse offset-limit?
 
-    my $limit = int($self->cgi->param('blimit') || 10);
+    my $limit = int(
+        $self->cgi->param('blimit') ||
+        $self->ctx->{opac_hits_per_page} ||
+        10
+    );
     my $offset = int($self->cgi->param('boffset') || 0);
     my $force_backward = scalar($self->cgi->param('bback'));
 
@@ -370,6 +375,8 @@ sub leading_article_test {
         if ($map->{$qtype}) {
             if ($bterm =~ qr/$map->{$qtype}/i) {
                 $self->ctx->{browse_leading_article_warning} = 1;
+                ($self->ctx->{browse_leading_article_alternative} = $bterm) =~
+                    s/$map->{$qtype}//;
             }
         }
     };
@@ -383,6 +390,18 @@ sub load_browse {
 
     _init_browse_cache();
 
+    # This is just so we can access a user settings IFF the user is logged in
+    # (opac.hits_per_page).
+    if ($self->ctx->{user}) {
+        $self->prepare_extended_user_info('settings');
+        if (my $setting = first { $_->name eq 'opac.hits_per_page' }
+            @{$self->ctx->{user}->settings}) {
+
+            $self->ctx->{opac_hits_per_page} = $setting->value;
+        }
+    }
+
+
     $self->ctx->{more_forward} = 0;
     $self->ctx->{more_back} = 0;
 
index 35a9d5a..0bb4931 100644 (file)
@@ -7,7 +7,7 @@
     INCLUDE "opac/parts/topnav.tt2";
 
     ctx.page_title = l("Browse the Catalog");
-    blimit = CGI.param('blimit') || 10;
+    blimit = CGI.param('blimit') || ctx.opac_hits_per_page || 10;
     boffset = CGI.param('boffset') || 0;
 
     depart_list = ['blimit', 'bterm', 'boffset', 'bpivot', 'bback'];
         <div id="main-content">
             <div id="browse-the-catalog">
                 <div id="browse-controls">
-                    <form method="get">
+                    <form method="get" onsubmit="$('browse-submit-spinner').className = ''; return true">
                         <input type="hidden" name="blimit"
                             value="[% blimit %]" />
 
                         [% control_qtype = INCLUDE "opac/parts/qtype_selector.tt2"
-                            id="browse-search-class" browse_only=1 %]
+                            id="browse-search-class" browse_only=1 plural=1 %]
 
                         [% control_bterm = BLOCK %]<input type="text" name="bterm" id="browse-term"
                             value="[% CGI.param('bterm') | html %]" />[% END %]
                         [% control_locg = INCLUDE build_org_selector id='browse-context'
                             show_loc_groups=1
                             arialabel=l('Select holding library') %]
-                        [% l('Browse by [_1] for [_2] held under [_3]', control_qtype, control_bterm, control_locg) %]
+                        [% l('Browse for [_1] starting with [_2] in [_3]', control_qtype, control_bterm, control_locg) %]
 
                         <input type="submit" value="[% l('Go') %]" />
+                        <img id="browse-submit-spinner" src="[% ctx.media_prefix %]/opac/images/progressbar_green.gif" class="hidden" style="width: 16px; height: 16px;" alt="" />
                     </form>
                 </div>
 
                 [% BLOCK browse_pager %]
                 <div class="browse-pager">
                     [% IF ctx.more_back %]
-                    <a class="opac-button" href="[% mkurl('', {bpivot => ctx.back_pivot, bback => 1}) %]">&larr; [%l ('Back') %]</a>
+                    <a class="opac-button" href="[% mkurl('', {bpivot => ctx.back_pivot, bback => 1}) %]" onclick="$('browse-pager-spinner-[% id %]').className = '';">&larr; [%l ('Back') %]</a>
                     [% END %]
                     [% IF browse.english_pager; # XXX how to apply i18n here?
                         current_qtype = CGI.param('qtype') || 'title' %]
                     [% END %]
 
                     [% IF ctx.more_forward %]
-                    <a class="opac-button" href="[% mkurl('', {bpivot => ctx.forward_pivot}, ['bback']) %]">[%l ('Forward') %] &rarr;</a>
+                    <a class="opac-button" href="[% mkurl('', {bpivot => ctx.forward_pivot}, ['bback']) %]" onclick="$('browse-pager-spinner-[% id %]').className = '';">[%l ('Next') %] &rarr;</a>
                     [% END %]
+
+                    <img id="browse-pager-spinner-[% id %]" src="[% ctx.media_prefix %]/opac/images/progressbar_green.gif" class="hidden" style="width: 16px; height: 16px;" alt="" />
                 </div>
                 [% END %]
 
-                [% PROCESS browse_pager %]
+                [% PROCESS browse_pager id=0 %]
 
                 <div id="browse-results">
                 [% IF ctx.browse_error %]
                 [% ELSE %]
                     [% IF ctx.browse_leading_article_warning %]
                     <div class="browse-leading-article-warning">
-                            [% l("Your browse term seems to begin with an article. You might get better results by omitting the article.") %]
+                            [% l("Your browse term seems to begin with an article (a, an, the). You might get better results by omitting the article.") %]
+                            [% IF ctx.browse_leading_article_alternative %]
+                            <p>
+                            [% alternative_link = BLOCK %]
+                            <a href="[% mkurl('', {bterm => ctx.browse_leading_article_alternative}, ['bback','bpivot','boffest']) %]">[% ctx.browse_leading_article_alternative | html %]</a>
+                            [%  END; # alternative_link BLOCK
+                                l("Did you mean [_1]?", alternative_link);
+                            END # IF %]
+                            </p >
                     </div>
                     [% END %]
-                    <ul class="browse-result-list">
+
+                    <ol class="browse-result-list">
                     [% FOR result IN ctx.browse_results %]
                         <li class="browse-result">
                             <span class="browse-result-value">
                 [% END %]
                 </div>
 
-                [% PROCESS browse_pager %]
+                [% PROCESS browse_pager id=1 %]
             </div>
 
             <div class="common-full-pad"></div>        
index 16c6400..68aac9b 100644 (file)
@@ -1526,7 +1526,7 @@ a.preflib_change {
     margin: 2ex 0;
 }
 .browse-result-list {
-    list-style-type: square;
+    padding-bottom: 0.5ex;
 }
 .browse-shortcuts {
     font-size: 120%;
index 30edbc6..6986fc1 100644 (file)
@@ -1,10 +1,10 @@
 [%  query_types = [
     {value => "keyword", label => l("Keyword")},
-    {value => "title", label => l("Title"), browse => 1},
+    {value => "title", label => l("Title"), plural_label => l("Titles"), browse => 1},
     {value => "jtitle", label => l("Journal Title")},
-    {value => "author", label => l("Author"), browse => 1},
-    {value => "subject", label => l("Subject"), browse => 1},
-    {value => "series", label => l("Series"), browse => 1},
+    {value => "author", label => l("Author"), plural_label => l("Authors"), browse => 1},
+    {value => "subject", label => l("Subject"), plural_label => l("Subjects"), browse => 1},
+    {value => "series", label => l("Series"), plural_label => l("Series"), browse => 1},
     {value => "id|bibcn", label => l("Bib Call Number")}
 ] %]
 <select name="[% name || 'qtype' %]"[% IF id; ' id="'; id ; '"' ; END -%]
         NEXT IF browse_only AND NOT qt.browse -%]
     <option value='[% qt.value | html %]'[%
         query_type == qt.value ? ' selected="selected"' : ''
-    %]>[% qt.label | html %]</option>
+    %]>[% IF plural AND qt.plural_label;
+        qt.plural_label | html;
+    ELSE;
+        qt.label | html;
+    END %]</option>
     [% END -%]
 </select>