LP1895678: Bring course materials into the bootstrap OPAC
authorJane Sandberg <sandbej@linnbenton.edu>
Sun, 20 Dec 2020 03:20:43 +0000 (19:20 -0800)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 8 Feb 2021 16:17:13 +0000 (11:17 -0500)
Also adds course_ou and use_courses to ctx, so that we
can avoid having so many duplicate and slightly inconsistent
checks to see if we are using the course materials module.

Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Signed-off-by: Garry Collum <gcollum@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm
Open-ILS/src/templates-bootstrap/opac/course_browse.tt2 [new file with mode: 0644]
Open-ILS/src/templates-bootstrap/opac/course_search.tt2 [new file with mode: 0644]
Open-ILS/src/templates-bootstrap/opac/css/style.css.tt2
Open-ILS/src/templates-bootstrap/opac/parts/record/copy_table.tt2
Open-ILS/src/templates-bootstrap/opac/parts/result/table.tt2
Open-ILS/src/templates-bootstrap/opac/parts/topnav_subnav.tt2

index 663cde6..ac307e8 100644 (file)
@@ -466,6 +466,9 @@ sub load_common {
         return $rows;
     };
 
+    $ctx->{course_ou} = int($self->cgi->param('locg')) || $self->ctx->{physical_loc} || $self->ctx->{aou_tree}->()->id;
+    $ctx->{use_courses} = $ctx->{get_org_setting}->($ctx->{course_ou}, 'circ.course_materials_opt_in') ? 1 : 0;
+
     return Apache2::Const::OK;
 }
 
