OPAC: PINES Carousel Implementation
authorTerran McCanna <tmccanna@georgialibraries.org>
Thu, 12 Nov 2020 19:46:30 +0000 (14:46 -0500)
committerChris Sharp <csharp@georgialibraries.org>
Mon, 8 Nov 2021 14:26:40 +0000 (09:26 -0500)
Adds carousel display with custom carousel picker to home page.

Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/src/templates-bootstrap/opac/css/style.css.tt2
Open-ILS/src/templates-bootstrap/opac/parts/homesearch.tt2
Open-ILS/src/templates-bootstrap/opac/parts/org_selector.tt2

index a75c4d7..1b31f6e 100755 (executable)
@@ -3836,8 +3836,8 @@ label[for*=expert_]
 */
 
 .carousel {
-    width: 80%;
-    margin: 0 auto;
+    width: 50%;
+    margin-left: 450px;
 }
 .carousel-title {
     font-size: 150%;
@@ -3849,11 +3849,12 @@ label[for*=expert_]
     margin: 0px 3px;
 }
 .carousel-entry {
-    max-width: 150px;
+    max-width: 130px;
 }
 .carousel-entry-image {
-    width: 100%;
-    height: auto;
+    width: auto;
+    height: 160px;
+    border: 1px solid #999;
 }
 .carousel .glide__arrow {
     color: [% css_colors.button_text %];
@@ -3868,10 +3869,75 @@ label[for*=expert_]
     display: inline-block;
 }
 .carousel .glide__arrow--right {
-    right: -6em;
+    right: -5em;
 }
 .carousel .glide__arrow--left {
-    left: -6em;
+    left: -7em;
+}
+
+/* PINES Carousel customizations */
+#carousel_selector {
+    width: 300px;
+}
+
+.pines_carousel_selector {
+    float: left;
+    text-align: center;
+    height: 250px;
+    width: 350px;
+    margin-left: 0px;
+    margin-right: 40px;
+}
+
+.pines_carousel_selector_image {
+    height: 150px;
+}
+
+.pines_carousel_selector_text {
+    font-size: 125%;
+    font-weight: bold;
+    color: #006838;
+}
+
+@media only screen and (max-width: 1200px) {
+    .carousel {
+        margin-left: 430px;
+        width: 40%;
+    }
+    .carousel-entry-image {
+        width: auto;
+        height: 90px;
+        border: 1px solid #999;
+    }
+}
+
+@media only screen and (max-width: 1000px) {
+    .carousel {
+        margin: auto;
+        width: 80%;
+    }
+    .carousel-entry-image {
+        width: auto;
+        height: 100px;
+        border: 1px solid #999;
+    }
+    .pines_carousel_selector {
+        float: none;
+        text-align: center;
+        height: 80px;
+        width: 100%;
+        margin: auto;
+        margin-top: -50px;
+        margin-bottom: 40px;
+    }
+    .pines_carousel_selector_image {
+        display: none;
+    }
+    .pines_carousel_selector_text {
+        font-size: 125%;
+        font-weight: bold;
+        color: #006838;
+    }
 }
 
 .search-filter{
index 229d442..cde1bcc 100755 (executable)
@@ -1,5 +1,16 @@
-<div id="homeLogo">
-    
-</div>
+<!-- PINES Customizations -->
+
+    <div class="pines_carousel_selector">
+        <img alt="[% l('New Arrivals') %]" src="[% ctx.media_prefix %]/images/books.jpg" class="pines_carousel_selector_image"/><br/>
+        <span class="pines_carousel_selector_text">[% l('New Library Materials') %]</span><br/>
+        <br/>
+        <form>
+            [% INCLUDE build_org_selector_carousel show_loc_groups=1 %]
+        </form>
+    </div>
+
+<!-- End PINES Customizations -->
+
+    [% PROCESS carousels %]
+
 
-[% PROCESS carousels %]
index 89d5f6c..0701ad5 100755 (executable)
@@ -222,3 +222,136 @@ BLOCK build_scope_selector;
 
     </select>
 [%- END %]
+
+[%  # PINES Customization for Carousels
+    # Build org selector that refreshes page with carousel_loc set to control which carousels display
+
+BLOCK build_org_selector_carousel;
+    node_stack = [{org => org_unit || ctx.aouct_tree || ctx.aou_tree}];
+    inherited_vis = ctx.get_cgf('opac.org_unit.non_inherited_visibility').enabled == 'f';
+
+    IF !name;
+        name = loc_name;
+    END;
+    IF !value;
+        value = loc_value;
+    END;
+
+    # if the selected org unit is out of hiding scope,
+    # disable the ou-hide scoping altogether.
+    hiding_disabled = ctx.org_hiding_disabled(value);
+
+    -%]
+
+    <select id='carousel_selector'
+            title='[% arialabel || l("Select Library") %]'
+            class="org_selector_dropdown"
+            onchange="location = '/eg/opac/home?carousel_loc=' +
+                this.options[this.selectedIndex].value">
+    <option value="" class="org_unit" disabled selected="selected">[% l("Choose a library to see newly purchased items") %]</option>
+    [%-
+        WHILE node_stack.size > 0;
+            node = node_stack.pop();
+            org_unit = node.org;
+            loc_grp = node.loc_grp;
+            ou_id = org_unit.id;
+            css_class = '';
+            disabled = '';
+            selected = '';
+            visible = org_unit.opac_visible == 't';
+
+            # org and all children are invisible.
+            NEXT IF !visible AND inherited_vis AND !ctx.is_staff;
+
+            IF !loc_grp; # processing an org unit
+
+                top_loc_groups = [];
+                IF show_loc_groups;
+                    # add the location groups that sort below the child org units
+                    FOR grp IN ctx.copy_location_groups.$ou_id.reverse;
+                        IF grp.top == 't';
+                            top_loc_groups.push(grp);
+                        ELSE;
+                            node_stack.push({org => org_unit, loc_grp => grp});
+                        END;
+                    END;
+                END;
+
+                # add the child org units
+                FOR child IN org_unit.children.reverse;
+                    node_stack.push({org => child});
+                END;
+
+                # add the location groups that sort to the top
+                # above the child org units
+                FOR grp IN top_loc_groups;
+                    node_stack.push({org => org_unit, loc_grp => grp});
+                END;
+
+            END;
+
+            # org is not publicly visible (though its children may be).
+            NEXT UNLESS ctx.is_staff OR visible;
+
+            # org is not within hiding scope (though its children may be).
+            NEXT UNLESS hiding_disabled OR ctx.org_within_hiding_scope(ou_id);
+
+            node_value = ou_id;
+            IF loc_grp;
+                node_value = node_value _ ':' _ loc_grp.id;
+                css_class = 'class="loc_grp"';
+            ELSE;
+                css_class = 'class="org_unit"';
+            END;
+
+            IF can_have_vols_only AND org_unit.ou_type.can_have_vols != 't';
+                disabled = 'disabled="disabled"';
+            ELSIF node_value == value;
+                selected = 'selected="selected"';
+            END;
+
+            IF can_have_users_only AND org_unit.ou_type.can_have_users != 't';
+                disabled = 'disabled="disabled"';
+            ELSIF node_value == value;
+                selected = 'selected="selected"';
+            END;
+
+            IF hold_pickup_lib AND ctx.get_org_setting(
+                    org_unit.id, 'opac.holds.org_unit_not_pickup_lib');
+                disabled = 'disabled="disabled"';
+            END;
+
+            # caller provided a list of valid org units.
+            # all orgs not in the list are marked invalid.
+            IF valid_org_list AND
+                    !valid_org_list.grep('^' _ org_unit.id _ '$').size;
+                disabled = 'disabled="disabled"';
+                selected = '';
+            END;
+
+            pad_depth = 0;
+
+            # copy loc groups appear as children of the owning org unit
+            SET pad_depth = pad_depth + 1 IF loc_grp;
+
+            # determine the depth by calculating the distance from the root
+            porg = ctx.get_aou(org_unit.parent_ou);
+            WHILE porg;
+                SET pad_depth = pad_depth + 1 IF porg.opac_visible == 't' OR ctx.is_staff;
+                porg = ctx.get_aou(porg.parent_ou);
+            END;
+
+            pad_depth = pad_depth * 5;
+            display_name = loc_grp ? loc_grp.name : org_unit.name %]
+            [% IF node_value == 1 %]
+                [% display_name = "All PINES Libraries" %]
+            [% END %]
+
+            <option value='[% org_unit.id %]' [% selected %] [% disabled %] [% css_class %]>
+                [% '&nbsp;' FOR [0..pad_depth]; display_name | html %]
+            </option>
+
+        [%- END %]
+    </select>
+[%- END %]
+