Skip to content

Commit

Permalink
Update URL for boundwith display
Browse files Browse the repository at this point in the history
  • Loading branch information
little9 committed Oct 29, 2024
1 parent 8a10722 commit c6604d8
Showing 1 changed file with 50 additions and 32 deletions.
82 changes: 50 additions & 32 deletions src/components/prmLocationHoldingsAfter.js
Original file line number Diff line number Diff line change
@@ -1,76 +1,94 @@
export const prmLocationHoldingsAfter = {
bindings: { parentCtrl: '<' },
templateUrl: '/discovery/custom/01JHU_INST-JHU/html/prm-location-holdings-after.html',
controller: ['$scope', function ($scope) {
bindings: { parentCtrl: "<" },
templateUrl:
"/discovery/custom/01JHU_INST-JHU/html/prm-location-holdings-after.html",
controller: [
"$scope",
function ($scope) {
var ctrl = this;

this.$onInit = function () {
$scope.$watch(
function () {
return ctrl.parentCtrl && ctrl.parentCtrl.currLoc && ctrl.parentCtrl.currLoc.summaryHoldings;
return (
ctrl.parentCtrl &&
ctrl.parentCtrl.currLoc &&
ctrl.parentCtrl.currLoc.summaryHoldings
);
},
function (newVal) {
if (newVal) {
ctrl.holdings = ctrl.parentCtrl.currLoc.summaryHoldings.allLines;
}
},
true // deep watch to detect changes in nested objects
true, // deep watch to detect changes in nested objects
);
};

this.getAvailabilityLink = function (line) {
var mmsId = ctrl.extractMmsId(line.value);
return 'https://jhu-psb.primo.exlibrisgroup.com/discovery/fulldisplay?docid=alma' + mmsId + '&context=L&vid=01JHU_INST:JHU';
return (
"https://catalyst.library.jhu.edu/discovery/fulldisplay?docid=alma" +
mmsId +
"&context=L&vid=01JHU_INST:JHU"
);
};

this.getLinkText = function (line) {
var titleAuthor = ctrl.extractTitleAuthor(line.value);
return titleAuthor.title + ' - ' + titleAuthor.author;
return titleAuthor.title + " - " + titleAuthor.author;
};

this.extractMmsId = function (values) {
return values.find(value => /^\d+$/.test(value)) || '';
return values.find((value) => /^\d+$/.test(value)) || "";
};

this.extractTitleAuthor = function (values) {
var nonMmsValues = values.filter(value => !/^\d+$/.test(value));
var nonMmsValues = values.filter((value) => !/^\d+$/.test(value));
return {
title: nonMmsValues[0] || 'No title',
author: nonMmsValues[1] || 'No author'
title: nonMmsValues[0] || "No title",
author: nonMmsValues[1] || "No author",
};
};

this.hasValidLink = function (line) {
var mmsId = ctrl.extractMmsId(line.value);
return mmsId !== '';
return mmsId !== "";
};

this.shouldShowBaseSummary = function () {
return ctrl.parentCtrl.currLoc.locationNoItems ? ctrl.parentCtrl.summaryLinesVisible : !ctrl.parentCtrl.summaryLinesVisible;
return ctrl.parentCtrl.currLoc.locationNoItems
? ctrl.parentCtrl.summaryLinesVisible
: !ctrl.parentCtrl.summaryLinesVisible;
};

this.getBaseSummaryLines = function () {
return ctrl.parentCtrl.currLoc.summaryHoldings.baseSummaryShort;
};

this.getStyle = function () {
return (ctrl.parentCtrl.isIE && ctrl.parentCtrl.mediaQueries.xs) ? { 'width': '14em' } : {};
return ctrl.parentCtrl.isIE && ctrl.parentCtrl.mediaQueries.xs
? { width: "14em" }
: {};
};

this.isLink = function (value) {
return value.startsWith('http:') || value.startsWith('https:');
return value.startsWith("http:") || value.startsWith("https:");
};

this.shouldShowAllLines = function () {
return ctrl.parentCtrl.currLoc.locationNoItems ? !ctrl.parentCtrl.summaryLinesVisible : ctrl.parentCtrl.summaryLinesVisible;
return ctrl.parentCtrl.currLoc.locationNoItems
? !ctrl.parentCtrl.summaryLinesVisible
: ctrl.parentCtrl.summaryLinesVisible;
};

this.getAllLines = function () {
return ctrl.parentCtrl.currLoc.summaryHoldings.allLines;
};

this.isAvailabilityLine = function (line) {
return line.key === 'For availability see:';
return line.key === "For availability see:";
};
}]
};
},
],
};

0 comments on commit c6604d8

Please sign in to comment.