diff --git a/Open-ILS/src/templates-bootstrap/opac/course_browse.tt2 b/Open-ILS/src/templates-bootstrap/opac/course_browse.tt2
new file mode 100644 (file)
index 0000000..15c87fd
--- /dev/null
@@ -0,0 +1,147 @@
+[%-
+
+    PROCESS "opac/parts/header.tt2";
+    PROCESS "opac/parts/misc_util.tt2";
+    PROCESS "opac/parts/org_selector.tt2";
+    WRAPPER "opac/parts/base.tt2";
+    INCLUDE "opac/parts/topnav.tt2";
+
+    ctx.page_title = l("Browse Courses");
+    blimit = CGI.param('blimit') || ctx.opac_hits_per_page || 10;
+    display_idx = CGI.param('didx') || ctx.match_idx || 0;
+
+    upper_limit = 0;
+    lower_limit = 0;
+    depart_list = ['blimit', 'bterm', 'bpivot'];
+    ctx.metalinks.push('<meta name="robots" content="noindex,follow">');
+%]
+
+<h2 class="sr-only">[% l('Course Browse') %]</h2>
+
+<div id="content-wrapper" class="my-5">
+  <div class="container mx-auto w-75">
+    <div id="browse-for-courses">
+      <div id="browse-controls" class='row'>
+        <form method="get" onsubmit="$('browse-submit-spinner').className = ''; return true" class="mx-auto">
+          <input type="hidden" name="blimit"
+            value="[% blimit | html %]" />
+          [% control_qtype = INCLUDE "opac/parts/course_search/qtype_selector.tt2"
+            id="browse-search-class" browse_only=1 plural=1 %]
+
+          [% control_bterm = BLOCK %]
+            <input type="text" name="bterm" id="browse-term" 
+              aria-label="[% l('Browse term') %]"
+              value="[% CGI.param('bterm') | html %]">
+          [% END; #control_bterm BLOCK %]
+
+          [% control_locg = INCLUDE build_org_selector id='browse-context'
+            show_log_groups=1 arialabel=l('Select owning Library') %]
+
+          [% l('Browse for [_1] starting with [_2] in [_3]',
+              control_qtype, control_bterm, control_locg) %]
+
+          <button id='search-submit-go' type="submit" class="btn btn-confirm my-2"><i class="fas fa-book-reader" aria-hidden="true"></i> [% l('Browse') %]</button>
+          <img id="browse-submit-spinner" class="hidden"
+            style="width: 16px; height: 16px;"
+            alt="[% l('Search in progress icon') %]"
+            src="[% ctx.media_prefix %]/opac/images/progressbar_green.gif[% ctx.cache_key %]" />
+        </form>
+      </div>
+
+      [% BLOCK browse_pager %]
+        [%
+            pivot_lower = CGI.param('didx') - blimit;
+            pivot_higher = CGI.param('didx') + blimit;
+            IF pivot_lower < 0;
+                pivot_lower = 0;
+            END;
+            IF CGI.param('didx') <= 0;
+                lower_limit = 1;
+            ELSE;
+                lower_limit = 0;
+            END;
+
+            IF pivot_higher > ctx.browse_results.size;
+                pivot_higher = ctx.browse_results.size - (blimit + 1);
+                upper_limit = 1;
+            ELSE;
+                upper_limit = 0;
+            END;
+        %]
+        [% IF ctx.browse_results.size >= blimit %]
+        <div class="browse-pager">
+            [% IF lower_limit == 0 %]
+            <a class="opac-button" href="[% mkurl('', {didx => pivot_lower}) %]" 
+              onclick="$('browse-pager-spinner-[% id %]').className = '';"
+            >&larr; [%l ('Back') %]</a>
+            [% END %]
+            [% IF upper_limit == 0 %]
+            <a class="opac-button" href="[% mkurl('', {didx => pivot_higher}) %]"
+              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[% ctx.cache_key %]"
+            class="hidden" style="width: 16px; height: 16px;" 
+            alt="[% l('Search in progress icon') %]" />
+        </div>
+        [% END %]
+      [% END %]
+
+      [% PROCESS browse_pager id=0 %]
+
+      <div id="browse-results">
+        [% IF ctx.browse_error %]
+          <span class="browse-error">
+            [% l("An error occurred browsing records. " _
+              "Please try again in a moment or report the issue " _
+              "to library staff.") %]
+          </span>
+        [% ELSE %]
+          [% IF ctx.browse_leading_article_warning %]
+            <div class="browse-leading-article-warning">
+              [% 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}, ['bpivot']) %]">[% ctx.browse_leading_article_alternative | html %]</a>
+                [%-  END; # alternative_link BLOCK
+                l("Did you mean [_1]?", alternative_link);
+              END # IF %]
+              </p>
+            </div>
+          [% END # IF browse leading article warning %]
+
+          <ul class="browse-result-list">
+          [% FOR result IN ctx.browse_results %]
+            [% IF result.browse_index >= CGI.param('didx') &&
+              result.browse_index <= (CGI.param('didx') + blimit - 1) %]
+            <li class="browse-result">
+              <span class="browse-result-value[% result.match == 1 ? ' browse-result-best-match' : '' %]">
+                [% IF result.results_count > 0 %]
+                  <a href="[% mkurl(ctx.opac_root _ '/course/results', {
+                    'query' => result.value, 'bool' => 'and'}
+                  )%]">[% result.value | html %]</a>
+                  <span class="browse-result-sources">([%
+                    IF result.accurate == 'f';
+                      l("At least"); " ";
+                    END; #result.accurate IF
+                  result.results_count %])</span>
+                [% ELSE %]
+                  [% result.value | html %]
+                [% END; #result.sources IF %]
+              </span>
+            </li>
+            [% END %]
+          [% END; #result in browse_results %]
+          </ul>
+        [% END; #browse error ELSE %]
+      </div>
+
+      [% PROCESS browse_pager id=1 %]
+    </div>
+
+    <div class="common-full-pad"></div>
+  </div>
+</div>
+
+[% END %]
diff --git a/Open-ILS/src/templates-bootstrap/opac/course_search.tt2 b/Open-ILS/src/templates-bootstrap/opac/course_search.tt2
new file mode 100644 (file)
index 0000000..4fc7c8e
--- /dev/null
@@ -0,0 +1,82 @@
+[%- PROCESS "opac/parts/header.tt2";
+    WRAPPER "opac/parts/base.tt2";
+    INCLUDE "opac/parts/topnav.tt2";
+    ctx.page_title = l("Course Search");
+
+    PROCESS "opac/parts/misc_util.tt2";
+    PROCESS get_library;
+    ctx.metalinks.push('<meta name="robots" content="noindex,follow">');
+-%]
+
+<h2 class="sr-only">[% l('Course Search') %]</h2>
+
+<div id="content-wrapper">
+  <div id="main-content">
+  <form action="[% ctx.opac_root %]/course/results" method="get">
+    <!-- TODO: Refactor simple.js addSearchRow to better handle
+      tables with IDs that aren't adv_... -->
+    <div class="header_middle" id="adv_search_input">
+      [% l("Course Search Input") %]
+    </div>
+
+    <div id="adv_search_filters" class="adv_filter_block">
+      <div class="adv_filter_block_item">
+        <div>
+          <strong><label for="ord.id">[% l('Search Library') %]</label></strong>
+        </div>
+        <div>
+          [% PROCESS "opac/parts/org_selector.tt2" %]
+          [% INCLUDE build_org_selector show_loc_groups=1 id=org.id %]
+          <span class="course_search_archived">
+            <input type="checkbox" name="modifier" value="include_archived"
+              [% CGI.param('modifier').grep('include_archived').size ? ' checked="checked"' : '' %]
+              id="opac.course_result.include_archived" />
+            <label for="opac.course_result.include_archived">
+              [% l('Include Archived Courses?') %]
+            </label>
+          </span>
+        </div>
+      </div>
+    </div>
+    
+    <div class="advanced_div">
+      <div id='adv_global_search' class='data_grid data_grid_center'>
+        <div id='adv_search_rows'>
+          <div class='adv_global_input_container'>
+            <table id="adv_global_input_table" role="presentation">
+              <tbody id='adv_global_tbody'>
+                [% INCLUDE "opac/parts/course_search/global_row.tt2" %]
+                <!-- add a new row -->
+                <tr id="adv_global_addrow">
+                  <td class="td-search-left">
+                    <a href="javascript:;" id="myopac_new_global_row" 
+                      onclick='addSearchRow();'>
+                      [% l('Add Search Row') %]
+                    </a>
+                  </td>
+                </tr>
+                <tr>
+              </tbody>
+            </table>
+          </div>
+        </div>
+
+        <div id='course_search_submit'>
+          <input type="hidden" name="_course" value="1" />
+          <span>
+            <input id='search-submit-go' type="submit" value="[% l('Search') %]" title="[% l('Search') %]" class="opac-button"
+              onclick='setTimeout(function(){$("search-submit-spinner").className=""; $("search-submit-go").className="hidden"}, 2000)'/>
+            <img id='search-submit-spinner' src='/opac/images/progressbar_green.gif[% ctx.cache_key %]'
+              class='hidden' alt="[% l('Search in progress icon') %]"/>
+          </span>
+          <a href="[% mkurl(ctx.opac_root _ '/course_search', {$loc_name => loc_value}, 1) %]"
+            class="opac-button">[% l('Clear Form') %]</a>
+        </div>
+      </div>
+    </div>
+    <div class="common-full-pad"></div>
+  </form>
+  </div>
+</div>
+
+[% END %]
index df0122f..575d468 100755 (executable)
@@ -1752,14 +1752,11 @@ div.result_table_utils_cont {
     text-transform:none;
 }
 
-.search_catalog_lbl {
-    font-size: [% css_fonts.size_bigger %];
-}
-.adv_search_catalog_lbl {
-    font-size: [% css_fonts.size_bigger %];
-}
-
-.browse_the_catalog_lbl {
+.search_catalog_lbl,
+.adv_search_catalog_lbl,
+.browse_the_catalog_lbl,
+.search_courses_lbl,
+.browse_courses_lbl {
     font-size: [% css_fonts.size_bigger %];
 }
 
index 0432fff..130d8aa 100755 (executable)
@@ -44,8 +44,10 @@ IF has_copies or ctx.foreign_copies;
             [%- END %]
             <th scope='col'>[% l("Barcode") %]</th>
             <th scope='col'>[% l("Shelving Location") %]</th>
-            [%- IF ctx.is_staff %]
+            [%- IF ctx.is_staff || ctx.use_courses %]
             <th scope='col'>[% l("Circulation Modifier") %]</th>
+            [%- END %]
+            [%- IF ctx.is_staff %]
             <th scope='col'>[% l("Age Hold Protection") %]</th>
             <th scope='col'>[% l("Active/Create Date") %]</th>
             [%- END %]
@@ -54,6 +56,9 @@ IF has_copies or ctx.foreign_copies;
             [%- END %]
             <th scope='col'>[% l("Status") %]</th>
             <th scope='col'>[% l("Due Date") %]</th>
+            [%- IF ctx.use_courses %]
+            <th scope='col'>[% l("Courses") %]</th>
+            [%- END %]
         </tr>
     </thead>
     <tbody>
@@ -139,8 +144,12 @@ END; # FOREACH bib
                 END; -%]
             </td>
             <td property="availableAtOrFrom">[%- INCLUDE "opac/parts/location_name_link.tt2"; -%]</td>
-            [%- IF ctx.is_staff %]
+            [% IF copy_info.courses.size > 0 || ctx.is_staff %]
             <td>[% copy_info.circ_modifier | html %]</td>
+            [% ELSIF ctx.use_courses %]
+            <td></td>
+            [% END %]
+            [% IF ctx.is_staff %]
             <td>
                 [% copy_info.age_protect ?
                     ctx.get_crahp(copy_info.age_protect).name : l('None') | html %]
@@ -224,6 +233,11 @@ END; # FOREACH bib
                 ELSE;
                     '-';
                 END %]</td>
+            [%- IF ctx.use_courses %]
+            <td>[%- FOREACH course IN copy_info.courses %]
+                <div>[% course.course_number %]</div>
+            [% END %]</td>
+            [% END %]
         </tr>
 
         [% IF copy_info.notes; %]
index 7f3ab3c..8395412 100755 (executable)
                                     [% UNLESS rec.mmr_id;
                                             PROCESS "opac/parts/result/copy_counts.tt2";
                                     END; %]
+                                    [% IF ctx.use_courses %]
+                                        [%- courseStrings = [] %]
+                                        [% FOREACH course IN rec.courses %]
+                                            [% courseString = course.name _ ' (' _ course.course_number _ ')' %]
+                                            [% courseStrings.push(courseString); %]
+                                        [% END %]
+                                        [% IF courseStrings.size > 0 %]
+                                            <span><strong>[% l('Associated Courses: ') %]</strong></span>
+                                            <span>[% courseStrings.join(', ') %]</span>
+                                        [% END %]
+                                    [% END %]
                                     [% IF rec.user_circulated %]
                                     <div class="result_item_circulated">
                                     <i class="fas fa-book-reader" aria-hidden="true"></i>
index faea851..27ff5d3 100755 (executable)
         [% ELSE %]
         <a href="[% mkurl(ctx.opac_root _ '/advanced', {},  expert_search_parms.merge(browse_search_parms, facet_search_parms)) %]" id="home_adv_search_link" class="nav-link active adv_search_catalog_lbl">[% l('Advanced Search') %]</a>
         [% END %]
+
+        [% IF ctx.page == 'course_search'; %]
+        <a href="[% mkurl(ctx.opac_root _ '/course_search') %]" id="home_course_search_link" class="nav-link active search_courses_lbl">[% l('Search Courses') %]</a>
+        [% ELSIF ctx.use_courses %]
+        <a href="[% mkurl(ctx.opac_root _ '/course_search') %]" id="home_course_search_link" class="nav-link search_courses_lbl">[% l('Search Courses') %]</a>
+        [% END %]
+        [% IF ctx.page == 'course_browse'; %]
+        <a href="[% mkurl(ctx.opac_root _ '/course_browse') %]" id="home_course_browse_link" class="nav-link active browse_courses_lbl">[% l('Browse Courses') %]</a>
+        [% ELSIF ctx.use_courses %]
+        <a href="[% mkurl(ctx.opac_root _ '/course_browse') %]" id="home_course_browse_link" class="nav-link browse_courses_lbl">[% l('Browse Courses') %]</a>
+        [% END %]
     </nav>
 </div>
  
@@ -26,4 +37,4 @@
         [% INCLUDE 'opac/parts/cart_nav.tt2' %]
     </div>
 </div>
-</div>
\ No newline at end of file
+</div>