diff --git a/ccm-theme-foundry/src/main/resources/themes/foundry/foundry/scripts/cms-admin.js b/ccm-theme-foundry/src/main/resources/themes/foundry/foundry/scripts/cms-admin.js
index 81e13da80..48b7a6fcf 100644
--- a/ccm-theme-foundry/src/main/resources/themes/foundry/foundry/scripts/cms-admin.js
+++ b/ccm-theme-foundry/src/main/resources/themes/foundry/foundry/scripts/cms-admin.js
@@ -174,10 +174,9 @@ function toggleSelectItemDialog(mode, dialogId) {
}
}
-function getJournalsForSelectAssetDialog(dialogId) {
+function getJournalsForSelectJournalDialog(dialogId) {
var dialog = document.querySelector("#" + dialogId);
- var type = dialog.getAttribute("data-assettype");
var targetId = dialog.getAttribute('data-targetId');
var filter = document.querySelector('#' + dialogId + '-journals-filter');
var query = filter.value;
@@ -188,7 +187,11 @@ function getJournalsForSelectAssetDialog(dialogId) {
0,
dispatcherPrefix.length - "/ccm".length
)
- + "/sci-publications/journals";
+ + "/scipublications/journals";
+
+ if (query !== null && query.length > 0) {
+ url = `${url}?query=${query}`;
+ }
request.open("GET", url);
request.addEventListener("load", function (event) {
@@ -199,21 +202,262 @@ function getJournalsForSelectAssetDialog(dialogId) {
for (i = 0; i < journals.length; ++i) {
var journal = journals[i];
tableRows = tableRows
- + "
"
- + "| "
- + ""
- + journal["title"]
- + " | "
- + "
";
+ + `
+ |
+
+ ${journal["title"]}
+
+ |
+
`;
}
document
.querySelector("#" + dialogId + " tbody")
.innerHTML = tableRows;
+ } else {
+ alert("Error while retrieving journals. "
+ + `Response code: ${request.status} `
+ + `Message: ${request.statusText}`);
}
});
request.send();
}
+function setSelectedJournal(journalId, journalTitle, targetId, dialogId) {
+ var target = document.querySelector(`#${targetId}`);
+ var targetText = document.querySelector(`#${targetId}-selected`);
+
+ target.value = journalId;
+ targetText.textContent = journalTitle;
+
+ toggleSelectJournalDialog('hide', dialogId);
+}
+
+function toggleSelectJournalDialog(mode, dialogId) {
+ var dialog = document.querySelector("#" + dialogId);
+
+ if ('show' === mode) {
+ dialog.setAttribute('open', 'open');
+ getAssetsForSelectAssetDialog(dialogId);
+ } else {
+ dialog.setAttribute('open', 'false');
+ }
+}
+
+function getItemsForSelectPublicationDialog(dialogId) {
+ var dialog = document.querySelector('#' + dialogId);
+ var type = dialog.getAttribute("data-publicationtype");
+ var targetId = dialog.getAttribute('data-targetId');
+ var filter = document.querySelector(`#${dialogId}-publication-filter`);
+ var query = filter.value;
+ var dispatcherPrefix = dialog.getAttribute('data-dispatcherPrefix');
+
+ var request = new XMLHttpRequest();
+ var url = `${dispatcherPrefix.substring(0,
+ dispatcherPrefix.length - "/ccm".length)}/scipublications/publications`;
+ if (filter !== null && type.length > 0) {
+ url = `${url}?type=${type}`;
+ }
+
+ if ((type !== null && type.length > 0)
+ && (query !== null && query.length > 0)) {
+ url = `${url}&query=${query}`;
+ } else if (query !== null && query.length > 0) {
+ url = `${url}?query=${query}`;
+ }
+
+ request.open("GET", url);
+ request.addEventListener("load", function (event) {
+ if (request.status >= 200 && request.status < 300) {
+ var publications = JSON.parse(request.responseText);
+ var tableRows = "";
+ var i;
+ for (i = 0; i < publications.length; ++i) {
+ var publication = publications[i];
+ var publicationStr = `${publication.authors} (${publication.year}): ${publication.title}`;
+
+ if (publications.publisher) {
+ publicationStr = `${publicationStr}: ${publication.place}: ${publication.publisher}`;
+ }
+
+ tableRows = tableRows
+ + `
+ |
+
+ ${publicationStr}
+
+ |
+
`;
+ }
+ document
+ .querySelector(`#${dialogId} tbody`)
+ .innerHTML = tableRows;
+ } else {
+ alert("Error while retrieving publications. "
+ + "Response code: " + request.status + " "
+ + "Message: " + request.statusText);
+ }
+ });
+ request.send();
+}
+
+function setSelectedPublication(publicationId, publicationStr, targetId,
+ dialogId) {
+ var target = document.querySelector(`#${targetId}`);
+ var targetText = document.querySelector(`#${targetId}-selected`);
+
+ target.value = publicationId;
+ targetText.textContent = publicationStr;
+
+ toggleSelectPublicationDialog('hide', dialogId);
+}
+
+function toggleSelectPublicationDialog(mode, dialogId) {
+ var dialog = document.querySelector("#" + dialogId);
+
+ if ('show' === mode) {
+ dialog.setAttribute('open', 'open');
+ getAssetsForSelectAssetDialog(dialogId);
+ } else {
+ dialog.setAttribute('open', 'false');
+ }
+}
+
+function getPublishersForSelectPublisherDialog(dialogId) {
+ var dialog = document.querySelector("#" + dialogId);
+ var targetId = dialog.getAttribute('data-targetId');
+ var filter = document.querySelector('#' + dialogId + '-publisher-filter');
+ var query = filter.value;
+ var dispatcherPrefix = dialog.getAttribute('data-dispatcherPrefix');
+
+ var request = new XMLHttpRequest();
+ var url = `${dispatcherPrefix.substring(0,
+ dispatcherPrefix.length - "/ccm".length)}/scipublications/publishers}`;
+ if (query !== null && query.length > 0) {
+ url = `${url}?query=${query}`;
+ }
+
+ request.open("GET", url);
+ request.addEventListener("load", function (event) {
+ if (request.status >= 200 && request.status < 300) {
+ var publishers = JSON.parse(request.responseText);
+ var tableRows = "";
+ var i;
+ for (i = 0; i < publishers.length; ++i) {
+ var publisher = publishers[i];
+ tableRows = tableRows
+ + `
+|
+
+ ${publisher.name}, ${publisher.place}
+
+ |
+
`;
+ }
+ document
+ .querySelector("#" + dialogId + " tbody")
+ .innerHTML = tableRows;
+ } else {
+ alert("Error while retrieving publishers. "
+ + `Response code: ${request.status} `
+ + `Message: ${request.statusText}`);
+ }
+ });
+ request.send();
+}
+
+function setSelectedPublisher(publisherId, publisherStr, targetId, dialogId) {
+ var target = document.querySelector(`#${targetId}`);
+ var targetText = document.querySelector(`#${targetId}-selected`);
+
+ target.value = publisherId;
+ targetText.textContent = publisherStr;
+
+ toggleSelectPublisherDialog("hide", dialogId);
+}
+
+function toggleSelectPublisherDialog(mode, dialogId) {
+ var dialog = document.querySelector("#" + dialogId);
+
+ if ('show' === mode) {
+ dialog.setAttribute('open', 'open');
+ getAssetsForSelectAssetDialog(dialogId);
+ } else {
+ dialog.setAttribute('open', 'false');
+ }
+}
+
+function getSeriesForSelectSeriesDialog(dialogId) {
+ var dialog = document.querySelector("#" + dialogId);
+ var targetId = dialog.getAttribute('data-targetId');
+ var filter = document.querySelector('#' + dialogId + '-series-filter');
+ var query = filter.value;
+ var dispatcherPrefix = dialog.getAttribute('data-dispatcherPrefix');
+
+ var request = new XMLHttpRequest();
+ var url = dispatcherPrefix.substring(
+ 0,
+ dispatcherPrefix.length - "/ccm".length
+ )
+ + "/scipublications/series";
+
+ if (query !== null && query.length > 0) {
+ url = `${url}?query=${query}`;
+ }
+
+ request.open("GET", url);
+ request.addEventListener("load", function (event) {
+ if (request.status >= 200 && request.status < 300) {
+ var seriesList = JSON.parse(request.responseText);
+ var tableRows = "";
+ var i;
+ for (i = 0; i < seriesList.length; ++i) {
+ var series = seriesList[i];
+ tableRows = tableRows
+ + `
+ |
+
+ ${series.name}
+
+ |
+
`;
+ }
+ document
+ .querySelector("#" + dialogId + " tbody")
+ .innerHTML = tableRows;
+ } else {
+ alert("Error while retrieving series. "
+ + `Response code: ${request.status} `
+ + `Message: ${request.statusText}`);
+ }
+ });
+ request.send();
+}
+
+function setSelectedSeries(seriesId, seriesName, targetId, dialogId) {
+ var target = document.querySelector(`#${targetId}`);
+ var targetText = document.querySelector(`#${targetId}-selected`);
+
+ target.value = seriesId;
+ targetText.textContent = seriesName;
+
+ toggleSelectSeriesDialog('hide', dialogId);
+}
+
+function toggleSelectSeriesDialog(dialogId) {
+ var dialog = document.querySelector("#" + dialogId);
+
+ if ('show' === mode) {
+ dialog.setAttribute('open', 'open');
+ getAssetsForSelectAssetDialog(dialogId);
+ } else {
+ dialog.setAttribute('open', 'false');
+ }
+}
+
document.addEventListener('DOMContentLoaded', function () {
var i;