First part of support for search widgets from SciPublications

pull/2/head
Jens Pelzetter 2019-10-26 19:05:37 +02:00
parent 115b6d8a79
commit b85df7c326
8 changed files with 321 additions and 40 deletions

View File

@ -27,7 +27,11 @@
<xsl:import href="cms/image.xsl" /> <xsl:import href="cms/image.xsl" />
<xsl:import href="cms/item-search-widget.xsl" /> <xsl:import href="cms/item-search-widget.xsl" />
<xsl:import href="cms/item-summary.xsl" /> <xsl:import href="cms/item-summary.xsl" />
<xsl:import href="cms/journal-search-widget.xsl" />
<xsl:import href="cms/notes.xsl" /> <xsl:import href="cms/notes.xsl" />
<xsl:import href="cms/publication-search-widget.xsl" />
<xsl:import href="cms/publisher-search-widget.xsl" />
<xsl:import href="cms/series-search-widget.xsl" />
<xsl:import href="cms/tasks-panel.xsl" /> <xsl:import href="cms/tasks-panel.xsl" />
</xsl:stylesheet> </xsl:stylesheet>

View File

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (C) 2019 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
-->
<!--
Processes the publisher search widget.
Author: Jens Pelzetter, jens.pelzetter@googlemail.com
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bebop="http://www.arsdigita.com/bebop/1.0"
xmlns:cms="http://www.arsdigita.com/cms/1.0"
xmlns:foundry="http://foundry.libreccm.org"
xmlns:nav="http://ccm.redhat.com/navigation"
exclude-result-prefixes="xsl bebop cms foundry nav"
version="2.0">
<xsl:template match="cms:publisher-search-widget">
<div class="publisher-search-widget">
<xsl:choose>
<xsl:when test="./cms:selected-publisher">
<p>
<xsl:value-of select="./cms:selected-publisher/@name" />
</p>
<p>
<xsl:value-of select="./cms:selected-publisher/@place" />
</p>
<input type="hidden"
id="{./@name}"
value="{./selected-publisher/@publisherId}" />
</xsl:when>
<xsl:otherwise>
<p id="{concat(./@name, '-selected')">
<strong>
<xsl:value-of select="foundry:get-internal-static-text('cms', 'publisher-search-widget/no-publisher-selected')" />
</strong>
</p>
</xsl:otherwise>
</xsl:choose>
<button id="{concat(./@name, 'select-publisher-button')}"
type="button"
class="select-publisher-button"
data-dialogId="{concat(./@name, '-dialog')}"
data-target="{./@name}">
<xsl:value-of select="foundry:get-internal-static-text('cms', 'publisher-search-widget/select-publisher-button')" />
</button>
<dialog id="{concat(./@name, '-dialog')}"
class="publisher-search-widget-dialog"
data-dispatcherPrefix="{$dispatcher-prefix}"
data-targetId="{./@name}">
<h3 class="titlebar">
<xsl:value-of select="foundry:get-internal-static-text('cms', 'publisher-search-widget/titlebar')" />
<button type="button"
class="close-button"
data-dialogId="{concat(./@name, '-dialog')}">
<span>
<xsl:value-of select="foundry:get-internal-static-text('cms', 'publisher-search-widget/titlebar/close')" />
</span>
</button>
</h3>
<div class="controls">
<input type="hidden" id="{concat(./@name, '-last-focus')}" />
<label for="{concat(./@name, 'publisher-filter')}">
<xsl:value-of select="foundry:get-internal-static-text('cms', 'publisher-search-widget/filter-list')" />
</label>
<input type="text" id="{concat(./@name, '-dialog-publisher-filter')}" />
<button type="button"
class="apply-filter"
data-dialogId="{concat(./@name, '-dialog')}">
<xsl:value-of select="foundry:get-internal-static-text('cms', 'publisher-search-widget/filter-list/apply')" />
</button>
</div>
<div class="selectable-publishers">
<table>
<thead>
<tr>
<th>
<xsl:value-of select="foundry:get-internal-static-text('cms', 'publisher-search-widget/table/header/name')" />
</th>
<th>
<xsl:value-of select="foundry:get-internal-static-text('cms', 'publisher-search-widget/table/header/place')" />
</th>
</tr>
</thead>
</table>
<tbody>
<tr>
<td>$name</td>
</tr>
<tr>
<td>$place</td>
</tr>
</tbody>
</div>
</dialog>
</div>
</xsl:template>
</xsl:stylesheet>

