-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
50 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:"; | ||
}; | ||
}] | ||
}; | ||
}, | ||
], | ||
}; |