Hide Non-Local Collections

Developer

LaVonna Sydow, Reed

Description

Hides collections that aren’t from your institution in Primo Classic. Removes “Collection Path” header if none of the collections are local.

In Primo VE, collections from other Alliance institutions will be hidden by default, without this customization.

Before: Extra HathiTrust Emergency Temporary Access collection from another institution in addition to local collection
Before: Extra “HathiTrust Emergency Temporary Access” collection from another institution in addition to local collection
After: Extra collection removed; only local collection displayed
After: Extra collection removed; only local collection displayed
Before: Extra HathiTrust Emergency Temporary Access collection from another institution
Before: Extra “HathiTrust Emergency Temporary Access” collection from another institution
After: extra collection removed; no collections displayed
After: Extra collection removed; no collections displayed

System Components

custom.js, Alma Discovery configuration

Skillset Requirements

Comfortable copying and editing JavaScript

Accessibility

not tested

Browser Support

Tested on Chrome 96, Edge 95/96, Firefox 94, Safari 14

Mobile Support

Tested on Android

Implementation

1. In your custom.js, you’ll need the line

var app = angular.module('viewCustom', ['locCollOnly']);

If this line already exists with other modules listed, separate the items with commas

var app = angular.module('viewCustom', ['toggleInstitutions', 'locCollOnly']);

2. After that line, paste the following code:

angular.module('locCollOnly', []).component('prmCollectionNavigationBreadcrumbsItemAfter', {
  controller: function () {

    if (document.querySelectorAll('prm-collection-navigation-breadcrumbs')) {

    //ENTER YOUR INSTITUTION CODE HERE
    //var your_institution = "REED";

    var your_institution = "";

    //NO EDITING BEYOND THIS POINT

    if (!your_institution) return;
      var your_institution = angular.uppercase(your_institution);
      var getCollections = document.querySelectorAll('prm-collection-navigation-breadcrumbs')
        for (var i = 0; i < getCollections.length; i++) {
          console.log("Looping thru Collections");
          var getInnerhtml = getCollections[i].innerHTML;
          var reinst = /inst\=([A-Z]+)"\sng-click/;
          var getinst = getInnerhtml.match(reinst);
            if (getinst) {
              if (getinst[1] != your_institution) {
                getCollections[i].hidden = true;
                //If there are no local collections, hide the header Collection Path
                if (i == 0) document.querySelector('[title="Collection Path"]').innerText = "";
              }
            }
          }
        }
      },
    })

3. Edit the code, filling in you institution’s code for the your_institution variable. E.g., var your_institution = “REED”;

var your_institution = "";