View File

@ -24,7 +24,13 @@ function getAssetsForSelectAssetDialog(dialogId) {
var dispatcherPrefix = dialog.getAttribute('data-dispatcherPrefix'); var dispatcherPrefix = dialog.getAttribute('data-dispatcherPrefix');
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
var url = dispatcherPrefix.substring(0, dispatcherPrefix.length - "/ccm".length) + "/content-sections/" + contentSection + "/assets/"; var url = dispatcherPrefix.substring(
0,
dispatcherPrefix.length - "/ccm".length
)
+ "/content-sections/"
+ contentSection
+ "/assets/";
if (type !== null && type.length > 0) { if (type !== null && type.length > 0) {
url = url + "?type=" + type; url = url + "?type=" + type;
} }
@ -102,7 +108,8 @@ function getItemsForSelectItemDialog(dialogId) {
var dispatcherPrefix = dialog.getAttribute('data-dispatcherPrefix'); var dispatcherPrefix = dialog.getAttribute('data-dispatcherPrefix');
var request = new XMLHttpRequest(); var request = new XMLHttpRequest();
var url = dispatcherPrefix.substring(0, dispatcherPrefix.length - "/ccm".length) + "/content-sections/" + contentSection + "/items/?version=DRAFT"; var url = dispatcherPrefix.substring(0,
dispatcherPrefix.length - "/ccm".length) + "/content-sections/" + contentSection + "/items/?version=DRAFT";
if (type !== null && type.length > 0) { if (type !== null && type.length > 0) {
url = url + "?type=" + type; url = url + "?type=" + type;
} }
@ -167,6 +174,46 @@ function toggleSelectItemDialog(mode, dialogId) {
} }
} }
function getJournalsForSelectAssetDialog(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;
var dispatcherPrefix = dialog.getAttribute('data-dispatcherPrefix');
var request = new XMLHttpRequest();
var url = dispatcherPrefix.substring(
0,
dispatcherPrefix.length - "/ccm".length
)
+ "/sci-publications/journals";
request.open("GET", url);
request.addEventListener("load", function (event) {
if (request.status >= 200 && request.status < 300) {
var journals = JSON.parse(request.responseText);
var tableRows = "";
var i;
for (i = 0; i < journals.length; ++i) {
var journal = journals[i];
tableRows = tableRows
+ "<tr>"
+ "<td>"
+ "<a href=\"#\" onclick=\"setSelectedJournal(" + journal["journalId"] + ", \'" + journal["title"] + "\', \'" + targetId + "\', \'" + dialogId + "\')\">"
+ journal["title"]
+ "</td>"
+ "</tr>";
}
document
.querySelector("#" + dialogId + " tbody")
.innerHTML = tableRows;
}
});
request.send();
}
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
var i; var i;
@ -185,7 +232,8 @@ document.addEventListener('DOMContentLoaded', function () {
}); });
} }
var closeButtons = document.querySelectorAll('.asset-search-widget-dialog .close-button'); var closeButtons = document.querySelectorAll(
'.asset-search-widget-dialog .close-button');
for (i = 0; i < closeButtons.length; ++i) { for (i = 0; i < closeButtons.length; ++i) {
closeButtons[i].addEventListener('click', function (event) { closeButtons[i].addEventListener('click', function (event) {
@ -201,7 +249,8 @@ document.addEventListener('DOMContentLoaded', function () {
} }
var applyButtons = document.querySelectorAll('.asset-search-widget-dialog .apply-filter'); var applyButtons = document.querySelectorAll(
'.asset-search-widget-dialog .apply-filter');
for (i = 0; i < applyButtons.length; ++i) { for (i = 0; i < applyButtons.length; ++i) {
applyButtons[i].addEventListener('click', function (event) { applyButtons[i].addEventListener('click', function (event) {
@ -235,7 +284,8 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
} }
var closeButtons = document.querySelectorAll('.item-search-widget-dialog .close-button'); var closeButtons = document.querySelectorAll(
'.item-search-widget-dialog .close-button');
for (i = 0; i < closeButtons.length; ++i) { for (i = 0; i < closeButtons.length; ++i) {
closeButtons[i].addEventListener('click', function (event) { closeButtons[i].addEventListener('click', function (event) {
@ -250,7 +300,8 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
} }
var applyButtons = document.querySelectorAll('.item-search-widget-dialog .apply-filter'); var applyButtons = document.querySelectorAll(
'.item-search-widget-dialog .apply-filter');
for (i = 0; i < applyButtons.length; ++i) { for (i = 0; i < applyButtons.length; ++i) {
applyButtons[i].addEventListener('click', function (event) { applyButtons[i].addEventListener('click', function (event) {

View File

@ -1441,7 +1441,12 @@ img.cmsImageDisplay {
} }
div.asset-search-widget dialog, div.asset-search-widget dialog,
div.item-search-widget dialog { div.item-search-widget dialog,
div.journal-search-widget dialog,
div.publication-search-widget dialog,
div.publisher-search-widget dialog,
div.series-search-widget dialog {
background-color: #e6e4f2; background-color: #e6e4f2;
border: 0px solid transparent; border: 0px solid transparent;
@ -1464,22 +1469,38 @@ div.item-search-widget dialog {
} }
div.asset-search-widget dialog[open="open"], div.asset-search-widget dialog[open="open"],
div.item-search-widget dialog[open="open"] { div.item-search-widget dialog[open="open"],
div.journal-search-widget dialog[open="open"],
div.publication-search-widget dialog[open="open"],
div.publisher-search-widget dialog[open="open"],
div.series-search-widget dialog[open="open"] {
display: block; display: block;
} }
div.asset-search-widget dialog .controls, div.asset-search-widget dialog .controls,
div.item-search-widget dialog .controls { div.item-search-widget dialog .controls,
div.journal-search-widget .controls,
div.publication-search-widget .controls,
div.publisher-search-widget .controls,
div.series-search-widget .controls {
padding: 0.5em; padding: 0.5em;
} }
div.asset-search-widget dialog .controls .apply-filter, div.asset-search-widget dialog .controls .apply-filter,
div.item-search-widget dialog .controls .apply-filter{ div.item-search-widget dialog .controls .apply-filter,
div.journal-search-widget .controls .apply-filter,
div.publication-search-widget .controls .apply-filter,
div.publisher-search-widget .controls .apply-filter,
div.series-search-widget .controls .apply-filter {
margin-left: 0.5em; margin-left: 0.5em;
} }
div.asset-search-widget dialog .controls label, div.asset-search-widget dialog .controls label,
div.item-search-widget dialog .controls label { div.item-search-widget dialog .controls label,
div.journal-search-widget .controls .label ,
div.publication-search-widget .controls .label,
div.publisher-search-widget .controls .label,
div.series-search-widget .controls .label {
font-weight: bold; font-weight: bold;
@ -1487,14 +1508,22 @@ div.item-search-widget dialog .controls label {
} }
div.asset-search-widget dialog .dialogarea controls button, div.asset-search-widget dialog .dialogarea controls button,
div.item-search-widget dialog .dialogarea controls button{ div.item-search-widget dialog .dialogarea controls button,
div.journal-search-widget .dialogarea controls button,
div.publication-search-widget .dialogarea controls button,
div.publisher-search-widget .dialogarea controls button,
div.series-search-widget {
margin-left: 0.5em; margin-left: 0.5em;
} }
div.asset-search-widget dialog .dialogarea table, div.asset-search-widget dialog .dialogarea table,
div.item-search-widget dialog .dialogarea table { div.item-search-widget dialog .dialogarea table,
div.journal-search-widget .dialogarea table ,
div.publication-search-widget .dialogarea table,
div.publisher-search-widget .dialogarea table,
div.series-search-widget .dialogarea table {
margin-top: 1em; margin-top: 1em;
margin-left: 0.5em; margin-left: 0.5em;
@ -1502,7 +1531,11 @@ div.item-search-widget dialog .dialogarea table {
} }
div.asset-search-widget dialog .titlebar, div.asset-search-widget dialog .titlebar,
div.item-search-widget dialog .titlebar { div.item-search-widget dialog .titlebar,
.div.journal-search-widget dialog .titlebar,
div.publication-search-widget dialog .titlebar,
div.publisher-search-widget dialog .titlebar,
div.series-search-widget dialog .titlebar {
margin-top: 0; margin-top: 0;
padding: 0.5em 1em; padding: 0.5em 1em;
@ -1520,7 +1553,11 @@ div.item-search-widget dialog .titlebar {
} }
div.asset-search-widget dialog .titlebar .close-button, div.asset-search-widget dialog .titlebar .close-button,
div.item-search-widget dialog .titlebar .close-button { div.item-search-widget dialog .titlebar .close-button,
div.journal-search-widget.titlebar .close-button,
div.publication-search-widget .titlebar .close-button,
div.publisher-search-widget .titlebar .close-button,
div.series-search-widget.titlebar .close-button {
background-color: transparent; background-color: transparent;
@ -1537,12 +1574,20 @@ div.item-search-widget dialog .titlebar .close-button {
} }
div.asset-search-widget dialog .titlebar .close-button:after, div.asset-search-widget dialog .titlebar .close-button:after,
div.item-search-widget dialog .titlebar .close-button:after { div.item-search-widget dialog .titlebar .close-button:after,
div.journal-search-widget .titlebar .close-button:after ,
div.publication-search-widget .titlebar .close-button:after ,
div.publisher-search-widget .titlebar .close-button:after ,
div.series-search-widget .titlebar .close-button:after {
content: '\2715'; content: '\2715';
} }
div.asset-search-widget dialog .titlebar .close-button span, div.asset-search-widget dialog .titlebar .close-button span,
div.item-search-widget dialog .titlebar .close-button span { div.item-search-widget dialog .titlebar .close-button span,
div.journal-search-widget .titlebar .close-button span ,
div.publication-search-widget .titlebar .close-button span ,
div.publisher-search-widget .titlebar .close-button span ,
div.series-search-widget .titlebar .close-button span {
position: absolute; position: absolute;
top: -999px; top: -999px;
@ -1553,24 +1598,40 @@ div.item-search-widget dialog .titlebar .close-button span {
} }
div.asset-search-widget dialog .titlebar .close-button:hover, div.asset-search-widget dialog .titlebar .close-button:hover,
div.item-search-widget dialog .titlebar .close-button:hover { div.item-search-widget dialog .titlebar .close-button:hover,
div.journal-search-widget dialog .titlebar .close-button:hover ,
div.publication-search-widget dialog .titlebar .close-button:hover ,
div.publisher-search-widget dialog .titlebar .close-button:hover ,
div.series-search-widget dialog .titlebar .close-button:hover {
cursor: pointer; cursor: pointer;
} }
div.asset-search-widget dialog .selectable-assets table, div.asset-search-widget dialog .selectable-assets table,
div.item-search-widget dialog .selectable-items table{ div.item-search-widget dialog .selectable-items table,
div.journal-search-widget dialog .selectable-items table ,
div.publication-search-widget dialog .selectable-items table ,
div.publisher-search-widget dialog .selectable-items table ,
div.series-search-widget dialog .selectable-items table {
width: 100%; width: 100%;
padding: 0.35em; padding: 0.35em;
table-layout: fixed; table-layout: fixed;
} }
div.asset-search-widget dialog .selectable-assets table tbody tr td, div.asset-search-widget dialog .selectable-assets table tbody tr td,
div.item-search-widget dialog .selectable-items table tbody tr td{ div.item-search-widget dialog .selectable-items table tbody tr td,
div.journal-search-widget dialog .selectable-items table tbody tr td ,
div.publication-search-widget dialog .selectable-items table tbody tr td ,
div.publisher-search-widget dialog .selectable-items table tbody tr td ,
div.series-search-widget dialog .selectable-items table tbody tr td {
overflow: hidden; overflow: hidden;
} }
div.asset-search-widget dialog .selectable-assets table thead th, div.asset-search-widget dialog .selectable-assets table thead th,
div.item-search-widget dialog .selectable-items table thead th{ div.item-search-widget dialog .selectable-items table thead th,
div.journal-search-widget dialog .selectable-items table thead th ,
div.publication-search-widget dialog .selectable-items table thead th ,
div.publisher-search-widget dialog .selectable-items table thead th ,
div.series-search-widget dialog .selectable-items table thead th {
text-align: center; text-align: center;
} }

View File

@ -54,7 +54,6 @@
<translation lang="en">Close without selecting an asset</translation> <translation lang="en">Close without selecting an asset</translation>
</text> </text>
<text id="category-step/header"> <text id="category-step/header">
<translation lang="de">Zugewiesene Kategorien bearbeiten</translation> <translation lang="de">Zugewiesene Kategorien bearbeiten</translation>
<translation lang="en">Edit assigned categories</translation> <translation lang="en">Edit assigned categories</translation>
@ -123,6 +122,51 @@
<translation lang="en">Close</translation> <translation lang="en">Close</translation>
</text> </text>
<text id="publisher-search-widget/filter-list">
<translation lang="de">Filtern nach</translation>
<translation lang="en">Filter using</translation>
</text>
<text id="publisher-search-widget/filter-list/apply">
<translation lang="de">Anwenden</translation>
<translation lang="en">Apply</translation>
</text>
<text id="publisher-search-widget/no-publisher-selected">
<translation lang="de">Kein Verlag ausgewählt</translation>
<translation lang="en">No publisher selected</translation>
</text>
<text id="publisher-search-widget/selected-publisher">
<translation lang="de">Ausgewählter Verlag</translation>
<translation lang="en">Selected publisher</translation>
</text>
<text id="publisher-search-widget/selected-publisher-name">
<translation lang="de">Name</translation>
<translation lang="en">Name</translation>
</text>
<text id="publisher-search-widget/selected-publisher-type">
<translation lang="de">Type</translation>
<translation lang="en">Typ</translation>
</text>
<text id="publisher-search-widget/select-publisher-button">
<translation lang="de">Verlag auswählen</translation>
<translation lang="en">Select publisher</translation>
</text>
<text id="publisher-search-widget/table/header/name">
<translation lang="de">Name</translation>
<translation lang="en">Name</translation>
</text>
<text id="publisher-search-widget/table/header/place">
<translation lang="de">Name</translation>
<translation lang="en">Name</translation>
</text>
<text id="publisher-search-widget/titlebar">
<translation lang="de">Wählen Sie den zu verwendenden Verlag aus</translation>
<translation lang="en">Select the publisher to use</translation>
</text>
<text id="publisher-search-widget/titlebar/close">
<translation lang="de">Ohne Auswahl schließen</translation>
<translation lang="en">Close without selecting an publisher</translation>
</text>
<text id="summary/itemSummary/header"> <text id="summary/itemSummary/header">
<translation lang="en">Item Summary</translation> <translation lang="en">Item Summary</translation>
<translation lang="de">Zusammenfassung</translation> <translation lang="de">Zusammenfassung</translation>